| 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 |
| 9 #include "bindings/core/v8/WindowProxyManager.h" |
| 8 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| 9 #include "core/dom/ExecutionContext.h" | 11 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/dom/SecurityContext.h" | 12 #include "core/dom/SecurityContext.h" |
| 11 #include "core/events/MessageEvent.h" | 13 #include "core/events/MessageEvent.h" |
| 12 #include "core/frame/Frame.h" | 14 #include "core/frame/Frame.h" |
| 13 #include "core/frame/FrameClient.h" | 15 #include "core/frame/FrameClient.h" |
| 14 #include "core/frame/FrameConsole.h" | 16 #include "core/frame/FrameConsole.h" |
| 15 #include "core/frame/LocalDOMWindow.h" | 17 #include "core/frame/LocalDOMWindow.h" |
| 16 #include "core/frame/Location.h" | 18 #include "core/frame/Location.h" |
| 17 #include "core/frame/Settings.h" | 19 #include "core/frame/Settings.h" |
| 18 #include "core/frame/UseCounter.h" | 20 #include "core/frame/UseCounter.h" |
| 19 #include "core/input/InputDeviceCapabilities.h" | 21 #include "core/input/InputDeviceCapabilities.h" |
| 20 #include "core/inspector/ConsoleMessage.h" | 22 #include "core/inspector/ConsoleMessage.h" |
| 21 #include "core/loader/MixedContentChecker.h" | 23 #include "core/loader/MixedContentChecker.h" |
| 22 #include "core/page/ChromeClient.h" | 24 #include "core/page/ChromeClient.h" |
| 23 #include "core/page/FocusController.h" | 25 #include "core/page/FocusController.h" |
| 24 #include "core/page/Page.h" | 26 #include "core/page/Page.h" |
| 25 #include "core/probe/CoreProbes.h" | 27 #include "core/probe/CoreProbes.h" |
| 26 #include "platform/weborigin/KURL.h" | 28 #include "platform/weborigin/KURL.h" |
| 27 #include "platform/weborigin/SecurityOrigin.h" | 29 #include "platform/weborigin/SecurityOrigin.h" |
| 28 #include "platform/weborigin/Suborigin.h" | 30 #include "platform/weborigin/Suborigin.h" |
| 29 | 31 |
| 30 namespace blink { | 32 namespace blink { |
| 31 | 33 |
| 32 DOMWindow::DOMWindow(Frame& frame) : frame_(frame), window_is_closing_(false) {} | 34 DOMWindow::DOMWindow(Frame& frame) |
| 35 : frame_(frame), |
| 36 window_proxy_manager_(frame.GetWindowProxyManager()), |
| 37 window_is_closing_(false) {} |
| 33 | 38 |
| 34 DOMWindow::~DOMWindow() { | 39 DOMWindow::~DOMWindow() { |
| 35 // The frame must be disconnected before finalization. | 40 // The frame must be disconnected before finalization. |
| 36 DCHECK(!frame_); | 41 DCHECK(!frame_); |
| 37 } | 42 } |
| 38 | 43 |
| 39 v8::Local<v8::Object> DOMWindow::Wrap(v8::Isolate*, | 44 v8::Local<v8::Object> DOMWindow::Wrap(v8::Isolate*, |
| 40 v8::Local<v8::Object> creation_context) { | 45 v8::Local<v8::Object> creation_context) { |
| 41 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " | 46 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " |
| 42 "wrappers must be created at WindowProxy::createContext() and " | 47 "wrappers must be created at WindowProxy::createContext() and " |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 } | 418 } |
| 414 | 419 |
| 415 // If we're a top level window, bring the window to the front. | 420 // If we're a top level window, bring the window to the front. |
| 416 if (GetFrame()->IsMainFrame() && allow_focus) | 421 if (GetFrame()->IsMainFrame() && allow_focus) |
| 417 page->GetChromeClient().Focus(); | 422 page->GetChromeClient().Focus(); |
| 418 | 423 |
| 419 page->GetFocusController().FocusDocumentView(GetFrame(), | 424 page->GetFocusController().FocusDocumentView(GetFrame(), |
| 420 true /* notifyEmbedder */); | 425 true /* notifyEmbedder */); |
| 421 } | 426 } |
| 422 | 427 |
| 428 v8::Local<v8::Object> DOMWindow::GlobalProxy(DOMWrapperWorld& world) { |
| 429 // TODO(yukishiino): Make this function always return the non-empty handle |
| 430 // even if the frame is detached because the global proxy must always exist |
| 431 // per spec. |
| 432 return window_proxy_manager_->GetWindowProxy(world) |
| 433 ->GlobalProxyIfNotDetached(); |
| 434 } |
| 435 |
| 423 InputDeviceCapabilitiesConstants* DOMWindow::GetInputDeviceCapabilities() { | 436 InputDeviceCapabilitiesConstants* DOMWindow::GetInputDeviceCapabilities() { |
| 424 if (!input_capabilities_) | 437 if (!input_capabilities_) |
| 425 input_capabilities_ = new InputDeviceCapabilitiesConstants; | 438 input_capabilities_ = new InputDeviceCapabilitiesConstants; |
| 426 return input_capabilities_; | 439 return input_capabilities_; |
| 427 } | 440 } |
| 428 | 441 |
| 429 DEFINE_TRACE(DOMWindow) { | 442 DEFINE_TRACE(DOMWindow) { |
| 430 visitor->Trace(frame_); | 443 visitor->Trace(frame_); |
| 444 visitor->Trace(window_proxy_manager_); |
| 431 visitor->Trace(input_capabilities_); | 445 visitor->Trace(input_capabilities_); |
| 432 visitor->Trace(location_); | 446 visitor->Trace(location_); |
| 433 EventTargetWithInlineData::Trace(visitor); | 447 EventTargetWithInlineData::Trace(visitor); |
| 434 } | 448 } |
| 435 | 449 |
| 436 } // namespace blink | 450 } // namespace blink |
| OLD | NEW |