| 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 * | 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 are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 shell = iter->value.get(); | 264 shell = iter->value.get(); |
| 265 else { | 265 else { |
| 266 OwnPtr<V8WindowShell> isolatedWorldShell = V8WindowShell::create(m_f
rame, world, m_isolate); | 266 OwnPtr<V8WindowShell> isolatedWorldShell = V8WindowShell::create(m_f
rame, world, m_isolate); |
| 267 shell = isolatedWorldShell.get(); | 267 shell = isolatedWorldShell.get(); |
| 268 m_isolatedWorlds.set(world->worldId(), isolatedWorldShell.release())
; | 268 m_isolatedWorlds.set(world->worldId(), isolatedWorldShell.release())
; |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 if (!shell->isContextInitialized() && shell->initializeIfNeeded()) { | 271 if (!shell->isContextInitialized() && shell->initializeIfNeeded()) { |
| 272 if (world->isMainWorld()) { | 272 if (world->isMainWorld()) { |
| 273 // FIXME: Remove this if clause. See comment with existingWindowShel
lWorkaroundWorld(). | 273 // FIXME: Remove this if clause. See comment with existingWindowShel
lWorkaroundWorld(). |
| 274 m_frame->loader()->dispatchDidClearWindowObjectInWorld(existingWindo
wShellWorkaroundWorld()); | 274 m_frame->loader().dispatchDidClearWindowObjectInWorld(existingWindow
ShellWorkaroundWorld()); |
| 275 } else | 275 } else { |
| 276 m_frame->loader()->dispatchDidClearWindowObjectInWorld(world); | 276 m_frame->loader().dispatchDidClearWindowObjectInWorld(world); |
| 277 } |
| 277 } | 278 } |
| 278 return shell; | 279 return shell; |
| 279 } | 280 } |
| 280 | 281 |
| 281 bool ScriptController::shouldBypassMainWorldContentSecurityPolicy() | 282 bool ScriptController::shouldBypassMainWorldContentSecurityPolicy() |
| 282 { | 283 { |
| 283 if (DOMWrapperWorld* world = isolatedWorldForEnteredContext()) | 284 if (DOMWrapperWorld* world = isolatedWorldForEnteredContext()) |
| 284 return world->isolatedWorldHasContentSecurityPolicy(); | 285 return world->isolatedWorldHasContentSecurityPolicy(); |
| 285 return false; | 286 return false; |
| 286 } | 287 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 539 } |
| 539 | 540 |
| 540 int ScriptController::contextDebugId(v8::Handle<v8::Context> context) | 541 int ScriptController::contextDebugId(v8::Handle<v8::Context> context) |
| 541 { | 542 { |
| 542 return V8PerContextDebugData::contextDebugId(context); | 543 return V8PerContextDebugData::contextDebugId(context); |
| 543 } | 544 } |
| 544 | 545 |
| 545 void ScriptController::updateDocument() | 546 void ScriptController::updateDocument() |
| 546 { | 547 { |
| 547 // For an uninitialized main window shell, do not incur the cost of context
initialization during FrameLoader::init(). | 548 // For an uninitialized main window shell, do not incur the cost of context
initialization during FrameLoader::init(). |
| 548 if ((!m_windowShell->isContextInitialized() || !m_windowShell->isGlobalIniti
alized()) && m_frame->loader()->stateMachine()->creatingInitialEmptyDocument()) | 549 if ((!m_windowShell->isContextInitialized() || !m_windowShell->isGlobalIniti
alized()) && m_frame->loader().stateMachine()->creatingInitialEmptyDocument()) |
| 549 return; | 550 return; |
| 550 | 551 |
| 551 if (!initializeMainWorld()) | 552 if (!initializeMainWorld()) |
| 552 windowShell(mainThreadNormalWorld())->updateDocument(); | 553 windowShell(mainThreadNormalWorld())->updateDocument(); |
| 553 } | 554 } |
| 554 | 555 |
| 555 void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& nam
e) | 556 void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& nam
e) |
| 556 { | 557 { |
| 557 windowShell(mainThreadNormalWorld())->namedItemAdded(doc, name); | 558 windowShell(mainThreadNormalWorld())->namedItemAdded(doc, name); |
| 558 } | 559 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 570 m_frame->document()->addConsoleMessage(SecurityMessageSource, ErrorM
essageLevel, "Blocked script execution in '" + m_frame->document()->url().elided
String() + "' because the document's frame is sandboxed and the 'allow-scripts'
permission is not set."); | 571 m_frame->document()->addConsoleMessage(SecurityMessageSource, ErrorM
essageLevel, "Blocked script execution in '" + m_frame->document()->url().elided
String() + "' because the document's frame is sandboxed and the 'allow-scripts'
permission is not set."); |
| 571 return false; | 572 return false; |
| 572 } | 573 } |
| 573 | 574 |
| 574 if (m_frame->document() && m_frame->document()->isViewSource()) { | 575 if (m_frame->document() && m_frame->document()->isViewSource()) { |
| 575 ASSERT(m_frame->document()->securityOrigin()->isUnique()); | 576 ASSERT(m_frame->document()->securityOrigin()->isUnique()); |
| 576 return true; | 577 return true; |
| 577 } | 578 } |
| 578 | 579 |
| 579 Settings* settings = m_frame->settings(); | 580 Settings* settings = m_frame->settings(); |
| 580 const bool allowed = m_frame->loader()->client()->allowScript(settings && se
ttings->isScriptEnabled()); | 581 const bool allowed = m_frame->loader().client()->allowScript(settings && set
tings->isScriptEnabled()); |
| 581 if (!allowed && reason == AboutToExecuteScript) | 582 if (!allowed && reason == AboutToExecuteScript) |
| 582 m_frame->loader()->client()->didNotAllowScript(); | 583 m_frame->loader().client()->didNotAllowScript(); |
| 583 return allowed; | 584 return allowed; |
| 584 } | 585 } |
| 585 | 586 |
| 586 bool ScriptController::executeScriptIfJavaScriptURL(const KURL& url) | 587 bool ScriptController::executeScriptIfJavaScriptURL(const KURL& url) |
| 587 { | 588 { |
| 588 if (!protocolIsJavaScript(url)) | 589 if (!protocolIsJavaScript(url)) |
| 589 return false; | 590 return false; |
| 590 | 591 |
| 591 if (!m_frame->page() | 592 if (!m_frame->page() |
| 592 || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_
frame->document()->url(), eventHandlerPosition().m_line)) | 593 || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_
frame->document()->url(), eventHandlerPosition().m_line)) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 String sourceURL = sourceCode.url(); | 650 String sourceURL = sourceCode.url(); |
| 650 const String* savedSourceURL = m_sourceURL; | 651 const String* savedSourceURL = m_sourceURL; |
| 651 m_sourceURL = &sourceURL; | 652 m_sourceURL = &sourceURL; |
| 652 | 653 |
| 653 v8::HandleScope handleScope(m_isolate); | 654 v8::HandleScope handleScope(m_isolate); |
| 654 v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(m_fra
me); | 655 v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(m_fra
me); |
| 655 if (v8Context.IsEmpty()) | 656 if (v8Context.IsEmpty()) |
| 656 return ScriptValue(); | 657 return ScriptValue(); |
| 657 | 658 |
| 658 RefPtr<Frame> protect(m_frame); | 659 RefPtr<Frame> protect(m_frame); |
| 659 if (m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument()) | 660 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
| 660 m_frame->loader()->didAccessInitialDocument(); | 661 m_frame->loader().didAccessInitialDocument(); |
| 661 | 662 |
| 662 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio
n::preprocess(m_frame, sourceCode); | 663 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio
n::preprocess(m_frame, sourceCode); |
| 663 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma
ybeProcessedSourceCode : sourceCode; | 664 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma
ybeProcessedSourceCode : sourceCode; |
| 664 | 665 |
| 665 v8::Local<v8::Value> object = executeScriptAndReturnValue(v8Context, sourceC
odeToCompile, corsStatus); | 666 v8::Local<v8::Value> object = executeScriptAndReturnValue(v8Context, sourceC
odeToCompile, corsStatus); |
| 666 m_sourceURL = savedSourceURL; | 667 m_sourceURL = savedSourceURL; |
| 667 | 668 |
| 668 if (object.IsEmpty()) | 669 if (object.IsEmpty()) |
| 669 return ScriptValue(); | 670 return ScriptValue(); |
| 670 | 671 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 699 v8Results = evaluateHandleScope.Close(resultArray); | 700 v8Results = evaluateHandleScope.Close(resultArray); |
| 700 } | 701 } |
| 701 | 702 |
| 702 if (results && !v8Results.IsEmpty()) { | 703 if (results && !v8Results.IsEmpty()) { |
| 703 for (size_t i = 0; i < v8Results->Length(); ++i) | 704 for (size_t i = 0; i < v8Results->Length(); ++i) |
| 704 results->append(ScriptValue(v8Results->Get(i), m_isolate)); | 705 results->append(ScriptValue(v8Results->Get(i), m_isolate)); |
| 705 } | 706 } |
| 706 } | 707 } |
| 707 | 708 |
| 708 } // namespace WebCore | 709 } // namespace WebCore |
| OLD | NEW |