| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "wtf/CurrentTime.h" | 72 #include "wtf/CurrentTime.h" |
| 73 #include "wtf/StdLibExtras.h" | 73 #include "wtf/StdLibExtras.h" |
| 74 #include "wtf/StringExtras.h" | 74 #include "wtf/StringExtras.h" |
| 75 #include "wtf/text/CString.h" | 75 #include "wtf/text/CString.h" |
| 76 #include "wtf/text/StringBuilder.h" | 76 #include "wtf/text/StringBuilder.h" |
| 77 #include "wtf/text/TextPosition.h" | 77 #include "wtf/text/TextPosition.h" |
| 78 | 78 |
| 79 namespace blink { | 79 namespace blink { |
| 80 | 80 |
| 81 ScriptController::ScriptController(LocalFrame* frame) | 81 ScriptController::ScriptController(LocalFrame* frame) |
| 82 : m_windowProxyManager(WindowProxyManager::create(*frame)) {} | 82 : m_windowProxyManager(LocalWindowProxyManager::create(*frame)) {} |
| 83 | 83 |
| 84 DEFINE_TRACE(ScriptController) { | 84 DEFINE_TRACE(ScriptController) { |
| 85 visitor->trace(m_windowProxyManager); | 85 visitor->trace(m_windowProxyManager); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void ScriptController::clearForClose() { | 88 void ScriptController::clearForClose() { |
| 89 m_windowProxyManager->clearForClose(); | 89 m_windowProxyManager->clearForClose(); |
| 90 MainThreadDebugger::instance()->didClearContextsForFrame(frame()); | 90 MainThreadDebugger::instance()->didClearContextsForFrame(frame()); |
| 91 } | 91 } |
| 92 | 92 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 V8ScriptRunner::runCompiledScript( | 202 V8ScriptRunner::runCompiledScript( |
| 203 isolate(), compiledScript.script(isolate()), frame()->document()), | 203 isolate(), compiledScript.script(isolate()), frame()->document()), |
| 204 result, tryCatch)) | 204 result, tryCatch)) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), | 207 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), |
| 208 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", | 208 "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", |
| 209 InspectorUpdateCountersEvent::data()); | 209 InspectorUpdateCountersEvent::data()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 WindowProxy* ScriptController::windowProxy(DOMWrapperWorld& world) { | 212 LocalWindowProxy* ScriptController::windowProxy(DOMWrapperWorld& world) { |
| 213 WindowProxy* windowProxy = m_windowProxyManager->windowProxy(world); | 213 LocalWindowProxy* windowProxy = m_windowProxyManager->windowProxy(world); |
| 214 windowProxy->initializeIfNeeded(); | 214 windowProxy->initializeIfNeeded(); |
| 215 return windowProxy; | 215 return windowProxy; |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool ScriptController::shouldBypassMainWorldCSP() { | 218 bool ScriptController::shouldBypassMainWorldCSP() { |
| 219 v8::HandleScope handleScope(isolate()); | 219 v8::HandleScope handleScope(isolate()); |
| 220 v8::Local<v8::Context> context = isolate()->GetCurrentContext(); | 220 v8::Local<v8::Context> context = isolate()->GetCurrentContext(); |
| 221 if (context.IsEmpty() || !toDOMWindow(context)) | 221 if (context.IsEmpty() || !toDOMWindow(context)) |
| 222 return false; | 222 return false; |
| 223 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate()); | 223 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate()); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 void ScriptController::executeScriptInIsolatedWorld( | 435 void ScriptController::executeScriptInIsolatedWorld( |
| 436 int worldID, | 436 int worldID, |
| 437 const HeapVector<ScriptSourceCode>& sources, | 437 const HeapVector<ScriptSourceCode>& sources, |
| 438 int extensionGroup, | 438 int extensionGroup, |
| 439 Vector<v8::Local<v8::Value>>* results) { | 439 Vector<v8::Local<v8::Value>>* results) { |
| 440 ASSERT(worldID > 0); | 440 ASSERT(worldID > 0); |
| 441 | 441 |
| 442 RefPtr<DOMWrapperWorld> world = | 442 RefPtr<DOMWrapperWorld> world = |
| 443 DOMWrapperWorld::ensureIsolatedWorld(isolate(), worldID, extensionGroup); | 443 DOMWrapperWorld::ensureIsolatedWorld(isolate(), worldID, extensionGroup); |
| 444 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); | 444 LocalWindowProxy* isolatedWorldWindowProxy = windowProxy(*world); |
| 445 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState(); | 445 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState(); |
| 446 if (!scriptState->contextIsValid()) | 446 if (!scriptState->contextIsValid()) |
| 447 return; | 447 return; |
| 448 v8::Context::Scope scope(scriptState->context()); | 448 v8::Context::Scope scope(scriptState->context()); |
| 449 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()); | 449 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()); |
| 450 | 450 |
| 451 for (size_t i = 0; i < sources.size(); ++i) { | 451 for (size_t i = 0; i < sources.size(); ++i) { |
| 452 v8::Local<v8::Value> evaluationResult = | 452 v8::Local<v8::Value> evaluationResult = |
| 453 executeScriptAndReturnValue(scriptState->context(), sources[i]); | 453 executeScriptAndReturnValue(scriptState->context(), sources[i]); |
| 454 if (evaluationResult.IsEmpty()) | 454 if (evaluationResult.IsEmpty()) |
| 455 evaluationResult = | 455 evaluationResult = |
| 456 v8::Local<v8::Value>::New(isolate(), v8::Undefined(isolate())); | 456 v8::Local<v8::Value>::New(isolate(), v8::Undefined(isolate())); |
| 457 if (!v8CallBoolean(resultArray->CreateDataProperty(scriptState->context(), | 457 if (!v8CallBoolean(resultArray->CreateDataProperty(scriptState->context(), |
| 458 i, evaluationResult))) | 458 i, evaluationResult))) |
| 459 return; | 459 return; |
| 460 } | 460 } |
| 461 | 461 |
| 462 if (results) { | 462 if (results) { |
| 463 for (size_t i = 0; i < resultArray->Length(); ++i) { | 463 for (size_t i = 0; i < resultArray->Length(); ++i) { |
| 464 v8::Local<v8::Value> value; | 464 v8::Local<v8::Value> value; |
| 465 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) | 465 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) |
| 466 return; | 466 return; |
| 467 results->push_back(value); | 467 results->push_back(value); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace blink | 472 } // namespace blink |
| OLD | NEW |