diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 01:56:02 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 01:56:02 +0000 |
commit | dcf7d3525aa9b1f16b56a16d16108262db0571ee (patch) | |
tree | 91228f9d96aa74f102df742cdf76598cbb328958 /chrome/browser/renderer_host | |
parent | 387b71b7d1d1bf267cbe088136610959b319f3b3 (diff) | |
download | chromium_src-dcf7d3525aa9b1f16b56a16d16108262db0571ee.zip chromium_src-dcf7d3525aa9b1f16b56a16d16108262db0571ee.tar.gz chromium_src-dcf7d3525aa9b1f16b56a16d16108262db0571ee.tar.bz2 |
Coalesce more hardcoded schemes to using predefined constants.
Review URL: http://codereview.chromium.org/31008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/buffered_resource_handler.cc | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/renderer_security_policy.cc | 20 |
3 files changed, 16 insertions, 14 deletions
diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc index f70ac9e..6439a14 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.cc +++ b/chrome/browser/renderer_host/buffered_resource_handler.cc @@ -9,6 +9,7 @@ #include "net/base/mime_sniffer.h" #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" +#include "chrome/common/url_constants.h" #include "net/base/mime_sniffer.h" #include "net/base/io_buffer.h" #include "net/http/http_response_headers.h" @@ -164,8 +165,8 @@ bool BufferedResourceHandler::ShouldBuffer(const GURL& url, const std::string& mime_type) { // We are willing to buffer for HTTP and HTTPS. bool sniffable_scheme = url.is_empty() || - url.SchemeIs("http") || - url.SchemeIs("https"); + url.SchemeIs(chrome::kHttpScheme) || + url.SchemeIs(chrome::kHttpsScheme); if (!sniffable_scheme) return false; diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 0af9211..5e644c2 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -28,6 +28,7 @@ #include "chrome/common/resource_bundle.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" +#include "chrome/common/url_constants.h" #include "chrome/common/thumbnail_score.h" #include "net/base/net_util.h" #include "skia/include/SkBitmap.h" @@ -41,10 +42,10 @@ void FilterURL(RendererSecurityPolicy* policy, int renderer_id, GURL* url) { if (!url->is_valid()) return; // We don't need to block invalid URLs. - if (url->SchemeIs("about")) { + if (url->SchemeIs(chrome::kAboutScheme)) { // The renderer treats all URLs in the about: scheme as being about:blank. // Canonicalize about: URLs to about:blank. - *url = GURL("about:blank"); + *url = GURL(chrome::kAboutBlankURL); } if (!policy->CanRequestURL(renderer_id, *url)) { diff --git a/chrome/browser/renderer_host/renderer_security_policy.cc b/chrome/browser/renderer_host/renderer_security_policy.cc index 71a71ec..e33b0d1 100644 --- a/chrome/browser/renderer_host/renderer_security_policy.cc +++ b/chrome/browser/renderer_host/renderer_security_policy.cc @@ -78,10 +78,10 @@ class RendererSecurityPolicy::SecurityState { RendererSecurityPolicy::RendererSecurityPolicy() { // We know about these schemes and believe them to be safe. - RegisterWebSafeScheme("http"); - RegisterWebSafeScheme("https"); - RegisterWebSafeScheme("ftp"); - RegisterWebSafeScheme("data"); + RegisterWebSafeScheme(chrome::kHttpScheme); + RegisterWebSafeScheme(chrome::kHttpsScheme); + RegisterWebSafeScheme(chrome::kFtpScheme); + RegisterWebSafeScheme(chrome::kDataScheme); RegisterWebSafeScheme("feed"); RegisterWebSafeScheme("chrome-extension"); @@ -156,7 +156,7 @@ void RendererSecurityPolicy::GrantRequestURL(int renderer_id, const GURL& url) { if (IsPseudoScheme(url.scheme())) { // The view-source scheme is a special case of a pseudo URL that eventually // results in requesting its embedded URL. - if (url.SchemeIs("view-source")) { + if (url.SchemeIs(chrome::kViewSourceScheme)) { // URLs with the view-source scheme typically look like: // view-source:http://www.google.com/a // In order to request these URLs, the renderer needs to be able to request @@ -199,7 +199,7 @@ void RendererSecurityPolicy::GrantInspectElement(int renderer_id) { // The inspector is served from a chrome-ui: URL. In order to run the // inspector, the renderer needs to be able to load chrome-ui URLs. - state->second->GrantScheme("chrome-ui"); + state->second->GrantScheme(chrome::kChromeUIScheme); } void RendererSecurityPolicy::GrantDOMUIBindings(int renderer_id) { @@ -212,10 +212,10 @@ void RendererSecurityPolicy::GrantDOMUIBindings(int renderer_id) { state->second->GrantDOMUIBindings(); // DOM UI bindings need the ability to request chrome-ui URLs. - state->second->GrantScheme("chrome-ui"); + state->second->GrantScheme(chrome::kChromeUIScheme); // DOM UI pages can contain links to file:// URLs. - state->second->GrantScheme("file"); + state->second->GrantScheme(chrome::kFileScheme); } bool RendererSecurityPolicy::CanRequestURL(int renderer_id, const GURL& url) { @@ -228,13 +228,13 @@ bool RendererSecurityPolicy::CanRequestURL(int renderer_id, const GURL& url) { if (IsPseudoScheme(url.scheme())) { // There are a number of special cases for pseudo schemes. - if (url.SchemeIs("view-source")) { + if (url.SchemeIs(chrome::kViewSourceScheme)) { // A view-source URL is allowed if the renderer is permitted to request // the embedded URL. return CanRequestURL(renderer_id, GURL(url.path())); } - if (LowerCaseEqualsASCII(url.spec(), "about:blank")) + if (LowerCaseEqualsASCII(url.spec(), chrome::kAboutBlankURL)) return true; // Every renderer can request <about:blank>. // URLs like <about:memory> and <about:crash> shouldn't be requestable by |