| 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 "bindings/core/v8/ScriptCallStackFactory.h" | 8 #include "bindings/core/v8/ScriptCallStackFactory.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 // If this DOMWindow isn't currently active in the Frame, then there's no | 125 // If this DOMWindow isn't currently active in the Frame, then there's no |
| 126 // way we should allow the access. | 126 // way we should allow the access. |
| 127 if (isCurrentlyDisplayedInFrame()) { | 127 if (isCurrentlyDisplayedInFrame()) { |
| 128 // FIXME: Is there some way to eliminate the need for a separate "callin
gWindow == this" check? | 128 // FIXME: Is there some way to eliminate the need for a separate "callin
gWindow == this" check? |
| 129 if (&callingWindow == this) | 129 if (&callingWindow == this) |
| 130 return false; | 130 return false; |
| 131 | 131 |
| 132 // FIXME: The name canAccess seems to be a roundabout way to ask "can ex
ecute script". | 132 // FIXME: The name canAccess seems to be a roundabout way to ask "can ex
ecute script". |
| 133 // Can we name the SecurityOrigin function better to make this more clea
r? | 133 // Can we name the SecurityOrigin function better to make this more clea
r? |
| 134 if (callingWindow.frame()->securityContext()->securityOrigin()->canAcces
s(frame()->securityContext()->securityOrigin())) | 134 if (callingWindow.frame()->securityContext()->securityOrigin()->canAcces
sCheckSuborigins(frame()->securityContext()->securityOrigin())) |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 | 137 |
| 138 callingWindow.printErrorMessage(crossDomainAccessErrorMessage(&callingWindow
)); | 138 callingWindow.printErrorMessage(crossDomainAccessErrorMessage(&callingWindow
)); |
| 139 return true; | 139 return true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void DOMWindow::resetLocation() | 142 void DOMWindow::resetLocation() |
| 143 { | 143 { |
| 144 // Location needs to be reset manually because it doesn't inherit from DOMWi
ndowProperty. | 144 // Location needs to be reset manually because it doesn't inherit from DOMWi
ndowProperty. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // http://crbug.com/17325 | 213 // http://crbug.com/17325 |
| 214 String DOMWindow::sanitizedCrossDomainAccessErrorMessage(LocalDOMWindow* calling
Window) | 214 String DOMWindow::sanitizedCrossDomainAccessErrorMessage(LocalDOMWindow* calling
Window) |
| 215 { | 215 { |
| 216 if (!callingWindow || !callingWindow->document() || !frame()) | 216 if (!callingWindow || !callingWindow->document() || !frame()) |
| 217 return String(); | 217 return String(); |
| 218 | 218 |
| 219 const KURL& callingWindowURL = callingWindow->document()->url(); | 219 const KURL& callingWindowURL = callingWindow->document()->url(); |
| 220 if (callingWindowURL.isNull()) | 220 if (callingWindowURL.isNull()) |
| 221 return String(); | 221 return String(); |
| 222 | 222 |
| 223 ASSERT(!callingWindow->document()->securityOrigin()->canAccess(frame()->secu
rityContext()->securityOrigin())); | 223 ASSERT(!callingWindow->document()->securityOrigin()->canAccessCheckSuborigin
s(frame()->securityContext()->securityOrigin())); |
| 224 | 224 |
| 225 SecurityOrigin* activeOrigin = callingWindow->document()->securityOrigin(); | 225 SecurityOrigin* activeOrigin = callingWindow->document()->securityOrigin(); |
| 226 String message = "Blocked a frame with origin \"" + activeOrigin->toString()
+ "\" from accessing a cross-origin frame."; | 226 String message = "Blocked a frame with origin \"" + activeOrigin->toString()
+ "\" from accessing a cross-origin frame."; |
| 227 | 227 |
| 228 // FIXME: Evaluate which details from 'crossDomainAccessErrorMessage' may sa
fely be reported to JavaScript. | 228 // FIXME: Evaluate which details from 'crossDomainAccessErrorMessage' may sa
fely be reported to JavaScript. |
| 229 | 229 |
| 230 return message; | 230 return message; |
| 231 } | 231 } |
| 232 | 232 |
| 233 String DOMWindow::crossDomainAccessErrorMessage(LocalDOMWindow* callingWindow) | 233 String DOMWindow::crossDomainAccessErrorMessage(LocalDOMWindow* callingWindow) |
| 234 { | 234 { |
| 235 if (!callingWindow || !callingWindow->document() || !frame()) | 235 if (!callingWindow || !callingWindow->document() || !frame()) |
| 236 return String(); | 236 return String(); |
| 237 | 237 |
| 238 const KURL& callingWindowURL = callingWindow->document()->url(); | 238 const KURL& callingWindowURL = callingWindow->document()->url(); |
| 239 if (callingWindowURL.isNull()) | 239 if (callingWindowURL.isNull()) |
| 240 return String(); | 240 return String(); |
| 241 | 241 |
| 242 // FIXME: This message, and other console messages, have extra newlines. Sho
uld remove them. | 242 // FIXME: This message, and other console messages, have extra newlines. Sho
uld remove them. |
| 243 SecurityOrigin* activeOrigin = callingWindow->document()->securityOrigin(); | 243 SecurityOrigin* activeOrigin = callingWindow->document()->securityOrigin(); |
| 244 SecurityOrigin* targetOrigin = frame()->securityContext()->securityOrigin(); | 244 SecurityOrigin* targetOrigin = frame()->securityContext()->securityOrigin(); |
| 245 ASSERT(!activeOrigin->canAccess(targetOrigin)); | 245 ASSERT(!activeOrigin->canAccessCheckSuborigins(targetOrigin)); |
| 246 | 246 |
| 247 String message = "Blocked a frame with origin \"" + activeOrigin->toString()
+ "\" from accessing a frame with origin \"" + targetOrigin->toString() + "\".
"; | 247 String message = "Blocked a frame with origin \"" + activeOrigin->toString()
+ "\" from accessing a frame with origin \"" + targetOrigin->toString() + "\".
"; |
| 248 | 248 |
| 249 // Sandbox errors: Use the origin of the frames' location, rather than their
actual origin (since we know that at least one will be "null"). | 249 // Sandbox errors: Use the origin of the frames' location, rather than their
actual origin (since we know that at least one will be "null"). |
| 250 KURL activeURL = callingWindow->document()->url(); | 250 KURL activeURL = callingWindow->document()->url(); |
| 251 // TODO(alexmos): RemoteFrames do not have a document, and their URLs | 251 // TODO(alexmos): RemoteFrames do not have a document, and their URLs |
| 252 // aren't replicated. For now, construct the URL using the replicated | 252 // aren't replicated. For now, construct the URL using the replicated |
| 253 // origin for RemoteFrames. If the target frame is remote and sandboxed, | 253 // origin for RemoteFrames. If the target frame is remote and sandboxed, |
| 254 // there isn't anything else to show other than "null" for its origin. | 254 // there isn't anything else to show other than "null" for its origin. |
| 255 KURL targetURL = isLocalDOMWindow() ? document()->url() : KURL(KURL(), targe
tOrigin->toString()); | 255 KURL targetURL = isLocalDOMWindow() ? document()->url() : KURL(KURL(), targe
tOrigin->toString()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 278 return message + "Protocols, domains, and ports must match."; | 278 return message + "Protocols, domains, and ports must match."; |
| 279 } | 279 } |
| 280 | 280 |
| 281 DEFINE_TRACE(DOMWindow) | 281 DEFINE_TRACE(DOMWindow) |
| 282 { | 282 { |
| 283 visitor->trace(m_location); | 283 visitor->trace(m_location); |
| 284 EventTargetWithInlineData::trace(visitor); | 284 EventTargetWithInlineData::trace(visitor); |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace blink | 287 } // namespace blink |
| OLD | NEW |