| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 NPRuntimeObjectFromDestroyedPlugin(NPP npp, const string& identifier) | 32 NPRuntimeObjectFromDestroyedPlugin(NPP npp, const string& identifier) |
| 33 : PluginTest(npp, identifier) | 33 : PluginTest(npp, identifier) |
| 34 { | 34 { |
| 35 } | 35 } |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 // This is the test object. | 38 // This is the test object. |
| 39 class TestObject : public Object<TestObject> { }; | 39 class TestObject : public Object<TestObject> { }; |
| 40 | 40 |
| 41 // This is the scriptable object. It has a single "testObject" property and
an "evaluate" function. | 41 // This is the scriptable object. It has a single "testObject" property and
an "evaluate" function. |
| 42 class ScriptableObject : public Object<ScriptableObject> { | 42 class ScriptableObject : public Object<ScriptableObject> { |
| 43 public: | 43 public: |
| 44 bool hasMethod(NPIdentifier methodName) | 44 bool hasMethod(NPIdentifier methodName) |
| 45 { | 45 { |
| 46 return identifierIs(methodName, "evaluate"); | 46 return identifierIs(methodName, "evaluate"); |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool invoke(NPIdentifier methodName, const NPVariant* args, uint32_t arg
Count, NPVariant* result) | 49 bool invoke(NPIdentifier methodName, const NPVariant* args, uint32_t arg
Count, NPVariant* result) |
| 50 { | 50 { |
| 51 if (!identifierIs(methodName, "evaluate")) | 51 if (!identifierIs(methodName, "evaluate")) |
| 52 return false; | 52 return false; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 70 NPObject* testObject = TestObject::create(pluginTest()); | 70 NPObject* testObject = TestObject::create(pluginTest()); |
| 71 OBJECT_TO_NPVARIANT(testObject, *result); | 71 OBJECT_TO_NPVARIANT(testObject, *result); |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 virtual NPError NPP_GetValue(NPPVariable variable, void *value) | 76 virtual NPError NPP_GetValue(NPPVariable variable, void *value) |
| 77 { | 77 { |
| 78 if (variable != NPPVpluginScriptableNPObject) | 78 if (variable != NPPVpluginScriptableNPObject) |
| 79 return NPERR_GENERIC_ERROR; | 79 return NPERR_GENERIC_ERROR; |
| 80 | 80 |
| 81 *(NPObject**)value = ScriptableObject::create(this); | 81 *(NPObject**)value = ScriptableObject::create(this); |
| 82 | 82 |
| 83 return NPERR_NO_ERROR; | 83 return NPERR_NO_ERROR; |
| 84 } | 84 } |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 static PluginTest::Register<NPRuntimeObjectFromDestroyedPlugin> npRuntimeObjectF
romDestroyedPlugin("npruntime-object-from-destroyed-plugin"); | 87 static PluginTest::Register<NPRuntimeObjectFromDestroyedPlugin> npRuntimeObjectF
romDestroyedPlugin("npruntime-object-from-destroyed-plugin"); |
| 88 | 88 |
| OLD | NEW |