| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/frame/DOMWindow.h" | 5 #include "core/frame/DOMWindow.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/WindowProxy.h" | |
| 9 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 10 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 11 #include "core/dom/SecurityContext.h" | 10 #include "core/dom/SecurityContext.h" |
| 12 #include "core/events/MessageEvent.h" | 11 #include "core/events/MessageEvent.h" |
| 13 #include "core/frame/Frame.h" | 12 #include "core/frame/Frame.h" |
| 14 #include "core/frame/FrameClient.h" | 13 #include "core/frame/FrameClient.h" |
| 15 #include "core/frame/FrameConsole.h" | 14 #include "core/frame/FrameConsole.h" |
| 16 #include "core/frame/LocalDOMWindow.h" | 15 #include "core/frame/LocalDOMWindow.h" |
| 17 #include "core/frame/Location.h" | 16 #include "core/frame/Location.h" |
| 18 #include "core/frame/Settings.h" | 17 #include "core/frame/Settings.h" |
| 19 #include "core/frame/UseCounter.h" | 18 #include "core/frame/UseCounter.h" |
| 20 #include "core/input/InputDeviceCapabilities.h" | 19 #include "core/input/InputDeviceCapabilities.h" |
| 21 #include "core/inspector/ConsoleMessage.h" | 20 #include "core/inspector/ConsoleMessage.h" |
| 22 #include "core/inspector/InspectorInstrumentation.h" | 21 #include "core/inspector/InspectorInstrumentation.h" |
| 23 #include "core/loader/MixedContentChecker.h" | 22 #include "core/loader/MixedContentChecker.h" |
| 24 #include "core/page/ChromeClient.h" | 23 #include "core/page/ChromeClient.h" |
| 25 #include "core/page/FocusController.h" | 24 #include "core/page/FocusController.h" |
| 26 #include "core/page/Page.h" | 25 #include "core/page/Page.h" |
| 27 #include "platform/weborigin/KURL.h" | 26 #include "platform/weborigin/KURL.h" |
| 28 #include "platform/weborigin/SecurityOrigin.h" | 27 #include "platform/weborigin/SecurityOrigin.h" |
| 29 #include "platform/weborigin/Suborigin.h" | 28 #include "platform/weborigin/Suborigin.h" |
| 30 | 29 |
| 31 namespace blink { | 30 namespace blink { |
| 32 | 31 |
| 33 DOMWindow::DOMWindow(Frame& frame) : m_frame(frame), m_windowIsClosing(false) {} | 32 DOMWindow::DOMWindow(Frame& frame) : m_frame(frame), m_windowIsClosing(false) {} |
| 34 | 33 |
| 35 DOMWindow::~DOMWindow() { | 34 DOMWindow::~DOMWindow() { |
| 36 // The frame must be disconnected before finalization. | 35 // The frame must be disconnected before finalization. |
| 37 DCHECK(!m_frame); | 36 DCHECK(!m_frame); |
| 38 | |
| 39 // Because the wrapper object of a DOMWindow is the global proxy object which | |
| 40 // may live much longer than the DOMWindow, we need to dissociate all wrappers | |
| 41 // for this instance. | |
| 42 DOMWrapperWorld::dissociateDOMWindowWrappersInAllWorlds(this); | |
| 43 } | 37 } |
| 44 | 38 |
| 45 v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate* isolate, | 39 v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate*, |
| 46 v8::Local<v8::Object> creationContext) { | 40 v8::Local<v8::Object> creationContext) { |
| 47 // Notice that we explicitly ignore |creationContext| because the DOMWindow | 41 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " |
| 48 // has its own creation context. | 42 "wrappers must be created at WindowProxy::createContext() and " |
| 49 | 43 "setupWindowPrototypeChain()."; |
| 50 Frame* frame = this->frame(); | 44 return v8::Local<v8::Object>(); |
| 51 CHECK(frame); | |
| 52 | |
| 53 v8::Local<v8::Object> globalProxy = | |
| 54 frame->windowProxy(DOMWrapperWorld::current(isolate)) | |
| 55 ->globalIfNotDetached(); | |
| 56 CHECK(!globalProxy.IsEmpty()); | |
| 57 | |
| 58 return globalProxy; | |
| 59 } | 45 } |
| 60 | 46 |
| 61 v8::Local<v8::Object> DOMWindow::associateWithWrapper( | 47 v8::Local<v8::Object> DOMWindow::associateWithWrapper( |
| 62 v8::Isolate*, | 48 v8::Isolate*, |
| 63 const WrapperTypeInfo*, | 49 const WrapperTypeInfo*, |
| 64 v8::Local<v8::Object> wrapper) { | 50 v8::Local<v8::Object> wrapper) { |
| 65 NOTREACHED(); | 51 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " |
| 52 "wrappers must be created at WindowProxy::createContext() and " |
| 53 "setupWindowPrototypeChain()."; |
| 66 return v8::Local<v8::Object>(); | 54 return v8::Local<v8::Object>(); |
| 67 } | 55 } |
| 68 | 56 |
| 69 const AtomicString& DOMWindow::interfaceName() const { | 57 const AtomicString& DOMWindow::interfaceName() const { |
| 70 return EventTargetNames::DOMWindow; | 58 return EventTargetNames::DOMWindow; |
| 71 } | 59 } |
| 72 | 60 |
| 73 const DOMWindow* DOMWindow::toDOMWindow() const { | 61 const DOMWindow* DOMWindow::toDOMWindow() const { |
| 74 return this; | 62 return this; |
| 75 } | 63 } |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 433 } |
| 446 | 434 |
| 447 DEFINE_TRACE(DOMWindow) { | 435 DEFINE_TRACE(DOMWindow) { |
| 448 visitor->trace(m_frame); | 436 visitor->trace(m_frame); |
| 449 visitor->trace(m_inputCapabilities); | 437 visitor->trace(m_inputCapabilities); |
| 450 visitor->trace(m_location); | 438 visitor->trace(m_location); |
| 451 EventTargetWithInlineData::trace(visitor); | 439 EventTargetWithInlineData::trace(visitor); |
| 452 } | 440 } |
| 453 | 441 |
| 454 } // namespace blink | 442 } // namespace blink |
| OLD | NEW |