Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: third_party/WebKit/Source/core/frame/DOMWindow.cpp

Issue 1417023006: bindings: Refactors BindingSecurity::shouldAllowAccessToXXX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the assertion condition. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 toLocalDOMWindow(this)->schedulePostMessage(event, source, target.get(), stackTrace.release()); 224 toLocalDOMWindow(this)->schedulePostMessage(event, source, target.get(), stackTrace.release());
225 } 225 }
226 } 226 }
227 227
228 // FIXME: Once we're throwing exceptions for cross-origin access violations, we will always sanitize the target 228 // FIXME: Once we're throwing exceptions for cross-origin access violations, we will always sanitize the target
229 // frame details, so we can safely combine 'crossDomainAccessErrorMessage' with this method after considering 229 // frame details, so we can safely combine 'crossDomainAccessErrorMessage' with this method after considering
230 // exactly which details may be exposed to JavaScript. 230 // exactly which details may be exposed to JavaScript.
231 // 231 //
232 // http://crbug.com/17325 232 // http://crbug.com/17325
233 String DOMWindow::sanitizedCrossDomainAccessErrorMessage(LocalDOMWindow* calling Window) 233 String DOMWindow::sanitizedCrossDomainAccessErrorMessage(const LocalDOMWindow* c allingWindow) const
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 ASSERT(!callingWindow->document()->securityOrigin()->canAccessCheckSuborigin s(frame()->securityContext()->securityOrigin())); 242 ASSERT(!callingWindow->document()->securityOrigin()->canAccessCheckSuborigin s(frame()->securityContext()->securityOrigin()));
243 243
244 SecurityOrigin* activeOrigin = callingWindow->document()->securityOrigin(); 244 const SecurityOrigin* activeOrigin = callingWindow->document()->securityOrig in();
245 String message = "Blocked a frame with origin \"" + activeOrigin->toString() + "\" from accessing a cross-origin frame."; 245 String message = "Blocked a frame with origin \"" + activeOrigin->toString() + "\" from accessing a cross-origin frame.";
246 246
247 // FIXME: Evaluate which details from 'crossDomainAccessErrorMessage' may sa fely be reported to JavaScript. 247 // FIXME: Evaluate which details from 'crossDomainAccessErrorMessage' may sa fely be reported to JavaScript.
248 248
249 return message; 249 return message;
250 } 250 }
251 251
252 String DOMWindow::crossDomainAccessErrorMessage(LocalDOMWindow* callingWindow) 252 String DOMWindow::crossDomainAccessErrorMessage(const LocalDOMWindow* callingWin dow) const
253 { 253 {
254 if (!callingWindow || !callingWindow->document() || !frame()) 254 if (!callingWindow || !callingWindow->document() || !frame())
255 return String(); 255 return String();
256 256
257 const KURL& callingWindowURL = callingWindow->document()->url(); 257 const KURL& callingWindowURL = callingWindow->document()->url();
258 if (callingWindowURL.isNull()) 258 if (callingWindowURL.isNull())
259 return String(); 259 return String();
260 260
261 // FIXME: This message, and other console messages, have extra newlines. Sho uld remove them. 261 // FIXME: This message, and other console messages, have extra newlines. Sho uld remove them.
262 SecurityOrigin* activeOrigin = callingWindow->document()->securityOrigin(); 262 const SecurityOrigin* activeOrigin = callingWindow->document()->securityOrig in();
263 SecurityOrigin* targetOrigin = frame()->securityContext()->securityOrigin(); 263 const SecurityOrigin* targetOrigin = frame()->securityContext()->securityOri gin();
264 ASSERT(!activeOrigin->canAccessCheckSuborigins(targetOrigin)); 264 ASSERT(!activeOrigin->canAccessCheckSuborigins(targetOrigin));
265 265
266 String message = "Blocked a frame with origin \"" + activeOrigin->toString() + "\" from accessing a frame with origin \"" + targetOrigin->toString() + "\". "; 266 String message = "Blocked a frame with origin \"" + activeOrigin->toString() + "\" from accessing a frame with origin \"" + targetOrigin->toString() + "\". ";
267 267
268 // Sandbox errors: Use the origin of the frames' location, rather than their actual origin (since we know that at least one will be "null"). 268 // Sandbox errors: Use the origin of the frames' location, rather than their actual origin (since we know that at least one will be "null").
269 KURL activeURL = callingWindow->document()->url(); 269 KURL activeURL = callingWindow->document()->url();
270 // TODO(alexmos): RemoteFrames do not have a document, and their URLs 270 // TODO(alexmos): RemoteFrames do not have a document, and their URLs
271 // aren't replicated. For now, construct the URL using the replicated 271 // aren't replicated. For now, construct the URL using the replicated
272 // origin for RemoteFrames. If the target frame is remote and sandboxed, 272 // origin for RemoteFrames. If the target frame is remote and sandboxed,
273 // there isn't anything else to show other than "null" for its origin. 273 // there isn't anything else to show other than "null" for its origin.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 m_windowIsClosing = true; 341 m_windowIsClosing = true;
342 } 342 }
343 343
344 DEFINE_TRACE(DOMWindow) 344 DEFINE_TRACE(DOMWindow)
345 { 345 {
346 visitor->trace(m_location); 346 visitor->trace(m_location);
347 EventTargetWithInlineData::trace(visitor); 347 EventTargetWithInlineData::trace(visitor);
348 } 348 }
349 349
350 } // namespace blink 350 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/DOMWindow.h ('k') | third_party/WebKit/Source/core/frame/LocalDOMWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698