Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp

Issue 10408065: Merge 117012 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/bindings/v8/V8NPObject.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Holger Hans Peter Freyther 3 * Copyright (C) 2009 Holger Hans Peter Freyther
4 * Copyright (C) 2010 Collabora Ltd. 4 * Copyright (C) 2010 Collabora Ltd.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 ID_PROPERTY_EVENT_LOGGING, 138 ID_PROPERTY_EVENT_LOGGING,
139 ID_PROPERTY_HAS_STREAM, 139 ID_PROPERTY_HAS_STREAM,
140 ID_PROPERTY_TEST_OBJECT, 140 ID_PROPERTY_TEST_OBJECT,
141 ID_PROPERTY_LOG_DESTROY, 141 ID_PROPERTY_LOG_DESTROY,
142 ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM, 142 ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM,
143 ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE, 143 ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE,
144 ID_PROPERTY_THROW_EXCEPTION_PROPERTY, 144 ID_PROPERTY_THROW_EXCEPTION_PROPERTY,
145 ID_LAST_SET_WINDOW_ARGUMENTS, 145 ID_LAST_SET_WINDOW_ARGUMENTS,
146 ID_PROPERTY_WINDOWED_PLUGIN, 146 ID_PROPERTY_WINDOWED_PLUGIN,
147 ID_PROPERTY_TEST_OBJECT_COUNT, 147 ID_PROPERTY_TEST_OBJECT_COUNT,
148 ID_PROPERTY_DELETE_IN_GET_PROPERTY,
148 NUM_PROPERTY_IDENTIFIERS 149 NUM_PROPERTY_IDENTIFIERS
149 }; 150 };
150 151
151 static NPIdentifier pluginPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS]; 152 static NPIdentifier pluginPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
152 static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = { 153 static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
153 "property", 154 "property",
154 "eventLoggingEnabled", 155 "eventLoggingEnabled",
155 "hasStream", 156 "hasStream",
156 "testObject", 157 "testObject",
157 "logDestroy", 158 "logDestroy",
158 "returnErrorFromNewStream", 159 "returnErrorFromNewStream",
159 "returnNegativeOneFromWrite", 160 "returnNegativeOneFromWrite",
160 "testThrowExceptionProperty", 161 "testThrowExceptionProperty",
161 "lastSetWindowArguments", 162 "lastSetWindowArguments",
162 "windowedPlugin", 163 "windowedPlugin",
163 "testObjectCount", 164 "testObjectCount",
165 "deletePluginInGetProperty"
164 }; 166 };
165 167
166 enum { 168 enum {
167 ID_TEST_CALLBACK_METHOD = 0, 169 ID_TEST_CALLBACK_METHOD = 0,
168 ID_TEST_CALLBACK_METHOD_RETURN, 170 ID_TEST_CALLBACK_METHOD_RETURN,
169 ID_TEST_GETURL, 171 ID_TEST_GETURL,
170 ID_TEST_DOM_ACCESS, 172 ID_TEST_DOM_ACCESS,
171 ID_TEST_GET_URL_NOTIFY, 173 ID_TEST_GET_URL_NOTIFY,
172 ID_TEST_INVOKE_DEFAULT, 174 ID_TEST_INVOKE_DEFAULT,
173 ID_DESTROY_STREAM, 175 ID_DESTROY_STREAM,
(...skipping 21 matching lines...) Expand all
195 ID_TEST_SET_BROWSER_PROPERTY, 197 ID_TEST_SET_BROWSER_PROPERTY,
196 ID_REMEMBER, 198 ID_REMEMBER,
197 ID_GET_REMEMBERED_OBJECT, 199 ID_GET_REMEMBERED_OBJECT,
198 ID_GET_AND_FORGET_REMEMBERED_OBJECT, 200 ID_GET_AND_FORGET_REMEMBERED_OBJECT,
199 ID_REF_COUNT, 201 ID_REF_COUNT,
200 ID_SET_STATUS, 202 ID_SET_STATUS,
201 ID_RESIZE_TO, 203 ID_RESIZE_TO,
202 ID_NORMALIZE, 204 ID_NORMALIZE,
203 ID_INVALIDATE_RECT, 205 ID_INVALIDATE_RECT,
204 ID_OBJECTS_ARE_SAME, 206 ID_OBJECTS_ARE_SAME,
207 ID_TEST_DELETE_WITHIN_INVOKE,
205 NUM_METHOD_IDENTIFIERS 208 NUM_METHOD_IDENTIFIERS
206 }; 209 };
207 210
208 static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS]; 211 static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
209 static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = { 212 static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
210 "testCallback", 213 "testCallback",
211 "testCallbackReturn", 214 "testCallbackReturn",
212 "getURL", 215 "getURL",
213 "testDOMAccess", 216 "testDOMAccess",
214 "getURLNotify", 217 "getURLNotify",
(...skipping 22 matching lines...) Expand all
237 "testGetBrowserProperty", 240 "testGetBrowserProperty",
238 "testSetBrowserProperty", 241 "testSetBrowserProperty",
239 "remember", 242 "remember",
240 "getRememberedObject", 243 "getRememberedObject",
241 "getAndForgetRememberedObject", 244 "getAndForgetRememberedObject",
242 "refCount", 245 "refCount",
243 "setStatus", 246 "setStatus",
244 "resizeTo", 247 "resizeTo",
245 "normalize", 248 "normalize",
246 "invalidateRect", 249 "invalidateRect",
247 "objectsAreSame" 250 "objectsAreSame",
251 "testDeleteWithinInvoke"
248 }; 252 };
249 253
250 static NPUTF8* createCStringFromNPVariant(const NPVariant* variant) 254 static NPUTF8* createCStringFromNPVariant(const NPVariant* variant)
251 { 255 {
252 size_t length = NPVARIANT_TO_STRING(*variant).UTF8Length; 256 size_t length = NPVARIANT_TO_STRING(*variant).UTF8Length;
253 NPUTF8* result = (NPUTF8*)malloc(length + 1); 257 NPUTF8* result = (NPUTF8*)malloc(length + 1);
254 memcpy(result, NPVARIANT_TO_STRING(*variant).UTF8Characters, length); 258 memcpy(result, NPVARIANT_TO_STRING(*variant).UTF8Characters, length);
255 result[length] = '\0'; 259 result[length] = '\0';
256 return result; 260 return result;
257 } 261 }
258 262
259 static void initializeIdentifiers(void) 263 static void initializeIdentifiers(void)
260 { 264 {
261 browser->getstringidentifiers(pluginPropertyIdentifierNames, NUM_PROPERTY_ID ENTIFIERS, pluginPropertyIdentifiers); 265 browser->getstringidentifiers(pluginPropertyIdentifierNames, NUM_PROPERTY_ID ENTIFIERS, pluginPropertyIdentifiers);
262 browser->getstringidentifiers(pluginMethodIdentifierNames, NUM_METHOD_IDENTI FIERS, pluginMethodIdentifiers); 266 browser->getstringidentifiers(pluginMethodIdentifierNames, NUM_METHOD_IDENTI FIERS, pluginMethodIdentifiers);
263 } 267 }
264 268
269 static bool callDeletePlugin(NPObject* obj, NPIdentifier name, NPIdentifier iden tifierToMatch)
270 {
271 if (name != identifierToMatch)
272 return false;
273
274 PluginObject* plugin = reinterpret_cast<PluginObject*>(obj);
275 NPObject* windowScriptObject;
276 browser->getvalue(plugin->npp, NPNVWindowNPObject, &windowScriptObject);
277
278 NPIdentifier callbackIdentifier = browser->getstringidentifier("deletePlugin ");
279 NPVariant browserResult;
280 if (browser->invoke(plugin->npp, windowScriptObject, callbackIdentifier, 0, 0, &browserResult))
281 browser->releasevariantvalue(&browserResult);
282 return true;
283 }
284
265 static bool pluginHasProperty(NPObject *obj, NPIdentifier name) 285 static bool pluginHasProperty(NPObject *obj, NPIdentifier name)
266 { 286 {
287 if (callDeletePlugin(obj, name, browser->getstringidentifier("deletePluginRe turnTrue")))
288 return true;
289
290 if (callDeletePlugin(obj, name, browser->getstringidentifier("deletePluginRe turnFalse")))
291 return false;
292
267 for (int i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++) 293 for (int i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++)
268 if (name == pluginPropertyIdentifiers[i]) 294 if (name == pluginPropertyIdentifiers[i])
269 return true; 295 return true;
270 return false; 296 return false;
271 } 297 }
272 298
273 static bool pluginHasMethod(NPObject *obj, NPIdentifier name) 299 static bool pluginHasMethod(NPObject *obj, NPIdentifier name)
274 { 300 {
301 if (callDeletePlugin(obj, name, browser->getstringidentifier("deletePluginIn HasMethod")))
302 return true;
303
275 for (int i = 0; i < NUM_METHOD_IDENTIFIERS; i++) 304 for (int i = 0; i < NUM_METHOD_IDENTIFIERS; i++)
276 if (name == pluginMethodIdentifiers[i]) 305 if (name == pluginMethodIdentifiers[i])
277 return true; 306 return true;
278 return false; 307 return false;
279 } 308 }
280 309
281 static bool pluginGetProperty(NPObject* obj, NPIdentifier name, NPVariant* resul t) 310 static bool pluginGetProperty(NPObject* obj, NPIdentifier name, NPVariant* resul t)
282 { 311 {
283 PluginObject* plugin = reinterpret_cast<PluginObject*>(obj); 312 PluginObject* plugin = reinterpret_cast<PluginObject*>(obj);
284 if (name == pluginPropertyIdentifiers[ID_PROPERTY_PROPERTY]) { 313 if (name == pluginPropertyIdentifiers[ID_PROPERTY_PROPERTY]) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 plugin->lastWindow.clipRect.left, plugin->lastWindow.clipRect.top, p lugin->lastWindow.clipRect.right - plugin->lastWindow.clipRect.left, plugin->las tWindow.clipRect.bottom - plugin->lastWindow.clipRect.top); 353 plugin->lastWindow.clipRect.left, plugin->lastWindow.clipRect.top, p lugin->lastWindow.clipRect.right - plugin->lastWindow.clipRect.left, plugin->las tWindow.clipRect.bottom - plugin->lastWindow.clipRect.top);
325 354
326 STRINGZ_TO_NPVARIANT(buf, *result); 355 STRINGZ_TO_NPVARIANT(buf, *result);
327 return true; 356 return true;
328 } 357 }
329 if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT_COUNT]) { 358 if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT_COUNT]) {
330 INT32_TO_NPVARIANT(getTestObjectCount(), *result); 359 INT32_TO_NPVARIANT(getTestObjectCount(), *result);
331 return true; 360 return true;
332 } 361 }
333 362
363 if (name == pluginPropertyIdentifiers[ID_PROPERTY_DELETE_IN_GET_PROPERTY]) {
364 browser->retainobject(obj);
365 callDeletePlugin(obj, name, pluginPropertyIdentifiers[ID_PROPERTY_DELETE _IN_GET_PROPERTY]);
366 NPObject* testObject = plugin->testObject;
367 browser->retainobject(testObject);
368 OBJECT_TO_NPVARIANT(testObject, *result);
369 browser->releaseobject(obj);
370 return true;
371 }
372
334 return false; 373 return false;
335 } 374 }
336 375
337 static bool pluginSetProperty(NPObject* obj, NPIdentifier name, const NPVariant* variant) 376 static bool pluginSetProperty(NPObject* obj, NPIdentifier name, const NPVariant* variant)
338 { 377 {
339 PluginObject* plugin = reinterpret_cast<PluginObject*>(obj); 378 PluginObject* plugin = reinterpret_cast<PluginObject*>(obj);
379 if (callDeletePlugin(obj, name, browser->getstringidentifier("deletePluginRe turnTrue")))
380 return true;
381
340 if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) { 382 if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
341 plugin->eventLogging = NPVARIANT_TO_BOOLEAN(*variant); 383 plugin->eventLogging = NPVARIANT_TO_BOOLEAN(*variant);
342 return true; 384 return true;
343 } 385 }
344 if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) { 386 if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
345 plugin->logDestroy = NPVARIANT_TO_BOOLEAN(*variant); 387 plugin->logDestroy = NPVARIANT_TO_BOOLEAN(*variant);
346 return true; 388 return true;
347 } 389 }
348 if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREA M]) { 390 if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREA M]) {
349 plugin->returnErrorFromNewStream = NPVARIANT_TO_BOOLEAN(*variant); 391 plugin->returnErrorFromNewStream = NPVARIANT_TO_BOOLEAN(*variant);
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 if (name == pluginMethodIdentifiers[ID_SET_STATUS]) 1158 if (name == pluginMethodIdentifiers[ID_SET_STATUS])
1117 return testSetStatus(plugin, args, argCount, result); 1159 return testSetStatus(plugin, args, argCount, result);
1118 if (name == pluginMethodIdentifiers[ID_RESIZE_TO]) 1160 if (name == pluginMethodIdentifiers[ID_RESIZE_TO])
1119 return testResizeTo(plugin, args, argCount, result); 1161 return testResizeTo(plugin, args, argCount, result);
1120 if (name == pluginMethodIdentifiers[ID_NORMALIZE]) 1162 if (name == pluginMethodIdentifiers[ID_NORMALIZE])
1121 return normalizeOverride(plugin, args, argCount, result); 1163 return normalizeOverride(plugin, args, argCount, result);
1122 if (name == pluginMethodIdentifiers[ID_INVALIDATE_RECT]) 1164 if (name == pluginMethodIdentifiers[ID_INVALIDATE_RECT])
1123 return invalidateRect(plugin, args, argCount, result); 1165 return invalidateRect(plugin, args, argCount, result);
1124 if (name == pluginMethodIdentifiers[ID_OBJECTS_ARE_SAME]) 1166 if (name == pluginMethodIdentifiers[ID_OBJECTS_ARE_SAME])
1125 return objectsAreSame(plugin, args, argCount, result); 1167 return objectsAreSame(plugin, args, argCount, result);
1126 1168 if (name == pluginMethodIdentifiers[ID_TEST_DELETE_WITHIN_INVOKE]) {
1169 NPObject* newObject = browser->createobject(plugin->npp, &pluginClass);
1170 OBJECT_TO_NPVARIANT(newObject, *result);
1171 callDeletePlugin(header, name, pluginMethodIdentifiers[ID_TEST_DELETE_WI THIN_INVOKE]);
1172 return true;
1173 }
1127 return false; 1174 return false;
1128 } 1175 }
1129 1176
1130 static void pluginInvalidate(NPObject* header) 1177 static void pluginInvalidate(NPObject* header)
1131 { 1178 {
1132 PluginObject* plugin = reinterpret_cast<PluginObject*>(header); 1179 PluginObject* plugin = reinterpret_cast<PluginObject*>(header);
1133 plugin->testObject = 0; 1180 plugin->testObject = 0;
1134 plugin->rememberedObject = 0; 1181 plugin->rememberedObject = 0;
1135 } 1182 }
1136 1183
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 DOUBLE_TO_NPVARIANT(242.242, args[4]); 1305 DOUBLE_TO_NPVARIANT(242.242, args[4]);
1259 STRINGZ_TO_NPVARIANT("Hello, World", args[5]); 1306 STRINGZ_TO_NPVARIANT("Hello, World", args[5]);
1260 OBJECT_TO_NPVARIANT(windowScriptObject, args[6]); 1307 OBJECT_TO_NPVARIANT(windowScriptObject, args[6]);
1261 1308
1262 NPVariant result; 1309 NPVariant result;
1263 if (browser->invoke(npp, windowScriptObject, testNPInvoke, args, 7, &result) ) 1310 if (browser->invoke(npp, windowScriptObject, testNPInvoke, args, 7, &result) )
1264 browser->releasevariantvalue(&result); 1311 browser->releasevariantvalue(&result);
1265 1312
1266 browser->releaseobject(windowScriptObject); 1313 browser->releaseobject(windowScriptObject);
1267 } 1314 }
OLDNEW
« no previous file with comments | « Source/WebCore/bindings/v8/V8NPObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698