OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "PluginTest.h" | 5 #include "PluginTest.h" |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 extern NPNetscapeFuncs *browser; | 8 extern NPNetscapeFuncs *browser; |
9 | 9 |
10 class FormValue : public PluginTest { | 10 class FormValue : public PluginTest { |
11 public: | 11 public: |
12 FormValue(NPP npp, const std::string& identifier) | 12 FormValue(NPP npp, const std::string& identifier) |
13 : PluginTest(npp, identifier) | 13 : PluginTest(npp, identifier) |
14 { | 14 { |
15 } | 15 } |
16 virtual NPError NPP_GetValue(NPPVariable, void*) override; | 16 NPError NPP_GetValue(NPPVariable, void*) override; |
17 }; | 17 }; |
18 | 18 |
19 NPError FormValue::NPP_GetValue(NPPVariable variable, void *value) | 19 NPError FormValue::NPP_GetValue(NPPVariable variable, void *value) |
20 { | 20 { |
21 if (variable == NPPVformValue) { | 21 if (variable == NPPVformValue) { |
22 static const char formValueText[] = "Plugin form value"; | 22 static const char formValueText[] = "Plugin form value"; |
23 *((void**)value) = browser->memalloc(sizeof(formValueText)); | 23 *((void**)value) = browser->memalloc(sizeof(formValueText)); |
24 if (!*((void**)value)) | 24 if (!*((void**)value)) |
25 return NPERR_OUT_OF_MEMORY_ERROR; | 25 return NPERR_OUT_OF_MEMORY_ERROR; |
26 strncpy(*((char**)value), formValueText, sizeof(formValueText)); | 26 strncpy(*((char**)value), formValueText, sizeof(formValueText)); |
27 return NPERR_NO_ERROR; | 27 return NPERR_NO_ERROR; |
28 } | 28 } |
29 return NPERR_GENERIC_ERROR; | 29 return NPERR_GENERIC_ERROR; |
30 } | 30 } |
31 | 31 |
32 static PluginTest::Register<FormValue> formValue("form-value"); | 32 static PluginTest::Register<FormValue> formValue("form-value"); |
OLD | NEW |