OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/test/plugin/plugin_client.h" | 5 #include "content/test/plugin/plugin_client.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/test/plugin/plugin_execute_stream_javascript.h" | 8 #include "content/test/plugin/plugin_execute_stream_javascript.h" |
9 #include "content/test/plugin/plugin_test.h" | 9 #include "content/test/plugin/plugin_test.h" |
10 #include "content/test/plugin/plugin_test_factory.h" | 10 #include "content/test/plugin/plugin_test_factory.h" |
11 | 11 |
12 namespace NPAPIClient { | 12 namespace NPAPIClient { |
13 | 13 |
| 14 class NPWithProperty : public NPObject { |
| 15 public: |
| 16 NPWithProperty() : NPObject() {} |
| 17 |
| 18 static NPObject* Allocate(NPP npp, NPClass* npclass) { |
| 19 return new NPWithProperty(); |
| 20 } |
| 21 |
| 22 static void Deallocate(NPObject* npobject) { |
| 23 delete static_cast<NPWithProperty*>(npobject); |
| 24 } |
| 25 |
| 26 static bool HasProperty(NPObject* npobject, NPIdentifier name) { |
| 27 return (name == PluginClient::HostFunctions()-> |
| 28 getstringidentifier("loadedProperty")); |
| 29 } |
| 30 |
| 31 static bool GetProperty(NPObject* npobject, |
| 32 NPIdentifier name, |
| 33 NPVariant* result) { |
| 34 if (name == PluginClient::HostFunctions()-> |
| 35 getstringidentifier("loadedProperty")) { |
| 36 BOOLEAN_TO_NPVARIANT(true, *result); |
| 37 return true; |
| 38 } |
| 39 return false; |
| 40 } |
| 41 }; |
| 42 |
| 43 static NPClass* GetNPClass() { |
| 44 static NPClass plugin_class = { |
| 45 NP_CLASS_STRUCT_VERSION, |
| 46 NPWithProperty::Allocate, |
| 47 NPWithProperty::Deallocate, |
| 48 NULL, // Invalidate |
| 49 NULL, // HasMethod |
| 50 NULL, // Invoke |
| 51 NULL, // InvokeDefault |
| 52 NPWithProperty::HasProperty, |
| 53 NPWithProperty::GetProperty, |
| 54 NULL, // SetProperty |
| 55 NULL, // RemoveProperty |
| 56 }; |
| 57 return &plugin_class; |
| 58 } |
| 59 |
14 NPNetscapeFuncs* PluginClient::host_functions_; | 60 NPNetscapeFuncs* PluginClient::host_functions_; |
15 | 61 |
16 NPError PluginClient::GetEntryPoints(NPPluginFuncs* pFuncs) { | 62 NPError PluginClient::GetEntryPoints(NPPluginFuncs* pFuncs) { |
17 if (pFuncs == NULL) | 63 if (pFuncs == NULL) |
18 return NPERR_INVALID_FUNCTABLE_ERROR; | 64 return NPERR_INVALID_FUNCTABLE_ERROR; |
19 | 65 |
20 if (pFuncs->size < sizeof(NPPluginFuncs)) | 66 if (pFuncs->size < sizeof(NPPluginFuncs)) |
21 return NPERR_INVALID_FUNCTABLE_ERROR; | 67 return NPERR_INVALID_FUNCTABLE_ERROR; |
22 | 68 |
23 pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; | 69 pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 269 |
224 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { | 270 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { |
225 if (instance == NULL) | 271 if (instance == NULL) |
226 return NPERR_INVALID_INSTANCE_ERROR; | 272 return NPERR_INVALID_INSTANCE_ERROR; |
227 | 273 |
228 if (variable == NPPVpluginNeedsXEmbed) { | 274 if (variable == NPPVpluginNeedsXEmbed) { |
229 *static_cast<NPBool*>(value) = 1; | 275 *static_cast<NPBool*>(value) = 1; |
230 return NPERR_NO_ERROR; | 276 return NPERR_NO_ERROR; |
231 } | 277 } |
232 | 278 |
| 279 if (variable == NPPVpluginScriptableNPObject) { |
| 280 *(NPObject**)value = |
| 281 NPAPIClient::PluginClient::HostFunctions()->createobject( |
| 282 instance, NPAPIClient::GetNPClass()); |
| 283 return NPERR_NO_ERROR; |
| 284 } |
| 285 |
233 // XXXMB - do work here. | 286 // XXXMB - do work here. |
234 return NPERR_GENERIC_ERROR; | 287 return NPERR_GENERIC_ERROR; |
235 } | 288 } |
236 | 289 |
237 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) { | 290 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) { |
238 if (instance == NULL) | 291 if (instance == NULL) |
239 return NPERR_INVALID_INSTANCE_ERROR; | 292 return NPERR_INVALID_INSTANCE_ERROR; |
240 | 293 |
241 // XXXMB - do work here. | 294 // XXXMB - do work here. |
242 return NPERR_GENERIC_ERROR; | 295 return NPERR_GENERIC_ERROR; |
(...skipping 18 matching lines...) Expand all Loading... |
261 } | 314 } |
262 } | 315 } |
263 | 316 |
264 NPError NPP_ClearSiteData(const char* site, | 317 NPError NPP_ClearSiteData(const char* site, |
265 uint64 flags, | 318 uint64 flags, |
266 uint64 max_age) { | 319 uint64 max_age) { |
267 VLOG(0) << "NPP_ClearSiteData called"; | 320 VLOG(0) << "NPP_ClearSiteData called"; |
268 return NPERR_NO_ERROR; | 321 return NPERR_NO_ERROR; |
269 } | 322 } |
270 } // extern "C" | 323 } // extern "C" |
OLD | NEW |