Chromium Code Reviews| 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 "bindings/core/v8/WindowProxy.h" | |
| 7 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 8 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 9 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/dom/SecurityContext.h" | 11 #include "core/dom/SecurityContext.h" |
| 11 #include "core/events/MessageEvent.h" | 12 #include "core/events/MessageEvent.h" |
| 12 #include "core/frame/External.h" | 13 #include "core/frame/External.h" |
| 13 #include "core/frame/Frame.h" | 14 #include "core/frame/Frame.h" |
| 14 #include "core/frame/FrameClient.h" | 15 #include "core/frame/FrameClient.h" |
| 15 #include "core/frame/FrameConsole.h" | 16 #include "core/frame/FrameConsole.h" |
| 16 #include "core/frame/LocalDOMWindow.h" | 17 #include "core/frame/LocalDOMWindow.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 32 #include "platform/weborigin/Suborigin.h" | 33 #include "platform/weborigin/Suborigin.h" |
| 33 #include <memory> | 34 #include <memory> |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 DOMWindow::DOMWindow(Frame& frame) : m_frame(frame), m_windowIsClosing(false) {} | 38 DOMWindow::DOMWindow(Frame& frame) : m_frame(frame), m_windowIsClosing(false) {} |
| 38 | 39 |
| 39 DOMWindow::~DOMWindow() { | 40 DOMWindow::~DOMWindow() { |
| 40 // The frame must be disconnected before finalization. | 41 // The frame must be disconnected before finalization. |
| 41 DCHECK(!m_frame); | 42 DCHECK(!m_frame); |
| 43 | |
| 44 // Because the wrapper object of a DOMWindow is the global proxy object which | |
| 45 // may live much longer than the DOMWindow, we need to dissociate all wrappers | |
| 46 // for this instance. | |
| 47 DOMWrapperWorld::dissociateWrappersInAllWorlds(this); | |
| 42 } | 48 } |
| 43 | 49 |
| 44 v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate*, | 50 v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate* isolate, |
| 45 v8::Local<v8::Object> creationContext) { | 51 v8::Local<v8::Object> creationContext) { |
| 46 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " | 52 // Notice that we explicitly ignore |creationContext| because the DOMWindow |
| 47 "wrappers must be created at WindowProxy::createContext() and " | 53 // has its own creation context. |
| 48 "setupWindowPrototypeChain()."; | 54 |
| 49 return v8::Local<v8::Object>(); | 55 Frame* frame = this->frame(); |
| 56 CHECK(frame); | |
|
haraken
2017/02/09 12:46:40
Would you help me understand why frame is guarante
Yuki
2017/02/10 07:47:21
If WindowProxy::initialize() was already called, t
| |
| 57 | |
| 58 v8::Local<v8::Object> globalProxy = | |
| 59 frame->windowProxy(DOMWrapperWorld::current(isolate)) | |
| 60 ->globalIfNotDetached(); | |
| 61 CHECK(!globalProxy.IsEmpty()); | |
| 62 | |
| 63 return globalProxy; | |
| 50 } | 64 } |
| 51 | 65 |
| 52 v8::Local<v8::Object> DOMWindow::associateWithWrapper( | 66 v8::Local<v8::Object> DOMWindow::associateWithWrapper( |
| 53 v8::Isolate*, | 67 v8::Isolate*, |
| 54 const WrapperTypeInfo*, | 68 const WrapperTypeInfo*, |
| 55 v8::Local<v8::Object> wrapper) { | 69 v8::Local<v8::Object> wrapper) { |
| 56 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " | 70 NOTREACHED(); |
| 57 "wrappers must be created at WindowProxy::createContext() and " | |
| 58 "setupWindowPrototypeChain()."; | |
| 59 return v8::Local<v8::Object>(); | 71 return v8::Local<v8::Object>(); |
| 60 } | 72 } |
| 61 | 73 |
| 62 const AtomicString& DOMWindow::interfaceName() const { | 74 const AtomicString& DOMWindow::interfaceName() const { |
| 63 return EventTargetNames::DOMWindow; | 75 return EventTargetNames::DOMWindow; |
| 64 } | 76 } |
| 65 | 77 |
| 66 const DOMWindow* DOMWindow::toDOMWindow() const { | 78 const DOMWindow* DOMWindow::toDOMWindow() const { |
| 67 return this; | 79 return this; |
| 68 } | 80 } |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 page->focusController().focusDocumentView(frame(), true /* notifyEmbedder */); | 455 page->focusController().focusDocumentView(frame(), true /* notifyEmbedder */); |
| 444 } | 456 } |
| 445 | 457 |
| 446 DEFINE_TRACE(DOMWindow) { | 458 DEFINE_TRACE(DOMWindow) { |
| 447 visitor->trace(m_frame); | 459 visitor->trace(m_frame); |
| 448 visitor->trace(m_location); | 460 visitor->trace(m_location); |
| 449 EventTargetWithInlineData::trace(visitor); | 461 EventTargetWithInlineData::trace(visitor); |
| 450 } | 462 } |
| 451 | 463 |
| 452 } // namespace blink | 464 } // namespace blink |
| OLD | NEW |