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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // way we should allow the access. | 130 // way we should allow the access. |
131 if (isCurrentlyDisplayedInFrame()) { | 131 if (isCurrentlyDisplayedInFrame()) { |
132 // FIXME: Is there some way to eliminate the need for a separate | 132 // FIXME: Is there some way to eliminate the need for a separate |
133 // "callingWindow == this" check? | 133 // "callingWindow == this" check? |
134 if (&callingWindow == this) | 134 if (&callingWindow == this) |
135 return false; | 135 return false; |
136 | 136 |
137 // FIXME: The name canAccess seems to be a roundabout way to ask "can | 137 // FIXME: The name canAccess seems to be a roundabout way to ask "can |
138 // execute script". Can we name the SecurityOrigin function better to make | 138 // execute script". Can we name the SecurityOrigin function better to make |
139 // this more clear? | 139 // this more clear? |
140 if (callingWindow.document()->getSecurityOrigin()->canAccessCheckSuborigins( | 140 if (callingWindow.document()->getSecurityOrigin()->canAccess( |
141 frame()->securityContext()->getSecurityOrigin())) | 141 frame()->securityContext()->getSecurityOrigin())) { |
142 return false; | 142 return false; |
| 143 } |
143 } | 144 } |
144 | 145 |
145 callingWindow.printErrorMessage( | 146 callingWindow.printErrorMessage( |
146 crossDomainAccessErrorMessage(&callingWindow)); | 147 crossDomainAccessErrorMessage(&callingWindow)); |
147 return true; | 148 return true; |
148 } | 149 } |
149 | 150 |
150 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, | 151 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, |
151 const MessagePortArray& ports, | 152 const MessagePortArray& ports, |
152 const String& targetOrigin, | 153 const String& targetOrigin, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 264 |
264 // FIXME: This message, and other console messages, have extra newlines. | 265 // FIXME: This message, and other console messages, have extra newlines. |
265 // Should remove them. | 266 // Should remove them. |
266 const SecurityOrigin* activeOrigin = | 267 const SecurityOrigin* activeOrigin = |
267 callingWindow->document()->getSecurityOrigin(); | 268 callingWindow->document()->getSecurityOrigin(); |
268 const SecurityOrigin* targetOrigin = | 269 const SecurityOrigin* targetOrigin = |
269 frame()->securityContext()->getSecurityOrigin(); | 270 frame()->securityContext()->getSecurityOrigin(); |
270 // It's possible for a remote frame to be same origin with respect to a | 271 // It's possible for a remote frame to be same origin with respect to a |
271 // local frame, but it must still be treated as a disallowed cross-domain | 272 // local frame, but it must still be treated as a disallowed cross-domain |
272 // access. See https://crbug.com/601629. | 273 // access. See https://crbug.com/601629. |
273 ASSERT(frame()->isRemoteFrame() || | 274 DCHECK(frame()->isRemoteFrame() || !activeOrigin->canAccess(targetOrigin)); |
274 !activeOrigin->canAccessCheckSuborigins(targetOrigin)); | |
275 | 275 |
276 String message = "Blocked a frame with origin \"" + activeOrigin->toString() + | 276 String message = "Blocked a frame with origin \"" + activeOrigin->toString() + |
277 "\" from accessing a frame with origin \"" + | 277 "\" from accessing a frame with origin \"" + |
278 targetOrigin->toString() + "\". "; | 278 targetOrigin->toString() + "\". "; |
279 | 279 |
280 // Sandbox errors: Use the origin of the frames' location, rather than their | 280 // Sandbox errors: Use the origin of the frames' location, rather than their |
281 // actual origin (since we know that at least one will be "null"). | 281 // actual origin (since we know that at least one will be "null"). |
282 KURL activeURL = callingWindow->document()->url(); | 282 KURL activeURL = callingWindow->document()->url(); |
283 // TODO(alexmos): RemoteFrames do not have a document, and their URLs | 283 // TODO(alexmos): RemoteFrames do not have a document, and their URLs |
284 // aren't replicated. For now, construct the URL using the replicated | 284 // aren't replicated. For now, construct the URL using the replicated |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 } | 422 } |
423 | 423 |
424 DEFINE_TRACE(DOMWindow) { | 424 DEFINE_TRACE(DOMWindow) { |
425 visitor->trace(m_frame); | 425 visitor->trace(m_frame); |
426 visitor->trace(m_inputCapabilities); | 426 visitor->trace(m_inputCapabilities); |
427 visitor->trace(m_location); | 427 visitor->trace(m_location); |
428 EventTargetWithInlineData::trace(visitor); | 428 EventTargetWithInlineData::trace(visitor); |
429 } | 429 } |
430 | 430 |
431 } // namespace blink | 431 } // namespace blink |
OLD | NEW |