| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
| 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 are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 _NPN_UnregisterObject(it->value); | 119 _NPN_UnregisterObject(it->value); |
| 120 _NPN_ReleaseObject(it->value); | 120 _NPN_ReleaseObject(it->value); |
| 121 } | 121 } |
| 122 m_pluginObjects.clear(); | 122 m_pluginObjects.clear(); |
| 123 | 123 |
| 124 if (m_windowScriptNPObject) { | 124 if (m_windowScriptNPObject) { |
| 125 // Dispose of the underlying V8 object before releasing our reference | 125 // Dispose of the underlying V8 object before releasing our reference |
| 126 // to it, so that if a plugin fails to release it properly we will | 126 // to it, so that if a plugin fails to release it properly we will |
| 127 // only leak the NPObject wrapper, not the object, its document, or | 127 // only leak the NPObject wrapper, not the object, its document, or |
| 128 // anything else they reference. | 128 // anything else they reference. |
| 129 disposeUnderlyingV8Object(m_windowScriptNPObject, m_isolate); | 129 disposeUnderlyingV8Object(m_isolate, m_windowScriptNPObject); |
| 130 _NPN_ReleaseObject(m_windowScriptNPObject); | 130 _NPN_ReleaseObject(m_windowScriptNPObject); |
| 131 m_windowScriptNPObject = 0; | 131 m_windowScriptNPObject = 0; |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ScriptController::clearForClose() | 135 void ScriptController::clearForClose() |
| 136 { | 136 { |
| 137 double start = currentTime(); | 137 double start = currentTime(); |
| 138 m_windowProxy->clearForClose(); | 138 m_windowProxy->clearForClose(); |
| 139 for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); iter != m_i
solatedWorlds.end(); ++iter) | 139 for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); iter != m_i
solatedWorlds.end(); ++iter) |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) | 379 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) |
| 380 { | 380 { |
| 381 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 381 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 382 if (!scriptState->contextIsValid()) | 382 if (!scriptState->contextIsValid()) |
| 383 return createNoScriptObject(); | 383 return createNoScriptObject(); |
| 384 | 384 |
| 385 ScriptState::Scope scope(scriptState); | 385 ScriptState::Scope scope(scriptState); |
| 386 LocalDOMWindow* window = frame->domWindow(); | 386 LocalDOMWindow* window = frame->domWindow(); |
| 387 v8::Handle<v8::Value> global = toV8(window, scriptState->context()->Global()
, scriptState->isolate()); | 387 v8::Handle<v8::Value> global = toV8(window, scriptState->context()->Global()
, scriptState->isolate()); |
| 388 ASSERT(global->IsObject()); | 388 ASSERT(global->IsObject()); |
| 389 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), windo
w, isolate); | 389 return npCreateV8ScriptObject(isolate, 0, v8::Handle<v8::Object>::Cast(globa
l), window); |
| 390 } | 390 } |
| 391 | 391 |
| 392 NPObject* ScriptController::windowScriptNPObject() | 392 NPObject* ScriptController::windowScriptNPObject() |
| 393 { | 393 { |
| 394 if (m_windowScriptNPObject) | 394 if (m_windowScriptNPObject) |
| 395 return m_windowScriptNPObject; | 395 return m_windowScriptNPObject; |
| 396 | 396 |
| 397 if (canExecuteScripts(NotAboutToExecuteScript)) { | 397 if (canExecuteScripts(NotAboutToExecuteScript)) { |
| 398 // JavaScript is enabled, so there is a JavaScript window object. | 398 // JavaScript is enabled, so there is a JavaScript window object. |
| 399 // Return an NPObject bound to the window object. | 399 // Return an NPObject bound to the window object. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 417 ScriptState* scriptState = ScriptState::forMainWorld(m_frame); | 417 ScriptState* scriptState = ScriptState::forMainWorld(m_frame); |
| 418 if (!scriptState->contextIsValid()) | 418 if (!scriptState->contextIsValid()) |
| 419 return createNoScriptObject(); | 419 return createNoScriptObject(); |
| 420 | 420 |
| 421 ScriptState::Scope scope(scriptState); | 421 ScriptState::Scope scope(scriptState); |
| 422 LocalDOMWindow* window = m_frame->domWindow(); | 422 LocalDOMWindow* window = m_frame->domWindow(); |
| 423 v8::Handle<v8::Value> v8plugin = toV8(plugin, scriptState->context()->Global
(), scriptState->isolate()); | 423 v8::Handle<v8::Value> v8plugin = toV8(plugin, scriptState->context()->Global
(), scriptState->isolate()); |
| 424 if (!v8plugin->IsObject()) | 424 if (!v8plugin->IsObject()) |
| 425 return createNoScriptObject(); | 425 return createNoScriptObject(); |
| 426 | 426 |
| 427 return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), win
dow, scriptState->isolate()); | 427 return npCreateV8ScriptObject(scriptState->isolate(), 0, v8::Handle<v8::Obje
ct>::Cast(v8plugin), window); |
| 428 } | 428 } |
| 429 | 429 |
| 430 void ScriptController::clearWindowProxy() | 430 void ScriptController::clearWindowProxy() |
| 431 { | 431 { |
| 432 double start = currentTime(); | 432 double start = currentTime(); |
| 433 // V8 binding expects ScriptController::clearWindowProxy only be called | 433 // V8 binding expects ScriptController::clearWindowProxy only be called |
| 434 // when a frame is loading a new page. This creates a new context for the ne
w page. | 434 // when a frame is loading a new page. This creates a new context for the ne
w page. |
| 435 | 435 |
| 436 // The V8 context must be available for |clearScriptObjects()|. | 436 // The V8 context must be available for |clearScriptObjects()|. |
| 437 // The below call must be before |clearForNavigation()| which disposes the V
8 context. | 437 // The below call must be before |clearForNavigation()| which disposes the V
8 context. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 resultArray->Set(i, evaluationResult); | 644 resultArray->Set(i, evaluationResult); |
| 645 } | 645 } |
| 646 | 646 |
| 647 if (results) { | 647 if (results) { |
| 648 for (size_t i = 0; i < resultArray->Length(); ++i) | 648 for (size_t i = 0; i < resultArray->Length(); ++i) |
| 649 results->append(handleScope.Escape(resultArray->Get(i))); | 649 results->append(handleScope.Escape(resultArray->Get(i))); |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 | 652 |
| 653 } // namespace blink | 653 } // namespace blink |
| OLD | NEW |