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/WindowProxyManager.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 10 matching lines...) Expand all Loading... |
27 #include "core/page/ChromeClient.h" | 28 #include "core/page/ChromeClient.h" |
28 #include "core/page/FocusController.h" | 29 #include "core/page/FocusController.h" |
29 #include "core/page/Page.h" | 30 #include "core/page/Page.h" |
30 #include "platform/weborigin/KURL.h" | 31 #include "platform/weborigin/KURL.h" |
31 #include "platform/weborigin/SecurityOrigin.h" | 32 #include "platform/weborigin/SecurityOrigin.h" |
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) |
| 39 : m_frame(frame), |
| 40 m_windowProxyManager(frame.getWindowProxyManager()), |
| 41 m_windowIsClosing(false) {} |
38 | 42 |
39 DOMWindow::~DOMWindow() { | 43 DOMWindow::~DOMWindow() { |
40 // The frame must be disconnected before finalization. | 44 // The frame must be disconnected before finalization. |
41 DCHECK(!m_frame); | 45 DCHECK(!m_frame); |
42 } | 46 } |
43 | 47 |
44 v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate*, | 48 v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate*, |
45 v8::Local<v8::Object> creationContext) { | 49 v8::Local<v8::Object> creationContext) { |
46 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " | 50 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " |
47 "wrappers must be created at WindowProxy::createContext() and " | 51 "wrappers must be created at WindowProxy::createContext() and " |
(...skipping 26 matching lines...) Expand all Loading... |
74 } | 78 } |
75 | 79 |
76 bool DOMWindow::closed() const { | 80 bool DOMWindow::closed() const { |
77 return m_windowIsClosing || !frame() || !frame()->host(); | 81 return m_windowIsClosing || !frame() || !frame()->host(); |
78 } | 82 } |
79 | 83 |
80 unsigned DOMWindow::length() const { | 84 unsigned DOMWindow::length() const { |
81 return frame() ? frame()->tree().scopedChildCount() : 0; | 85 return frame() ? frame()->tree().scopedChildCount() : 0; |
82 } | 86 } |
83 | 87 |
84 v8::Local<v8::Object> DOMWindow::self(ScriptState* scriptState) const { | 88 WindowProxyManagerBase* DOMWindow::self() const { |
85 return scriptState->context()->Global(); | 89 return m_windowProxyManager.get(); |
86 } | 90 } |
87 | 91 |
88 DOMWindow* DOMWindow::opener() const { | 92 DOMWindow* DOMWindow::opener() const { |
89 // FIXME: Use FrameTree to get opener as well, to simplify logic here. | 93 // FIXME: Use FrameTree to get opener as well, to simplify logic here. |
90 if (!frame() || !frame()->client()) | 94 if (!frame() || !frame()->client()) |
91 return nullptr; | 95 return nullptr; |
92 | 96 |
93 Frame* opener = frame()->client()->opener(); | 97 Frame* opener = frame()->client()->opener(); |
94 return opener ? opener->domWindow() : nullptr; | 98 return opener ? opener->domWindow() : nullptr; |
95 } | 99 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 432 |
429 // If we're a top level window, bring the window to the front. | 433 // If we're a top level window, bring the window to the front. |
430 if (frame()->isMainFrame() && allowFocus) | 434 if (frame()->isMainFrame() && allowFocus) |
431 page->chromeClient().focus(); | 435 page->chromeClient().focus(); |
432 | 436 |
433 page->focusController().focusDocumentView(frame(), true /* notifyEmbedder */); | 437 page->focusController().focusDocumentView(frame(), true /* notifyEmbedder */); |
434 } | 438 } |
435 | 439 |
436 DEFINE_TRACE(DOMWindow) { | 440 DEFINE_TRACE(DOMWindow) { |
437 visitor->trace(m_frame); | 441 visitor->trace(m_frame); |
| 442 visitor->trace(m_windowProxyManager); |
438 visitor->trace(m_location); | 443 visitor->trace(m_location); |
439 EventTargetWithInlineData::trace(visitor); | 444 EventTargetWithInlineData::trace(visitor); |
440 } | 445 } |
441 | 446 |
442 } // namespace blink | 447 } // namespace blink |
OLD | NEW |