diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-14 20:51:04 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-14 20:51:04 +0000 |
commit | 13c34d1395636e081be2318e8ae12bc8fa71ca57 (patch) | |
tree | 4a719a69338f1cc14fe23db88e061c513cf122db /chrome/browser/browser_about_handler.cc | |
parent | 1364d8b89dd74afd35a5d9fe4bb4f3c66d09c3c4 (diff) | |
download | chromium_src-13c34d1395636e081be2318e8ae12bc8fa71ca57.zip chromium_src-13c34d1395636e081be2318e8ae12bc8fa71ca57.tar.gz chromium_src-13c34d1395636e081be2318e8ae12bc8fa71ca57.tar.bz2 |
Change the URLs used to access "view-cache:" and "view-net-internals:".
"net-internal:*" ==> "chrome://net-internals/*"
"view-cache:*" ==> "chrome://net-internals/view-cache/*"
"view-cache:stats" ==> "chrome://net-internals/httpcache.stats"
As before, there are also aliases from the "about:*" page:
"about:net-internal[/*]" aliases "chrome://net-internals/*"
"about:cache[/*]" aliases "chrome://net-internals/view-cache"
BUG=http://crbug.com/21551
Review URL: http://codereview.chromium.org/202067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_about_handler.cc')
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 047ca97..3e4baf3 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -759,6 +759,23 @@ void ChromeOSAboutVersionHandler::OnVersion( #endif +// Returns true if |url|'s spec starts with |about_specifier|, and is +// terminated by the start of a path. +bool StartsWithAboutSpecifier(const GURL& url, const char* about_specifier) { + return StartsWithASCII(url.spec(), about_specifier, true) && + (url.spec().size() == strlen(about_specifier) || + url.spec()[strlen(about_specifier)] == '/'); +} + +// Transforms a URL of the form "about:foo/XXX" to <url_prefix> + "XXX". +GURL RemapAboutURL(const std::string& url_prefix, const GURL& url) { + std::string path; + size_t split = url.spec().find('/'); + if (split != std::string::npos) + path = url.spec().substr(split + 1); + return GURL(url_prefix + path); +} + } // namespace // ----------------------------------------------------------------------------- @@ -774,23 +791,16 @@ bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) { if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBlankURL)) return false; - // Handle rewriting view-cache URLs. This allows us to load about:cache. - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutCacheURL)) { - // Create an mapping from about:cache to the view-cache: internal URL. - *url = GURL(std::string(chrome::kViewCacheScheme) + ":"); + // Rewrite about:cache/* URLs to chrome://net-internals/view-cache/* + if (StartsWithAboutSpecifier(*url, chrome::kAboutCacheURL)) { + *url = RemapAboutURL(chrome::kNetworkViewCacheURL + std::string("/"), + *url); return true; } - // Handle rewriting net-internal URLs. This allows us to load - // about:net-internal. - if (StartsWithASCII(url->spec(), chrome::kAboutNetInternalURL, true)) { - // Create a mapping from about:net-internal to the view-net-internal: - // internal URL. - std::string path; - size_t split = url->spec().find('/'); - if (split != std::string::npos) - path = url->spec().substr(split + 1); - *url = GURL(std::string(chrome::kViewNetInternalScheme) + ":" + path); + // Rewrite about:net-internals/* URLs to chrome://net-internals/* + if (StartsWithAboutSpecifier(*url, chrome::kAboutNetInternalsURL)) { + *url = RemapAboutURL(chrome::kNetworkViewInternalsURL, *url); return true; } |