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

Side by Side Diff: Source/platform/weborigin/SecurityOrigin.cpp

Issue 1180923003: Add window access checks for Suborigins (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix tests on Windows Created 5 years, 6 months 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 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 canAccess = true; 279 canAccess = true;
280 } 280 }
281 } 281 }
282 282
283 if (canAccess && isLocal()) 283 if (canAccess && isLocal())
284 canAccess = passesFileCheck(other); 284 canAccess = passesFileCheck(other);
285 285
286 return canAccess; 286 return canAccess;
287 } 287 }
288 288
289 bool SecurityOrigin::canAccessCheckSuborigins(const SecurityOrigin* other) const
290 {
291 if (hasSuborigin() != other->hasSuborigin())
292 return false;
293
294 if (hasSuborigin() && suboriginName() != other->suboriginName())
295 return false;
296
297 return canAccess(other);
298 }
299
289 bool SecurityOrigin::passesFileCheck(const SecurityOrigin* other) const 300 bool SecurityOrigin::passesFileCheck(const SecurityOrigin* other) const
290 { 301 {
291 ASSERT(isLocal() && other->isLocal()); 302 ASSERT(isLocal() && other->isLocal());
292 303
293 return !m_enforceFilePathSeparation && !other->m_enforceFilePathSeparation; 304 return !m_enforceFilePathSeparation && !other->m_enforceFilePathSeparation;
294 } 305 }
295 306
296 bool SecurityOrigin::canRequest(const KURL& url) const 307 bool SecurityOrigin::canRequest(const KURL& url) const
297 { 308 {
298 if (m_universalAccess) 309 if (m_universalAccess)
(...skipping 14 matching lines...) Expand all
313 // to ignore document.domain effects. 324 // to ignore document.domain effects.
314 if (isSameSchemeHostPort(targetOrigin.get())) 325 if (isSameSchemeHostPort(targetOrigin.get()))
315 return true; 326 return true;
316 327
317 if (SecurityPolicy::isAccessWhiteListed(this, targetOrigin.get())) 328 if (SecurityPolicy::isAccessWhiteListed(this, targetOrigin.get()))
318 return true; 329 return true;
319 330
320 return false; 331 return false;
321 } 332 }
322 333
334 bool SecurityOrigin::canRequestNoSuborigin(const KURL& url) const
335 {
336 return !hasSuborigin() && canRequest(url);
337 }
338
323 bool SecurityOrigin::taintsCanvas(const KURL& url) const 339 bool SecurityOrigin::taintsCanvas(const KURL& url) const
324 { 340 {
325 if (canRequest(url)) 341 if (canRequest(url))
326 return false; 342 return false;
327 343
328 // This function exists because we treat data URLs as having a unique origin , 344 // This function exists because we treat data URLs as having a unique origin ,
329 // contrary to the current (9/19/2009) draft of the HTML5 specification. 345 // contrary to the current (9/19/2009) draft of the HTML5 specification.
330 // We still want to let folks paint data URLs onto untainted canvases, so 346 // We still want to let folks paint data URLs onto untainted canvases, so
331 // we special case data URLs below. If we change to match HTML5 w.r.t. 347 // we special case data URLs below. If we change to match HTML5 w.r.t.
332 // data URL security, then we can remove this function in favor of 348 // data URL security, then we can remove this function in favor of
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 569
554 if (m_port != other->m_port) 570 if (m_port != other->m_port)
555 return false; 571 return false;
556 572
557 if (isLocal() && !passesFileCheck(other)) 573 if (isLocal() && !passesFileCheck(other))
558 return false; 574 return false;
559 575
560 return true; 576 return true;
561 } 577 }
562 578
579 bool SecurityOrigin::isSameSchemeHostPortAndSuborigin(const SecurityOrigin* othe r) const
580 {
581 return isSameSchemeHostPort(other) && (!hasSuborigin() || suboriginName() == other->suboriginName());
582 }
583
563 const KURL& SecurityOrigin::urlWithUniqueSecurityOrigin() 584 const KURL& SecurityOrigin::urlWithUniqueSecurityOrigin()
564 { 585 {
565 ASSERT(isMainThread()); 586 ASSERT(isMainThread());
566 DEFINE_STATIC_LOCAL(const KURL, uniqueSecurityOriginURL, (ParsedURLString, " data:,")); 587 DEFINE_STATIC_LOCAL(const KURL, uniqueSecurityOriginURL, (ParsedURLString, " data:,"));
567 return uniqueSecurityOriginURL; 588 return uniqueSecurityOriginURL;
568 } 589 }
569 590
570 void SecurityOrigin::transferPrivilegesFrom(const SecurityOrigin& origin) 591 void SecurityOrigin::transferPrivilegesFrom(const SecurityOrigin& origin)
571 { 592 {
572 m_universalAccess = origin.m_universalAccess; 593 m_universalAccess = origin.m_universalAccess;
573 m_canLoadLocalResources = origin.m_canLoadLocalResources; 594 m_canLoadLocalResources = origin.m_canLoadLocalResources;
574 m_enforceFilePathSeparation = origin.m_enforceFilePathSeparation; 595 m_enforceFilePathSeparation = origin.m_enforceFilePathSeparation;
575 } 596 }
576 597
577 } // namespace blink 598 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/weborigin/SecurityOrigin.h ('k') | Source/platform/weborigin/SecurityOriginHash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698