| 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 "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/dom/SecurityContext.h" | 10 #include "core/dom/SecurityContext.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const AtomicString& DOMWindow::interfaceName() const { | 57 const AtomicString& DOMWindow::interfaceName() const { |
| 58 return EventTargetNames::DOMWindow; | 58 return EventTargetNames::DOMWindow; |
| 59 } | 59 } |
| 60 | 60 |
| 61 const DOMWindow* DOMWindow::toDOMWindow() const { | 61 const DOMWindow* DOMWindow::toDOMWindow() const { |
| 62 return this; | 62 return this; |
| 63 } | 63 } |
| 64 | 64 |
| 65 Location* DOMWindow::location() const { | 65 Location* DOMWindow::location() const { |
| 66 if (!m_location) | 66 if (!m_location) |
| 67 m_location = Location::create(frame()); | 67 m_location = Location::create(const_cast<DOMWindow*>(this)); |
| 68 return m_location.get(); | 68 return m_location.get(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool DOMWindow::closed() const { | 71 bool DOMWindow::closed() const { |
| 72 return m_windowIsClosing || !frame() || !frame()->host(); | 72 return m_windowIsClosing || !frame() || !frame()->host(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 unsigned DOMWindow::length() const { | 75 unsigned DOMWindow::length() const { |
| 76 return frame() ? frame()->tree().scopedChildCount() : 0; | 76 return frame() ? frame()->tree().scopedChildCount() : 0; |
| 77 } | 77 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 if (callingWindow.document()->getSecurityOrigin()->canAccessCheckSuborigins( | 140 if (callingWindow.document()->getSecurityOrigin()->canAccessCheckSuborigins( |
| 141 frame()->securityContext()->getSecurityOrigin())) | 141 frame()->securityContext()->getSecurityOrigin())) |
| 142 return false; | 142 return false; |
| 143 } | 143 } |
| 144 | 144 |
| 145 callingWindow.printErrorMessage( | 145 callingWindow.printErrorMessage( |
| 146 crossDomainAccessErrorMessage(&callingWindow)); | 146 crossDomainAccessErrorMessage(&callingWindow)); |
| 147 return true; | 147 return true; |
| 148 } | 148 } |
| 149 | 149 |
| 150 void DOMWindow::resetLocation() { | |
| 151 // Location needs to be reset manually so that it doesn't retain a stale | |
| 152 // Frame pointer. | |
| 153 if (m_location) { | |
| 154 m_location->reset(); | |
| 155 m_location = nullptr; | |
| 156 } | |
| 157 } | |
| 158 | |
| 159 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, | 150 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, |
| 160 const MessagePortArray& ports, | 151 const MessagePortArray& ports, |
| 161 const String& targetOrigin, | 152 const String& targetOrigin, |
| 162 LocalDOMWindow* source, | 153 LocalDOMWindow* source, |
| 163 ExceptionState& exceptionState) { | 154 ExceptionState& exceptionState) { |
| 164 if (!isCurrentlyDisplayedInFrame()) | 155 if (!isCurrentlyDisplayedInFrame()) |
| 165 return; | 156 return; |
| 166 | 157 |
| 167 Document* sourceDocument = source->document(); | 158 Document* sourceDocument = source->document(); |
| 168 | 159 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 424 } |
| 434 | 425 |
| 435 DEFINE_TRACE(DOMWindow) { | 426 DEFINE_TRACE(DOMWindow) { |
| 436 visitor->trace(m_frame); | 427 visitor->trace(m_frame); |
| 437 visitor->trace(m_inputCapabilities); | 428 visitor->trace(m_inputCapabilities); |
| 438 visitor->trace(m_location); | 429 visitor->trace(m_location); |
| 439 EventTargetWithInlineData::trace(visitor); | 430 EventTargetWithInlineData::trace(visitor); |
| 440 } | 431 } |
| 441 | 432 |
| 442 } // namespace blink | 433 } // namespace blink |
| OLD | NEW |