OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 free(v8NpObject); | 70 free(v8NpObject); |
71 } | 71 } |
72 | 72 |
73 static NPClass V8NPObjectClass = { | 73 static NPClass V8NPObjectClass = { |
74 NP_CLASS_STRUCT_VERSION, | 74 NP_CLASS_STRUCT_VERSION, |
75 allocV8NPObject, | 75 allocV8NPObject, |
76 freeV8NPObject, | 76 freeV8NPObject, |
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | 77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
78 }; | 78 }; |
79 | 79 |
80 static v8::Local<v8::Context> mainWorldContext(v8::Isolate* isolate, NPP npp, NP
Object* npObject) | 80 static v8::Local<v8::Context> mainWorldContext(NPP npp, NPObject* npObject) |
81 { | 81 { |
82 ASSERT(npObject->_class == &V8NPObjectClass); | 82 ASSERT(npObject->_class == &V8NPObjectClass); |
83 V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject); | 83 V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject); |
84 DOMWindow* window = object->rootObject; | 84 DOMWindow* window = object->rootObject; |
85 if (!window || !window->isCurrentlyDisplayedInFrame()) | 85 if (!window || !window->isCurrentlyDisplayedInFrame()) |
86 return v8::Local<v8::Context>(); | 86 return v8::Local<v8::Context>(); |
87 return toV8Context(isolate, object->rootObject->frame(), DOMWrapperWorld::ma
inWorld()); | 87 return toV8Context(object->rootObject->frame(), DOMWrapperWorld::mainWorld()
); |
88 } | 88 } |
89 | 89 |
90 static PassOwnPtr<v8::Handle<v8::Value>[]> createValueListFromVariantArgs(const
NPVariant* arguments, uint32_t argumentCount, NPObject* owner, v8::Isolate* isol
ate) | 90 static PassOwnPtr<v8::Handle<v8::Value>[]> createValueListFromVariantArgs(const
NPVariant* arguments, uint32_t argumentCount, NPObject* owner, v8::Isolate* isol
ate) |
91 { | 91 { |
92 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu
e>[argumentCount]); | 92 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu
e>[argumentCount]); |
93 for (uint32_t index = 0; index < argumentCount; index++) { | 93 for (uint32_t index = 0; index < argumentCount; index++) { |
94 const NPVariant* arg = &arguments[index]; | 94 const NPVariant* arg = &arguments[index]; |
95 argv[index] = convertNPVariantToV8Object(arg, owner, isolate); | 95 argv[index] = convertNPVariantToV8Object(arg, owner, isolate); |
96 } | 96 } |
97 return argv.release(); | 97 return argv.release(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 if (!strcmp(identifier->value.string, "eval")) { | 225 if (!strcmp(identifier->value.string, "eval")) { |
226 if (argumentCount != 1) | 226 if (argumentCount != 1) |
227 return false; | 227 return false; |
228 if (arguments[0].type != NPVariantType_String) | 228 if (arguments[0].type != NPVariantType_String) |
229 return false; | 229 return false; |
230 return _NPN_Evaluate(npp, npObject, const_cast<NPString*>(&arguments[0].
value.stringValue), result); | 230 return _NPN_Evaluate(npp, npObject, const_cast<NPString*>(&arguments[0].
value.stringValue), result); |
231 } | 231 } |
232 | 232 |
233 v8::HandleScope handleScope(isolate); | 233 v8::HandleScope handleScope(isolate); |
234 // FIXME: should use the plugin's owner frame as the security context. | 234 // FIXME: should use the plugin's owner frame as the security context. |
235 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObject); | 235 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
236 if (context.IsEmpty()) | 236 if (context.IsEmpty()) |
237 return false; | 237 return false; |
238 | 238 |
239 v8::Context::Scope scope(context); | 239 v8::Context::Scope scope(context); |
240 ExceptionCatcher exceptionCatcher; | 240 ExceptionCatcher exceptionCatcher; |
241 | 241 |
242 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NpOb
ject->v8Object); | 242 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NpOb
ject->v8Object); |
243 v8::Handle<v8::Value> functionObject = v8Object->Get(v8AtomicString(isolate,
identifier->value.string)); | 243 v8::Handle<v8::Value> functionObject = v8Object->Get(v8AtomicString(isolate,
identifier->value.string)); |
244 if (functionObject.IsEmpty() || functionObject->IsNull()) { | 244 if (functionObject.IsEmpty() || functionObject->IsNull()) { |
245 NULL_TO_NPVARIANT(*result); | 245 NULL_TO_NPVARIANT(*result); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 if (npObject->_class->invokeDefault) | 280 if (npObject->_class->invokeDefault) |
281 return npObject->_class->invokeDefault(npObject, arguments, argument
Count, result); | 281 return npObject->_class->invokeDefault(npObject, arguments, argument
Count, result); |
282 | 282 |
283 VOID_TO_NPVARIANT(*result); | 283 VOID_TO_NPVARIANT(*result); |
284 return true; | 284 return true; |
285 } | 285 } |
286 | 286 |
287 VOID_TO_NPVARIANT(*result); | 287 VOID_TO_NPVARIANT(*result); |
288 | 288 |
289 v8::HandleScope handleScope(isolate); | 289 v8::HandleScope handleScope(isolate); |
290 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObject); | 290 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
291 if (context.IsEmpty()) | 291 if (context.IsEmpty()) |
292 return false; | 292 return false; |
293 | 293 |
294 v8::Context::Scope scope(context); | 294 v8::Context::Scope scope(context); |
295 ExceptionCatcher exceptionCatcher; | 295 ExceptionCatcher exceptionCatcher; |
296 | 296 |
297 // Lookup the function object and call it. | 297 // Lookup the function object and call it. |
298 v8::Local<v8::Object> functionObject = v8::Local<v8::Object>::New(isolate, v
8NpObject->v8Object); | 298 v8::Local<v8::Object> functionObject = v8::Local<v8::Object>::New(isolate, v
8NpObject->v8Object); |
299 if (!functionObject->IsFunction()) | 299 if (!functionObject->IsFunction()) |
300 return false; | 300 return false; |
(...skipping 28 matching lines...) Expand all Loading... |
329 VOID_TO_NPVARIANT(*result); | 329 VOID_TO_NPVARIANT(*result); |
330 if (!npObject) | 330 if (!npObject) |
331 return false; | 331 return false; |
332 | 332 |
333 V8NPObject* v8NpObject = npObjectToV8NPObject(npObject); | 333 V8NPObject* v8NpObject = npObjectToV8NPObject(npObject); |
334 if (!v8NpObject) | 334 if (!v8NpObject) |
335 return false; | 335 return false; |
336 | 336 |
337 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 337 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
338 v8::HandleScope handleScope(isolate); | 338 v8::HandleScope handleScope(isolate); |
339 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObject); | 339 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
340 if (context.IsEmpty()) | 340 if (context.IsEmpty()) |
341 return false; | 341 return false; |
342 | 342 |
343 v8::Context::Scope scope(context); | 343 v8::Context::Scope scope(context); |
344 ExceptionCatcher exceptionCatcher; | 344 ExceptionCatcher exceptionCatcher; |
345 | 345 |
346 // FIXME: Is this branch still needed after switching to using UserGestureIn
dicator? | 346 // FIXME: Is this branch still needed after switching to using UserGestureIn
dicator? |
347 String filename; | 347 String filename; |
348 if (!popupsAllowed) | 348 if (!popupsAllowed) |
349 filename = "npscript"; | 349 filename = "npscript"; |
(...skipping 15 matching lines...) Expand all Loading... |
365 } | 365 } |
366 | 366 |
367 bool _NPN_GetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, NP
Variant* result) | 367 bool _NPN_GetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, NP
Variant* result) |
368 { | 368 { |
369 if (!npObject) | 369 if (!npObject) |
370 return false; | 370 return false; |
371 | 371 |
372 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { | 372 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { |
373 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 373 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
374 v8::HandleScope handleScope(isolate); | 374 v8::HandleScope handleScope(isolate); |
375 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObjec
t); | 375 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
376 if (context.IsEmpty()) | 376 if (context.IsEmpty()) |
377 return false; | 377 return false; |
378 | 378 |
379 v8::Context::Scope scope(context); | 379 v8::Context::Scope scope(context); |
380 ExceptionCatcher exceptionCatcher; | 380 ExceptionCatcher exceptionCatcher; |
381 | 381 |
382 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); | 382 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); |
383 v8::Local<v8::Value> v8result = obj->Get(npIdentifierToV8Identifier(prop
ertyName, isolate)); | 383 v8::Local<v8::Value> v8result = obj->Get(npIdentifierToV8Identifier(prop
ertyName, isolate)); |
384 | 384 |
385 if (v8result.IsEmpty()) | 385 if (v8result.IsEmpty()) |
(...skipping 13 matching lines...) Expand all Loading... |
399 } | 399 } |
400 | 400 |
401 bool _NPN_SetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, co
nst NPVariant* value) | 401 bool _NPN_SetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, co
nst NPVariant* value) |
402 { | 402 { |
403 if (!npObject) | 403 if (!npObject) |
404 return false; | 404 return false; |
405 | 405 |
406 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { | 406 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { |
407 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 407 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
408 v8::HandleScope handleScope(isolate); | 408 v8::HandleScope handleScope(isolate); |
409 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObjec
t); | 409 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
410 if (context.IsEmpty()) | 410 if (context.IsEmpty()) |
411 return false; | 411 return false; |
412 | 412 |
413 v8::Context::Scope scope(context); | 413 v8::Context::Scope scope(context); |
414 ExceptionCatcher exceptionCatcher; | 414 ExceptionCatcher exceptionCatcher; |
415 | 415 |
416 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); | 416 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); |
417 obj->Set(npIdentifierToV8Identifier(propertyName, context->GetIsolate())
, convertNPVariantToV8Object(value, object->rootObject->frame()->script().window
ScriptNPObject(), context->GetIsolate())); | 417 obj->Set(npIdentifierToV8Identifier(propertyName, context->GetIsolate())
, convertNPVariantToV8Object(value, object->rootObject->frame()->script().window
ScriptNPObject(), context->GetIsolate())); |
418 return true; | 418 return true; |
419 } | 419 } |
420 | 420 |
421 if (npObject->_class->setProperty) | 421 if (npObject->_class->setProperty) |
422 return npObject->_class->setProperty(npObject, propertyName, value); | 422 return npObject->_class->setProperty(npObject, propertyName, value); |
423 | 423 |
424 return false; | 424 return false; |
425 } | 425 } |
426 | 426 |
427 bool _NPN_RemoveProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName) | 427 bool _NPN_RemoveProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName) |
428 { | 428 { |
429 if (!npObject) | 429 if (!npObject) |
430 return false; | 430 return false; |
431 | 431 |
432 V8NPObject* object = npObjectToV8NPObject(npObject); | 432 V8NPObject* object = npObjectToV8NPObject(npObject); |
433 if (!object) | 433 if (!object) |
434 return false; | 434 return false; |
435 | 435 |
436 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 436 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
437 v8::HandleScope handleScope(isolate); | 437 v8::HandleScope handleScope(isolate); |
438 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObject); | 438 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
439 if (context.IsEmpty()) | 439 if (context.IsEmpty()) |
440 return false; | 440 return false; |
441 v8::Context::Scope scope(context); | 441 v8::Context::Scope scope(context); |
442 ExceptionCatcher exceptionCatcher; | 442 ExceptionCatcher exceptionCatcher; |
443 | 443 |
444 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object->v8O
bject); | 444 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object->v8O
bject); |
445 // FIXME: Verify that setting to undefined is right. | 445 // FIXME: Verify that setting to undefined is right. |
446 obj->Set(npIdentifierToV8Identifier(propertyName, isolate), v8::Undefined(is
olate)); | 446 obj->Set(npIdentifierToV8Identifier(propertyName, isolate), v8::Undefined(is
olate)); |
447 return true; | 447 return true; |
448 } | 448 } |
449 | 449 |
450 bool _NPN_HasProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName) | 450 bool _NPN_HasProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName) |
451 { | 451 { |
452 if (!npObject) | 452 if (!npObject) |
453 return false; | 453 return false; |
454 | 454 |
455 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { | 455 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { |
456 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 456 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
457 v8::HandleScope handleScope(isolate); | 457 v8::HandleScope handleScope(isolate); |
458 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObjec
t); | 458 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
459 if (context.IsEmpty()) | 459 if (context.IsEmpty()) |
460 return false; | 460 return false; |
461 v8::Context::Scope scope(context); | 461 v8::Context::Scope scope(context); |
462 ExceptionCatcher exceptionCatcher; | 462 ExceptionCatcher exceptionCatcher; |
463 | 463 |
464 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); | 464 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); |
465 return obj->Has(npIdentifierToV8Identifier(propertyName, isolate)); | 465 return obj->Has(npIdentifierToV8Identifier(propertyName, isolate)); |
466 } | 466 } |
467 | 467 |
468 if (npObject->_class->hasProperty) | 468 if (npObject->_class->hasProperty) |
469 return npObject->_class->hasProperty(npObject, propertyName); | 469 return npObject->_class->hasProperty(npObject, propertyName); |
470 return false; | 470 return false; |
471 } | 471 } |
472 | 472 |
473 bool _NPN_HasMethod(NPP npp, NPObject* npObject, NPIdentifier methodName) | 473 bool _NPN_HasMethod(NPP npp, NPObject* npObject, NPIdentifier methodName) |
474 { | 474 { |
475 if (!npObject) | 475 if (!npObject) |
476 return false; | 476 return false; |
477 | 477 |
478 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { | 478 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { |
479 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 479 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
480 v8::HandleScope handleScope(isolate); | 480 v8::HandleScope handleScope(isolate); |
481 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObjec
t); | 481 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
482 if (context.IsEmpty()) | 482 if (context.IsEmpty()) |
483 return false; | 483 return false; |
484 v8::Context::Scope scope(context); | 484 v8::Context::Scope scope(context); |
485 ExceptionCatcher exceptionCatcher; | 485 ExceptionCatcher exceptionCatcher; |
486 | 486 |
487 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); | 487 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); |
488 v8::Handle<v8::Value> prop = obj->Get(npIdentifierToV8Identifier(methodN
ame, isolate)); | 488 v8::Handle<v8::Value> prop = obj->Get(npIdentifierToV8Identifier(methodN
ame, isolate)); |
489 return prop->IsFunction(); | 489 return prop->IsFunction(); |
490 } | 490 } |
491 | 491 |
492 if (npObject->_class->hasMethod) | 492 if (npObject->_class->hasMethod) |
493 return npObject->_class->hasMethod(npObject, methodName); | 493 return npObject->_class->hasMethod(npObject, methodName); |
494 return false; | 494 return false; |
495 } | 495 } |
496 | 496 |
497 void _NPN_SetException(NPObject* npObject, const NPUTF8 *message) | 497 void _NPN_SetException(NPObject* npObject, const NPUTF8 *message) |
498 { | 498 { |
499 if (!npObject || !npObjectToV8NPObject(npObject)) { | 499 if (!npObject || !npObjectToV8NPObject(npObject)) { |
500 // We won't be able to find a proper scope for this exception, so just t
hrow it. | 500 // We won't be able to find a proper scope for this exception, so just t
hrow it. |
501 // This is consistent with JSC, which throws a global exception all the
time. | 501 // This is consistent with JSC, which throws a global exception all the
time. |
502 throwError(v8GeneralError, message, v8::Isolate::GetCurrent()); | 502 throwError(v8GeneralError, message, v8::Isolate::GetCurrent()); |
503 return; | 503 return; |
504 } | 504 } |
505 | 505 |
506 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 506 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
507 v8::HandleScope handleScope(isolate); | 507 v8::HandleScope handleScope(isolate); |
508 v8::Handle<v8::Context> context = mainWorldContext(isolate, 0, npObject); | 508 v8::Handle<v8::Context> context = mainWorldContext(0, npObject); |
509 if (context.IsEmpty()) | 509 if (context.IsEmpty()) |
510 return; | 510 return; |
511 | 511 |
512 v8::Context::Scope scope(context); | 512 v8::Context::Scope scope(context); |
513 ExceptionCatcher exceptionCatcher; | 513 ExceptionCatcher exceptionCatcher; |
514 | 514 |
515 throwError(v8GeneralError, message, context->GetIsolate()); | 515 throwError(v8GeneralError, message, context->GetIsolate()); |
516 } | 516 } |
517 | 517 |
518 bool _NPN_Enumerate(NPP npp, NPObject* npObject, NPIdentifier** identifier, uint
32_t* count) | 518 bool _NPN_Enumerate(NPP npp, NPObject* npObject, NPIdentifier** identifier, uint
32_t* count) |
519 { | 519 { |
520 if (!npObject) | 520 if (!npObject) |
521 return false; | 521 return false; |
522 | 522 |
523 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { | 523 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { |
524 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 524 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
525 v8::HandleScope handleScope(isolate); | 525 v8::HandleScope handleScope(isolate); |
526 v8::Local<v8::Context> context = mainWorldContext(isolate, npp, npObject
); | 526 v8::Local<v8::Context> context = mainWorldContext(npp, npObject); |
527 if (context.IsEmpty()) | 527 if (context.IsEmpty()) |
528 return false; | 528 return false; |
529 v8::Context::Scope scope(context); | 529 v8::Context::Scope scope(context); |
530 ExceptionCatcher exceptionCatcher; | 530 ExceptionCatcher exceptionCatcher; |
531 | 531 |
532 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); | 532 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); |
533 | 533 |
534 // FIXME: http://b/issue?id=1210340: Use a v8::Object::Keys() method whe
n it exists, instead of evaluating javascript. | 534 // FIXME: http://b/issue?id=1210340: Use a v8::Object::Keys() method whe
n it exists, instead of evaluating javascript. |
535 | 535 |
536 // FIXME: Figure out how to cache this helper function. Run a helper fu
nction that collects the properties | 536 // FIXME: Figure out how to cache this helper function. Run a helper fu
nction that collects the properties |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 572 |
573 bool _NPN_Construct(NPP npp, NPObject* npObject, const NPVariant* arguments, uin
t32_t argumentCount, NPVariant* result) | 573 bool _NPN_Construct(NPP npp, NPObject* npObject, const NPVariant* arguments, uin
t32_t argumentCount, NPVariant* result) |
574 { | 574 { |
575 if (!npObject) | 575 if (!npObject) |
576 return false; | 576 return false; |
577 | 577 |
578 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 578 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
579 | 579 |
580 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { | 580 if (V8NPObject* object = npObjectToV8NPObject(npObject)) { |
581 v8::HandleScope handleScope(isolate); | 581 v8::HandleScope handleScope(isolate); |
582 v8::Handle<v8::Context> context = mainWorldContext(isolate, npp, npObjec
t); | 582 v8::Handle<v8::Context> context = mainWorldContext(npp, npObject); |
583 if (context.IsEmpty()) | 583 if (context.IsEmpty()) |
584 return false; | 584 return false; |
585 v8::Context::Scope scope(context); | 585 v8::Context::Scope scope(context); |
586 ExceptionCatcher exceptionCatcher; | 586 ExceptionCatcher exceptionCatcher; |
587 | 587 |
588 // Lookup the constructor function. | 588 // Lookup the constructor function. |
589 v8::Handle<v8::Object> ctorObj = v8::Local<v8::Object>::New(isolate, obj
ect->v8Object); | 589 v8::Handle<v8::Object> ctorObj = v8::Local<v8::Object>::New(isolate, obj
ect->v8Object); |
590 if (!ctorObj->IsFunction()) | 590 if (!ctorObj->IsFunction()) |
591 return false; | 591 return false; |
592 | 592 |
(...skipping 12 matching lines...) Expand all Loading... |
605 | 605 |
606 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); | 606 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); |
607 return true; | 607 return true; |
608 } | 608 } |
609 | 609 |
610 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) | 610 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->
construct) |
611 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); | 611 return npObject->_class->construct(npObject, arguments, argumentCount, r
esult); |
612 | 612 |
613 return false; | 613 return false; |
614 } | 614 } |
OLD | NEW |