| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void ScriptController::disableEval(const String& errorMessage) | 257 void ScriptController::disableEval(const String& errorMessage) |
| 258 { | 258 { |
| 259 if (!m_windowProxyManager->mainWorldProxy()->isContextInitialized()) | 259 if (!m_windowProxyManager->mainWorldProxy()->isContextInitialized()) |
| 260 return; | 260 return; |
| 261 v8::HandleScope handleScope(isolate()); | 261 v8::HandleScope handleScope(isolate()); |
| 262 v8::Local<v8::Context> v8Context = m_windowProxyManager->mainWorldProxy()->c
ontext(); | 262 v8::Local<v8::Context> v8Context = m_windowProxyManager->mainWorldProxy()->c
ontext(); |
| 263 v8Context->AllowCodeGenerationFromStrings(false); | 263 v8Context->AllowCodeGenerationFromStrings(false); |
| 264 v8Context->SetErrorMessageForCodeGenerationFromStrings(v8String(isolate(), e
rrorMessage)); | 264 v8Context->SetErrorMessageForCodeGenerationFromStrings(v8String(isolate(), e
rrorMessage)); |
| 265 } | 265 } |
| 266 | 266 |
| 267 PassRefPtr<SharedPersistent<v8::Object> > ScriptController::createPluginWrapper(
Widget* widget) | 267 PassRefPtr<SharedPersistent<v8::Object>> ScriptController::createPluginWrapper(W
idget* widget) |
| 268 { | 268 { |
| 269 ASSERT(widget); | 269 ASSERT(widget); |
| 270 | 270 |
| 271 if (!widget->isPluginView()) | 271 if (!widget->isPluginView()) |
| 272 return nullptr; | 272 return nullptr; |
| 273 | 273 |
| 274 v8::HandleScope handleScope(isolate()); | 274 v8::HandleScope handleScope(isolate()); |
| 275 v8::Local<v8::Object> scriptableObject = toPluginView(widget)->scriptableObj
ect(isolate()); | 275 v8::Local<v8::Object> scriptableObject = toPluginView(widget)->scriptableObj
ect(isolate()); |
| 276 | 276 |
| 277 if (scriptableObject.IsEmpty()) | 277 if (scriptableObject.IsEmpty()) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 m_windowProxyManager->clearForNavigation(); | 406 m_windowProxyManager->clearForNavigation(); |
| 407 blink::Platform::current()->histogramCustomCounts("WebCore.ScriptController.
clearWindowProxy", (currentTime() - start) * 1000, 0, 10000, 50); | 407 blink::Platform::current()->histogramCustomCounts("WebCore.ScriptController.
clearWindowProxy", (currentTime() - start) * 1000, 0, 10000, 50); |
| 408 } | 408 } |
| 409 | 409 |
| 410 void ScriptController::setCaptureCallStackForUncaughtExceptions(bool value) | 410 void ScriptController::setCaptureCallStackForUncaughtExceptions(bool value) |
| 411 { | 411 { |
| 412 v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::ma
xCallStackSizeToCapture, stackTraceOptions); | 412 v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::ma
xCallStackSizeToCapture, stackTraceOptions); |
| 413 } | 413 } |
| 414 | 414 |
| 415 void ScriptController::collectIsolatedContexts(Vector<std::pair<ScriptState*, Se
curityOrigin*> >& result) | 415 void ScriptController::collectIsolatedContexts(Vector<std::pair<ScriptState*, Se
curityOrigin*>>& result) |
| 416 { | 416 { |
| 417 m_windowProxyManager->collectIsolatedContexts(result); | 417 m_windowProxyManager->collectIsolatedContexts(result); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void ScriptController::updateDocument() | 420 void ScriptController::updateDocument() |
| 421 { | 421 { |
| 422 // For an uninitialized main window windowProxy, do not incur the cost of co
ntext initialization. | 422 // For an uninitialized main window windowProxy, do not incur the cost of co
ntext initialization. |
| 423 if (!m_windowProxyManager->mainWorldProxy()->isGlobalInitialized()) | 423 if (!m_windowProxyManager->mainWorldProxy()->isGlobalInitialized()) |
| 424 return; | 424 return; |
| 425 | 425 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 560 |
| 561 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte
xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); | 561 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte
xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); |
| 562 m_sourceURL = savedSourceURL; | 562 m_sourceURL = savedSourceURL; |
| 563 | 563 |
| 564 if (object.IsEmpty()) | 564 if (object.IsEmpty()) |
| 565 return v8::Local<v8::Value>(); | 565 return v8::Local<v8::Value>(); |
| 566 | 566 |
| 567 return handleScope.Escape(object); | 567 return handleScope.Escape(object); |
| 568 } | 568 } |
| 569 | 569 |
| 570 void ScriptController::executeScriptInIsolatedWorld(int worldID, const WillBeHea
pVector<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Val
ue> >* results) | 570 void ScriptController::executeScriptInIsolatedWorld(int worldID, const WillBeHea
pVector<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Val
ue>>* results) |
| 571 { | 571 { |
| 572 ASSERT(worldID > 0); | 572 ASSERT(worldID > 0); |
| 573 | 573 |
| 574 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate
(), worldID, extensionGroup); | 574 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate
(), worldID, extensionGroup); |
| 575 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); | 575 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); |
| 576 if (!isolatedWorldWindowProxy->isContextInitialized()) | 576 if (!isolatedWorldWindowProxy->isContextInitialized()) |
| 577 return; | 577 return; |
| 578 | 578 |
| 579 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState(); | 579 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState(); |
| 580 v8::Context::Scope scope(scriptState->context()); | 580 v8::Context::Scope scope(scriptState->context()); |
| 581 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size())
; | 581 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size())
; |
| 582 | 582 |
| 583 for (size_t i = 0; i < sources.size(); ++i) { | 583 for (size_t i = 0; i < sources.size(); ++i) { |
| 584 v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(scri
ptState->context(), sources[i]); | 584 v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(scri
ptState->context(), sources[i]); |
| 585 if (evaluationResult.IsEmpty()) | 585 if (evaluationResult.IsEmpty()) |
| 586 evaluationResult = v8::Local<v8::Value>::New(isolate(), v8::Undefine
d(isolate())); | 586 evaluationResult = v8::Local<v8::Value>::New(isolate(), v8::Undefine
d(isolate())); |
| 587 resultArray->Set(i, evaluationResult); | 587 resultArray->Set(i, evaluationResult); |
| 588 } | 588 } |
| 589 | 589 |
| 590 if (results) { | 590 if (results) { |
| 591 for (size_t i = 0; i < resultArray->Length(); ++i) | 591 for (size_t i = 0; i < resultArray->Length(); ++i) |
| 592 results->append(resultArray->Get(i)); | 592 results->append(resultArray->Get(i)); |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 | 595 |
| 596 } // namespace blink | 596 } // namespace blink |
| OLD | NEW |