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 "config.h" | 5 #include "config.h" |
| 6 #include "core/frame/DOMWindow.h" | 6 #include "core/frame/DOMWindow.h" |
| 7 | 7 |
| 8 #include "core/dom/SecurityContext.h" | 8 #include "core/dom/SecurityContext.h" |
| 9 #include "core/frame/Frame.h" | 9 #include "core/frame/Frame.h" |
| 10 #include "core/frame/FrameClient.h" | 10 #include "core/frame/FrameClient.h" |
| 11 #include "core/frame/Location.h" | |
| 11 #include "platform/weborigin/KURL.h" | 12 #include "platform/weborigin/KURL.h" |
| 12 #include "platform/weborigin/SecurityOrigin.h" | 13 #include "platform/weborigin/SecurityOrigin.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 17 DOMWindow::~DOMWindow() | |
| 18 { | |
| 19 } | |
| 20 | |
| 21 Location* DOMWindow::location() const | |
| 22 { | |
| 23 if (!m_location) | |
| 24 m_location = Location::create(frame()); | |
| 25 return m_location.get(); | |
| 26 } | |
| 27 | |
| 16 bool DOMWindow::closed() const | 28 bool DOMWindow::closed() const |
| 17 { | 29 { |
| 18 return !frame() || !frame()->host(); | 30 return !frame() || !frame()->host(); |
| 19 } | 31 } |
| 20 | 32 |
| 21 unsigned DOMWindow::length() const | 33 unsigned DOMWindow::length() const |
| 22 { | 34 { |
| 23 return frame() ? frame()->tree().scopedChildCount() : 0; | 35 return frame() ? frame()->tree().scopedChildCount() : 0; |
| 24 } | 36 } |
| 25 | 37 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 return false; | 97 return false; |
| 86 | 98 |
| 87 // FIXME: The name canAccess seems to be a roundabout way to ask "can ex ecute script". | 99 // FIXME: The name canAccess seems to be a roundabout way to ask "can ex ecute script". |
| 88 // Can we name the SecurityOrigin function better to make this more clea r? | 100 // Can we name the SecurityOrigin function better to make this more clea r? |
| 89 if (callingWindow.frame()->securityContext()->securityOrigin()->canAcces s(frame()->securityContext()->securityOrigin())) | 101 if (callingWindow.frame()->securityContext()->securityOrigin()->canAcces s(frame()->securityContext()->securityOrigin())) |
| 90 return false; | 102 return false; |
| 91 } | 103 } |
| 92 return true; | 104 return true; |
| 93 } | 105 } |
| 94 | 106 |
| 107 void DOMWindow::reset() | |
| 108 { | |
| 109 // Location needs to be reset manually because it doesn't inherit from DOMWi ndowProperty. | |
|
haraken
2015/02/03 00:56:09
I'm just curious, but why can't Location inherit f
dcheng
2015/02/03 08:22:54
Location was the only DOMWindowProperty that neede
haraken
2015/02/03 08:24:09
Thanks, sounds reasonable to me.
| |
| 110 m_location->reset(); | |
| 111 m_location = nullptr; | |
| 112 } | |
| 113 | |
| 95 } // namespace blink | 114 } // namespace blink |
| OLD | NEW |