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 /* | 5 /* |
6 * Copyright (C) 2012 Apple Inc. All rights reserved. | 6 * Copyright (C) 2012 Apple Inc. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 30 matching lines...) Expand all Loading... |
41 { | 41 { |
42 } | 42 } |
43 | 43 |
44 private: | 44 private: |
45 class PluginObject : public Object<PluginObject> { | 45 class PluginObject : public Object<PluginObject> { |
46 public: | 46 public: |
47 PluginObject() | 47 PluginObject() |
48 { | 48 { |
49 } | 49 } |
50 | 50 |
51 virtual ~PluginObject() | 51 ~PluginObject() override {} |
52 { | |
53 } | |
54 | 52 |
55 bool hasProperty(NPIdentifier propertyName) | 53 bool hasProperty(NPIdentifier propertyName) |
56 { | 54 { |
57 return true; | 55 return true; |
58 } | 56 } |
59 | 57 |
60 bool getProperty(NPIdentifier propertyName, NPVariant* result) | 58 bool getProperty(NPIdentifier propertyName, NPVariant* result) |
61 { | 59 { |
62 static const char* message = "My name is "; | 60 static const char* message = "My name is "; |
63 char* propertyString = pluginTest()->NPN_UTF8FromIdentifier(property
Name); | 61 char* propertyString = pluginTest()->NPN_UTF8FromIdentifier(property
Name); |
64 | 62 |
65 int bufferLength = strlen(propertyString) + strlen(message) + 1; | 63 int bufferLength = strlen(propertyString) + strlen(message) + 1; |
66 char* resultBuffer = static_cast<char*>(pluginTest()->NPN_MemAlloc(b
ufferLength)); | 64 char* resultBuffer = static_cast<char*>(pluginTest()->NPN_MemAlloc(b
ufferLength)); |
67 snprintf(resultBuffer, bufferLength, "%s%s", message, propertyString
); | 65 snprintf(resultBuffer, bufferLength, "%s%s", message, propertyString
); |
68 | 66 |
69 STRINGZ_TO_NPVARIANT(resultBuffer, *result); | 67 STRINGZ_TO_NPVARIANT(resultBuffer, *result); |
70 | 68 |
71 return true; | 69 return true; |
72 } | 70 } |
73 }; | 71 }; |
74 | 72 |
75 virtual NPError NPP_GetValue(NPPVariable variable, void *value) override | 73 NPError NPP_GetValue(NPPVariable variable, void* value) override { |
76 { | |
77 if (variable != NPPVpluginScriptableNPObject) | 74 if (variable != NPPVpluginScriptableNPObject) |
78 return NPERR_GENERIC_ERROR; | 75 return NPERR_GENERIC_ERROR; |
79 | 76 |
80 *(NPObject**)value = PluginObject::create(this); | 77 *(NPObject**)value = PluginObject::create(this); |
81 | 78 |
82 return NPERR_NO_ERROR; | 79 return NPERR_NO_ERROR; |
83 } | 80 } |
84 | 81 |
85 }; | 82 }; |
86 | 83 |
87 static PluginTest::Register<PluginScriptableObjectOverridesAllProperties> plugin
ScriptableObjectOverridesAllProperties("plugin-scriptable-object-overrides-all-p
roperties"); | 84 static PluginTest::Register<PluginScriptableObjectOverridesAllProperties> plugin
ScriptableObjectOverridesAllProperties("plugin-scriptable-object-overrides-all-p
roperties"); |
OLD | NEW |