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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 VOID_TO_NPVARIANT(*result); | 250 VOID_TO_NPVARIANT(*result); |
251 return false; | 251 return false; |
252 } | 252 } |
253 | 253 |
254 Frame* frame = v8NpObject->rootObject->frame(); | 254 Frame* frame = v8NpObject->rootObject->frame(); |
255 ASSERT(frame); | 255 ASSERT(frame); |
256 | 256 |
257 // Call the function object. | 257 // Call the function object. |
258 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(functionO
bject); | 258 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(functionO
bject); |
259 OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(argume
nts, argumentCount, npObject, isolate); | 259 OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(argume
nts, argumentCount, npObject, isolate); |
260 v8::Local<v8::Value> resultObject = frame->script()->callFunction(function,
v8Object, argumentCount, argv.get()); | 260 v8::Local<v8::Value> resultObject = frame->script().callFunction(function, v
8Object, argumentCount, argv.get()); |
261 | 261 |
262 // If we had an error, return false. The spec is a little unclear here, but
says "Returns true if the method was | 262 // If we had an error, return false. The spec is a little unclear here, but
says "Returns true if the method was |
263 // successfully invoked". If we get an error return value, was that success
fully invoked? | 263 // successfully invoked". If we get an error return value, was that success
fully invoked? |
264 if (resultObject.IsEmpty()) | 264 if (resultObject.IsEmpty()) |
265 return false; | 265 return false; |
266 | 266 |
267 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); | 267 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); |
268 return true; | 268 return true; |
269 } | 269 } |
270 | 270 |
(...skipping 29 matching lines...) Expand all Loading... |
300 if (!functionObject->IsFunction()) | 300 if (!functionObject->IsFunction()) |
301 return false; | 301 return false; |
302 | 302 |
303 v8::Local<v8::Value> resultObject; | 303 v8::Local<v8::Value> resultObject; |
304 v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(functionOb
ject); | 304 v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(functionOb
ject); |
305 if (!function->IsNull()) { | 305 if (!function->IsNull()) { |
306 Frame* frame = v8NpObject->rootObject->frame(); | 306 Frame* frame = v8NpObject->rootObject->frame(); |
307 ASSERT(frame); | 307 ASSERT(frame); |
308 | 308 |
309 OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(ar
guments, argumentCount, npObject, isolate); | 309 OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(ar
guments, argumentCount, npObject, isolate); |
310 resultObject = frame->script()->callFunction(function, functionObject, a
rgumentCount, argv.get()); | 310 resultObject = frame->script().callFunction(function, functionObject, ar
gumentCount, argv.get()); |
311 } | 311 } |
312 // If we had an error, return false. The spec is a little unclear here, but
says "Returns true if the method was | 312 // If we had an error, return false. The spec is a little unclear here, but
says "Returns true if the method was |
313 // successfully invoked". If we get an error return value, was that success
fully invoked? | 313 // successfully invoked". If we get an error return value, was that success
fully invoked? |
314 if (resultObject.IsEmpty()) | 314 if (resultObject.IsEmpty()) |
315 return false; | 315 return false; |
316 | 316 |
317 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); | 317 convertV8ObjectToNPVariant(resultObject, npObject, result, isolate); |
318 return true; | 318 return true; |
319 } | 319 } |
320 | 320 |
(...skipping 27 matching lines...) Expand all Loading... |
348 String filename; | 348 String filename; |
349 if (!popupsAllowed) | 349 if (!popupsAllowed) |
350 filename = "npscript"; | 350 filename = "npscript"; |
351 | 351 |
352 Frame* frame = v8NpObject->rootObject->frame(); | 352 Frame* frame = v8NpObject->rootObject->frame(); |
353 ASSERT(frame); | 353 ASSERT(frame); |
354 | 354 |
355 String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Len
gth); | 355 String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Len
gth); |
356 | 356 |
357 UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNe
wUserGesture : PossiblyProcessingUserGesture); | 357 UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNe
wUserGesture : PossiblyProcessingUserGesture); |
358 v8::Local<v8::Value> v8result = frame->script()->executeScriptAndReturnValue
(context, ScriptSourceCode(script, KURL(ParsedURLString, filename))); | 358 v8::Local<v8::Value> v8result = frame->script().executeScriptAndReturnValue(
context, ScriptSourceCode(script, KURL(ParsedURLString, filename))); |
359 | 359 |
360 if (v8result.IsEmpty()) | 360 if (v8result.IsEmpty()) |
361 return false; | 361 return false; |
362 | 362 |
363 if (_NPN_IsAlive(npObject)) | 363 if (_NPN_IsAlive(npObject)) |
364 convertV8ObjectToNPVariant(v8result, npObject, result, isolate); | 364 convertV8ObjectToNPVariant(v8result, npObject, result, isolate); |
365 return true; | 365 return true; |
366 } | 366 } |
367 | 367 |
368 bool _NPN_GetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, NP
Variant* result) | 368 bool _NPN_GetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, NP
Variant* result) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 408 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
409 v8::HandleScope handleScope(isolate); | 409 v8::HandleScope handleScope(isolate); |
410 v8::Handle<v8::Context> context = toV8Context(npp, npObject); | 410 v8::Handle<v8::Context> context = toV8Context(npp, npObject); |
411 if (context.IsEmpty()) | 411 if (context.IsEmpty()) |
412 return false; | 412 return false; |
413 | 413 |
414 v8::Context::Scope scope(context); | 414 v8::Context::Scope scope(context); |
415 ExceptionCatcher exceptionCatcher; | 415 ExceptionCatcher exceptionCatcher; |
416 | 416 |
417 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); | 417 v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object-
>v8Object); |
418 obj->Set(npIdentifierToV8Identifier(propertyName), convertNPVariantToV8O
bject(value, object->rootObject->frame()->script()->windowScriptNPObject(), cont
ext->GetIsolate())); | 418 obj->Set(npIdentifierToV8Identifier(propertyName), convertNPVariantToV8O
bject(value, object->rootObject->frame()->script().windowScriptNPObject(), conte
xt->GetIsolate())); |
419 return true; | 419 return true; |
420 } | 420 } |
421 | 421 |
422 if (npObject->_class->setProperty) | 422 if (npObject->_class->setProperty) |
423 return npObject->_class->setProperty(npObject, propertyName, value); | 423 return npObject->_class->setProperty(npObject, propertyName, value); |
424 | 424 |
425 return false; | 425 return false; |
426 } | 426 } |
427 | 427 |
428 bool _NPN_RemoveProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName) | 428 bool _NPN_RemoveProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName) |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |