Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: third_party/WebKit/Source/core/frame/DOMWindow.cpp

Issue 2617733004: binding: Changes the association among global-proxy/global/window-instance. (Closed)
Patch Set: Addressed review comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "core/dom/Document.h" 9 #include "core/dom/Document.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/Frame.h" 13 #include "core/frame/Frame.h"
13 #include "core/frame/FrameClient.h" 14 #include "core/frame/FrameClient.h"
14 #include "core/frame/FrameConsole.h" 15 #include "core/frame/FrameConsole.h"
15 #include "core/frame/LocalDOMWindow.h" 16 #include "core/frame/LocalDOMWindow.h"
16 #include "core/frame/Location.h" 17 #include "core/frame/Location.h"
17 #include "core/frame/Settings.h" 18 #include "core/frame/Settings.h"
18 #include "core/frame/UseCounter.h" 19 #include "core/frame/UseCounter.h"
19 #include "core/input/InputDeviceCapabilities.h" 20 #include "core/input/InputDeviceCapabilities.h"
20 #include "core/inspector/ConsoleMessage.h" 21 #include "core/inspector/ConsoleMessage.h"
21 #include "core/inspector/InspectorInstrumentation.h" 22 #include "core/inspector/InspectorInstrumentation.h"
22 #include "core/loader/MixedContentChecker.h" 23 #include "core/loader/MixedContentChecker.h"
23 #include "core/page/ChromeClient.h" 24 #include "core/page/ChromeClient.h"
24 #include "core/page/FocusController.h" 25 #include "core/page/FocusController.h"
25 #include "core/page/Page.h" 26 #include "core/page/Page.h"
26 #include "platform/weborigin/KURL.h" 27 #include "platform/weborigin/KURL.h"
27 #include "platform/weborigin/SecurityOrigin.h" 28 #include "platform/weborigin/SecurityOrigin.h"
28 #include "platform/weborigin/Suborigin.h" 29 #include "platform/weborigin/Suborigin.h"
29 30
30 namespace blink { 31 namespace blink {
31 32
32 DOMWindow::DOMWindow(Frame& frame) : m_frame(frame), m_windowIsClosing(false) {} 33 DOMWindow::DOMWindow(Frame& frame) : m_frame(frame), m_windowIsClosing(false) {}
33 34
34 DOMWindow::~DOMWindow() { 35 DOMWindow::~DOMWindow() {
35 // The frame must be disconnected before finalization. 36 // The frame must be disconnected before finalization.
36 DCHECK(!m_frame); 37 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);
37 } 43 }
38 44
39 v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate*, 45 v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate* isolate,
40 v8::Local<v8::Object> creationContext) { 46 v8::Local<v8::Object> creationContext) {
41 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " 47 // Notice that we explicitly ignore |creationContext| because the DOMWindow
42 "wrappers must be created at WindowProxy::createContext() and " 48 // has its own creation context.
43 "setupWindowPrototypeChain()."; 49
44 return v8::Local<v8::Object>(); 50 Frame* frame = this->frame();
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;
45 } 59 }
46 60
47 v8::Local<v8::Object> DOMWindow::associateWithWrapper( 61 v8::Local<v8::Object> DOMWindow::associateWithWrapper(
48 v8::Isolate*, 62 v8::Isolate*,
49 const WrapperTypeInfo*, 63 const WrapperTypeInfo*,
50 v8::Local<v8::Object> wrapper) { 64 v8::Local<v8::Object> wrapper) {
51 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " 65 NOTREACHED();
52 "wrappers must be created at WindowProxy::createContext() and "
53 "setupWindowPrototypeChain().";
54 return v8::Local<v8::Object>(); 66 return v8::Local<v8::Object>();
55 } 67 }
56 68
57 const AtomicString& DOMWindow::interfaceName() const { 69 const AtomicString& DOMWindow::interfaceName() const {
58 return EventTargetNames::DOMWindow; 70 return EventTargetNames::DOMWindow;
59 } 71 }
60 72
61 const DOMWindow* DOMWindow::toDOMWindow() const { 73 const DOMWindow* DOMWindow::toDOMWindow() const {
62 return this; 74 return this;
63 } 75 }
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 445 }
434 446
435 DEFINE_TRACE(DOMWindow) { 447 DEFINE_TRACE(DOMWindow) {
436 visitor->trace(m_frame); 448 visitor->trace(m_frame);
437 visitor->trace(m_inputCapabilities); 449 visitor->trace(m_inputCapabilities);
438 visitor->trace(m_location); 450 visitor->trace(m_location);
439 EventTargetWithInlineData::trace(visitor); 451 EventTargetWithInlineData::trace(visitor);
440 } 452 }
441 453
442 } // namespace blink 454 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.idl ('k') | third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698