15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "PluginTest.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <string.h> 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)extern NPNetscapeFuncs *browser; 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class FormValue : public PluginTest { 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)public: 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FormValue(NPP npp, const std::string& identifier) 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : PluginTest(npp, identifier) 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual NPError NPP_GetValue(NPPVariable, void*) OVERRIDE; 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)NPError FormValue::NPP_GetValue(NPPVariable variable, void *value) 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles){ 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (variable == NPPVformValue) { 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static const char formValueText[] = "Plugin form value"; 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *((void**)value) = browser->memalloc(sizeof(formValueText)); 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!*((void**)value)) 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return NPERR_OUT_OF_MEMORY_ERROR; 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) strncpy(*((char**)value), formValueText, sizeof(formValueText)); 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return NPERR_NO_ERROR; 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return NPERR_GENERIC_ERROR; 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)static PluginTest::Register<FormValue> formValue("form-value"); 33