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

Unified Diff: content/browser/child_process_security_policy.cc

Issue 7873007: Restricting redirects to chrome: (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Improving that path so it doesn't break things Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_security_policy.cc
diff --git a/content/browser/child_process_security_policy.cc b/content/browser/child_process_security_policy.cc
index 81d3964c54a5c2759ff4e0767d1fe2a6f5c65953..2f3fe5df33018ea228a31355e89aae343e31390b 100644
--- a/content/browser/child_process_security_policy.cc
+++ b/content/browser/child_process_security_policy.cc
@@ -136,6 +136,10 @@ ChildProcessSecurityPolicy::ChildProcessSecurityPolicy() {
RegisterWebSafeScheme(chrome::kBlobScheme);
RegisterWebSafeScheme(chrome::kFileSystemScheme);
+ // The following Web UI schemes are only accessible by children with with
+ // WebUI bindings.
+ RegisterWebUIScheme(chrome::kChromeUIScheme);
abarth-chromium 2011/09/19 06:46:39 In the past, access to this scheme happened natura
+
// We know about the following pseudo schemes and treat them specially.
RegisterPseudoScheme(chrome::kAboutScheme);
RegisterPseudoScheme(chrome::kJavaScriptScheme);
@@ -192,6 +196,21 @@ bool ChildProcessSecurityPolicy::IsWebSafeScheme(const std::string& scheme) {
return (web_safe_schemes_.find(scheme) != web_safe_schemes_.end());
}
+void ChildProcessSecurityPolicy::RegisterWebUIScheme(
+ const std::string& scheme) {
+ base::AutoLock lock(lock_);
+ DCHECK(webui_schemes_.count(scheme) == 0) << "Adds schemes at most once.";
+ DCHECK(web_safe_schemes_.count(scheme) == 0) << "WebUI schemes not web-safe.";
+
+ webui_schemes_.insert(scheme);
+}
+
+bool ChildProcessSecurityPolicy::IsWebUIScheme(const std::string& scheme) {
+ base::AutoLock lock(lock_);
+
+ return (webui_schemes_.find(scheme) != webui_schemes_.end());
+}
+
void ChildProcessSecurityPolicy::RegisterPseudoScheme(
const std::string& scheme) {
base::AutoLock lock(lock_);
@@ -349,7 +368,7 @@ bool ChildProcessSecurityPolicy::CanRequestURL(
return false; // Can't request invalid URLs.
if (IsDisabledScheme(url.scheme()))
- return false; // The scheme is disabled by policy.
+ return false; // The scheme is disabled by policy.
if (IsWebSafeScheme(url.scheme()))
return true; // The scheme has been white-listed for every child process.
@@ -393,6 +412,11 @@ bool ChildProcessSecurityPolicy::CanRequestURL(
}
}
+bool ChildProcessSecurityPolicy::CanRedirectURL(
+ int child_id, const GURL& url) {
+ return CanRequestURL(child_id, url) && !IsWebUIScheme(url.scheme());
abarth-chromium 2011/09/19 06:46:39 If you can request a URL, why can't you redirect t
+}
+
bool ChildProcessSecurityPolicy::CanReadFile(int child_id,
const FilePath& file) {
return HasPermissionsForFile(child_id, file, kReadFilePermissions);

Powered by Google App Engine
This is Rietveld 408576698