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

Side by Side Diff: content/browser/child_process_security_policy_impl.cc

Issue 2541063002: Revert of Remove about:srcdoc url conversion. (Closed)
Patch Set: Created 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/child_process_security_policy_impl.h" 5 #include "content/browser/child_process_security_policy_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 619
620 state->second->RevokeReadRawCookies(); 620 state->second->RevokeReadRawCookies();
621 } 621 }
622 622
623 bool ChildProcessSecurityPolicyImpl::CanRequestURL( 623 bool ChildProcessSecurityPolicyImpl::CanRequestURL(
624 int child_id, const GURL& url) { 624 int child_id, const GURL& url) {
625 if (!url.is_valid()) 625 if (!url.is_valid())
626 return false; // Can't request invalid URLs. 626 return false; // Can't request invalid URLs.
627 627
628 if (IsPseudoScheme(url.scheme())) { 628 if (IsPseudoScheme(url.scheme())) {
629 // Every child process can request <about:blank> and <about:srcdoc>. 629 // Every child process can request <about:blank>.
630 if (url == url::kAboutBlankURL || url == kAboutSrcDocURL) 630 if (base::LowerCaseEqualsASCII(url.spec(), url::kAboutBlankURL))
631 return true; 631 return true;
632 // URLs like <about:version>, <about:crash>, <view-source:...> shouldn't be 632 // URLs like <about:version>, <about:crash>, <view-source:...> shouldn't be
633 // requestable by any child process. Also, this case covers 633 // requestable by any child process. Also, this case covers
634 // <javascript:...>, which should be handled internally by the process and 634 // <javascript:...>, which should be handled internally by the process and
635 // not kicked up to the browser. 635 // not kicked up to the browser.
636 return false; 636 return false;
637 } 637 }
638 638
639 // Blob and filesystem URLs require special treatment, since they embed an 639 // Blob and filesystem URLs require special treatment, since they embed an
640 // inner origin. 640 // inner origin.
(...skipping 16 matching lines...) Expand all
657 // Also allow URLs destined for ShellExecute and not the browser itself. 657 // Also allow URLs destined for ShellExecute and not the browser itself.
658 return !GetContentClient()->browser()->IsHandledURL(url) && 658 return !GetContentClient()->browser()->IsHandledURL(url) &&
659 !net::URLRequest::IsHandledURL(url); 659 !net::URLRequest::IsHandledURL(url);
660 } 660 }
661 661
662 bool ChildProcessSecurityPolicyImpl::CanCommitURL(int child_id, 662 bool ChildProcessSecurityPolicyImpl::CanCommitURL(int child_id,
663 const GURL& url) { 663 const GURL& url) {
664 if (!url.is_valid()) 664 if (!url.is_valid())
665 return false; // Can't commit invalid URLs. 665 return false; // Can't commit invalid URLs.
666 666
667 // Of all the pseudo schemes, only about:blank and about:srcdoc are allowed to 667 // Of all the pseudo schemes, only about:blank is allowed to commit.
668 // commit.
669 if (IsPseudoScheme(url.scheme())) 668 if (IsPseudoScheme(url.scheme()))
670 return url == url::kAboutBlankURL || url == kAboutSrcDocURL; 669 return base::LowerCaseEqualsASCII(url.spec(), url::kAboutBlankURL);
671 670
672 // Blob and filesystem URLs require special treatment; validate the inner 671 // Blob and filesystem URLs require special treatment; validate the inner
673 // origin they embed. 672 // origin they embed.
674 if (url.SchemeIsBlob() || url.SchemeIsFileSystem()) { 673 if (url.SchemeIsBlob() || url.SchemeIsFileSystem()) {
675 if (IsMalformedBlobUrl(url)) 674 if (IsMalformedBlobUrl(url))
676 return false; 675 return false;
677 676
678 url::Origin origin(url); 677 url::Origin origin(url);
679 return origin.unique() || CanCommitURL(child_id, GURL(origin.Serialize())); 678 return origin.unique() || CanCommitURL(child_id, GURL(origin.Serialize()));
680 } 679 }
(...skipping 30 matching lines...) Expand all
711 if (!url.is_valid()) 710 if (!url.is_valid())
712 return false; // Can't set invalid URLs as origin headers. 711 return false; // Can't set invalid URLs as origin headers.
713 712
714 // Suborigin URLs are a special case and are allowed to be an origin header. 713 // Suborigin URLs are a special case and are allowed to be an origin header.
715 if (url.scheme() == url::kHttpSuboriginScheme || 714 if (url.scheme() == url::kHttpSuboriginScheme ||
716 url.scheme() == url::kHttpsSuboriginScheme) { 715 url.scheme() == url::kHttpsSuboriginScheme) {
717 DCHECK(IsPseudoScheme(url.scheme())); 716 DCHECK(IsPseudoScheme(url.scheme()));
718 return true; 717 return true;
719 } 718 }
720 719
721 // about:srcdoc cannot be used as an origin
722 if (url == kAboutSrcDocURL)
723 return false;
724
725 // If this process can commit |url|, it can use |url| as an origin for 720 // If this process can commit |url|, it can use |url| as an origin for
726 // outbound requests. 721 // outbound requests.
727 if (CanCommitURL(child_id, url)) 722 if (CanCommitURL(child_id, url))
728 return true; 723 return true;
729 724
730 // Allow schemes which may come from scripts executing in isolated worlds; 725 // Allow schemes which may come from scripts executing in isolated worlds;
731 // XHRs issued by such scripts reflect the script origin rather than the 726 // XHRs issued by such scripts reflect the script origin rather than the
732 // document origin. 727 // document origin.
733 { 728 {
734 base::AutoLock lock(lock_); 729 base::AutoLock lock(lock_);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 base::AutoLock lock(lock_); 993 base::AutoLock lock(lock_);
999 994
1000 SecurityStateMap::iterator state = security_state_.find(child_id); 995 SecurityStateMap::iterator state = security_state_.find(child_id);
1001 if (state == security_state_.end()) 996 if (state == security_state_.end())
1002 return false; 997 return false;
1003 998
1004 return state->second->can_send_midi_sysex(); 999 return state->second->can_send_midi_sysex();
1005 } 1000 }
1006 1001
1007 } // namespace content 1002 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/web_contents_observer_proxy.cc ('k') | content/browser/child_process_security_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698