diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 18:34:03 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 18:34:03 +0000 |
commit | 89f550b854228a6414d017c9186e3e8540b69e13 (patch) | |
tree | 863139cb1cfeeeeeebbfb48b729373ce4c12f112 /chrome/browser | |
parent | 56283961a67c5beb667589a547adf3d94db018e9 (diff) | |
download | chromium_src-89f550b854228a6414d017c9186e3e8540b69e13.zip chromium_src-89f550b854228a6414d017c9186e3e8540b69e13.tar.gz chromium_src-89f550b854228a6414d017c9186e3e8540b69e13.tar.bz2 |
*Fixup about and chrome scheme URLs in URLFixerUpper::FixupURL.
*Update AboutSource to use the source_name of each about/chrome page.
*Make WillHandleBrowserAboutURL fix up schemes and handle chrome://foo/
-Redirect memory to memory-redirect (wasn't handling chrome://memory/).
-Catalog all kChromeUI*Hosts in url_constants.cc
-Simplify paths (credits, os-credits, ipc, settings, about/version).
-Nix web_ui_util::ChromeURLHostEquals (use scheme & host comparison).
-Favor GURL::SchemeIs and url_constants, update & expand tests.
-Add and fixup chrome://chrome-urls (the about:about page).
-Update special_tabs.py from Nirnimesh's codereview.chromium.org/6995057/.
This change was reverted with r88166 for sync_integration_tests failures.
These failures are a tangential issue, crbug.com/85294; I'll re-land this soon.
BUG=55771
TEST=Access about:, about://, chrome:, chrome:// pages.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=88142
Review URL: http://codereview.chromium.org/7068007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
34 files changed, 391 insertions, 452 deletions
diff --git a/chrome/browser/accessibility/accessibility_win_browsertest.cc b/chrome/browser/accessibility/accessibility_win_browsertest.cc index 16e12e2..19bb413 100644 --- a/chrome/browser/accessibility/accessibility_win_browsertest.cc +++ b/chrome/browser/accessibility/accessibility_win_browsertest.cc @@ -11,6 +11,7 @@ #include "chrome/browser/renderer_host/render_widget_host_view_win.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" +#include "chrome/common/url_constants.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" #include "content/browser/renderer_host/render_view_host.h" @@ -370,8 +371,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, EXPECT_NE(parent_dispatch, reinterpret_cast<IDispatch*>(NULL)); // Navigate to another page. - GURL about_url("about:"); - ui_test_utils::NavigateToURL(browser(), about_url); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIVersionURL)); // Verify that the IAccessible reference still points to a valid object and // that calls to its methods fail since the tree is no longer valid after diff --git a/chrome/browser/autocomplete/builtin_provider.cc b/chrome/browser/autocomplete/builtin_provider.cc index 96843cf..507d9ed 100644 --- a/chrome/browser/autocomplete/builtin_provider.cc +++ b/chrome/browser/autocomplete/builtin_provider.cc @@ -15,7 +15,7 @@ const int BuiltinProvider::kRelevance = 575; BuiltinProvider::BuiltinProvider(ACProviderListener* listener, Profile* profile) : AutocompleteProvider(listener, profile, "Builtin") { - std::vector<std::string> builtins(AboutPaths()); + std::vector<std::string> builtins(ChromePaths()); for (std::vector<std::string>::iterator i(builtins.begin()); i != builtins.end(); ++i) builtins_.push_back(ASCIIToUTF16("about:") + ASCIIToUTF16(*i)); diff --git a/chrome/browser/automation/automation_tab_helper_browsertest.cc b/chrome/browser/automation/automation_tab_helper_browsertest.cc index 2bc1f17..9e87089 100644 --- a/chrome/browser/automation/automation_tab_helper_browsertest.cc +++ b/chrome/browser/automation/automation_tab_helper_browsertest.cc @@ -206,5 +206,5 @@ IN_PROC_BROWSER_TEST_F(AutomationTabHelperBrowserTest, EXPECT_CALL(mock_tab_observer, OnFirstPendingLoad(_)); EXPECT_CALL(mock_tab_observer, OnNoMorePendingLoads(_)); - ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutCrashURL)); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL)); } diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 0ae9771..f26d0b1 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -31,6 +31,7 @@ #include "chrome/browser/memory_details.h" #include "chrome/browser/metrics/histogram_synchronizer.h" #include "chrome/browser/net/predictor_api.h" +#include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -102,107 +103,93 @@ void AboutTcmallocRendererCallback(base::ProcessId pid, namespace { -// The (alphabetized) paths used for the about pages. -// Note: Keep these in sync with url_constants.h -const char kAppCacheInternalsPath[] = "appcache-internals"; -const char kBlobInternalsPath[] = "blob-internals"; -const char kCreditsPath[] = "credits"; -const char kCachePath[] = "view-http-cache"; +// Add paths here to be included in chrome://chrome-urls/. +// These paths will also be suggested by BuiltinProvider. +const char *kChromePaths[] = { + chrome::kChromeUIAppCacheInternalsHost, + chrome::kChromeUIBlobInternalsHost, + chrome::kChromeUIChromeURLsHost, + chrome::kChromeUICreditsHost, + chrome::kChromeUIDNSHost, + chrome::kChromeUIFlagsHost, + chrome::kChromeUIFlashHost, + chrome::kChromeUIGpuInternalsHost, + chrome::kChromeUIHistogramsHost, + chrome::kChromeUIMemoryHost, + chrome::kChromeUINetInternalsHost, + chrome::kChromeUINetworkViewCacheHost, + chrome::kChromeUIPluginsHost, + chrome::kChromeUIStatsHost, + chrome::kChromeUISyncInternalsHost, + chrome::kChromeUITCMallocHost, + chrome::kChromeUITermsHost, + chrome::kChromeUIVersionHost, +#ifdef TRACK_ALL_TASK_OBJECTS + chrome::kChromeUITasksHost, +#endif #if defined(OS_WIN) -const char kConflictsPath[] = "conflicts"; + chrome::kChromeUIConflictsHost, #endif -const char kDnsPath[] = "dns"; -const char kFlagsPath[] = "flags"; -const char kFlashPath[] = "flash"; -const char kGpuPath[] = "gpu-internals"; -const char kHistogramsPath[] = "histograms"; -const char kMemoryRedirectPath[] = "memory-redirect"; -const char kMemoryPath[] = "memory"; -const char kStatsPath[] = "stats"; -const char kTasksPath[] = "tasks"; -const char kTcmallocPath[] = "tcmalloc"; -const char kTermsPath[] = "terms"; -const char kVersionPath[] = "version"; -const char kAboutPath[] = "about"; -// Not about:* pages, but included to make about:about look nicer -const char kNetInternalsPath[] = "net-internals"; -const char kPluginsPath[] = "plugins"; -const char kSyncInternalsPath[] = "sync-internals"; - #if defined(OS_LINUX) -const char kLinuxProxyConfigPath[] = "linux-proxy-config"; -const char kSandboxPath[] = "sandbox"; + chrome::kChromeUISandboxHost, #endif - #if defined(OS_CHROMEOS) -const char kNetworkPath[] = "network"; -const char kOSCreditsPath[] = "os-credits"; -const char kEULAPathFormat[] = "/usr/share/chromeos-assets/eula/%s/eula.html"; + chrome::kChromeUINetworkHost, + chrome::kChromeUIOSCreditsHost, #endif +}; -// Add path here to be included in about:about -const char *kAllAboutPaths[] = { - kAboutPath, - kAppCacheInternalsPath, - kBlobInternalsPath, - kCachePath, - kCreditsPath, -#if defined(OS_WIN) - kConflictsPath, -#endif - kDnsPath, - kFlagsPath, - kFlashPath, - kGpuPath, - kHistogramsPath, - kMemoryPath, - kNetInternalsPath, - kPluginsPath, - kStatsPath, - kSyncInternalsPath, +// Debug paths, presented without links in chrome://about. +// These paths will not be suggested by BuiltinProvider. +const char *kDebugChromePaths[] = { + chrome::kChromeUICrashHost, + chrome::kChromeUIKillHost, + chrome::kChromeUIHangHost, + chrome::kChromeUIShorthangHost, + chrome::kChromeUIGpuCleanHost, + chrome::kChromeUIGpuCrashHost, + chrome::kChromeUIGpuHangHost +}; + +// AboutSource handles these chrome:// paths. +const char *kAboutSourceNames[] = { + chrome::kChromeUIChromeURLsHost, + chrome::kChromeUICreditsHost, + chrome::kChromeUIDNSHost, + chrome::kChromeUIHistogramsHost, + chrome::kChromeUIMemoryHost, + chrome::kChromeUIMemoryRedirectHost, + chrome::kChromeUIStatsHost, + chrome::kChromeUITermsHost, + chrome::kChromeUIVersionHost, #ifdef TRACK_ALL_TASK_OBJECTS - kTasksPath, -#endif // TRACK_ALL_TASK_OBJECTS - kTcmallocPath, - kTermsPath, - kVersionPath, + chrome::kChromeUITasksHost, +#endif +#if defined(USE_TCMALLOC) + chrome::kChromeUITCMallocHost, +#endif #if defined(OS_LINUX) - kSandboxPath, + chrome::kChromeUILinuxProxyConfigHost, + chrome::kChromeUISandboxHost, #endif #if defined(OS_CHROMEOS) - kNetworkPath, - kOSCreditsPath, + chrome::kChromeUINetworkHost, + chrome::kChromeUIOSCreditsHost, #endif - }; - -// When you type about:memory, it actually loads an intermediate URL that -// redirects you to the final page. This avoids the problem where typing -// "about:memory" on the new tab page or any other page where a process -// transition would occur to the about URL will cause some confusion. -// -// The problem is that during the processing of the memory page, there are two -// processes active, the original and the destination one. This can create the -// impression that we're using more resources than we actually are. This -// redirect solves the problem by eliminating the process transition during the -// time that about memory is being computed. -std::string GetAboutMemoryRedirectResponse() { - return "<meta http-equiv=\"refresh\" " - "content=\"0;chrome://about/memory\">"; -} +}; class AboutSource : public ChromeURLDataManager::DataSource { public: - // Creates our datasource. - AboutSource(); - explicit AboutSource(Profile* profile); + // Construct a data source for the specified |source_name|. + AboutSource(const std::string& source_name, Profile* profile); // Called when the network layer has requested a resource underneath // the path we registered. virtual void StartDataRequest(const std::string& path, bool is_incognito, - int request_id); + int request_id) OVERRIDE; - virtual std::string GetMimeType(const std::string&) const { + virtual std::string GetMimeType(const std::string&) const OVERRIDE { return "text/html"; } @@ -219,14 +206,43 @@ class AboutSource : public ChromeURLDataManager::DataSource { DISALLOW_COPY_AND_ASSIGN(AboutSource); }; +// Register a data source for a known source name. Safe to call multiple times. +// |name| may be an unkown host (e.g. "chrome://foo/"); only handle known hosts. +void InitializeAboutDataSource(const std::string& name, Profile* profile) { + ChromeURLDataManager* manager = profile->GetChromeURLDataManager(); + for (size_t i = 0; i < arraysize(kAboutSourceNames); i++) { + if (name == kAboutSourceNames[i]) { + manager->AddDataSource(new AboutSource(name, profile)); + return; + } + } +} + +// When you type about:memory, it actually loads this intermediate URL that +// redirects you to the final page. This avoids the problem where typing +// "about:memory" on the new tab page or any other page where a process +// transition would occur to the about URL will cause some confusion. +// +// The problem is that during the processing of the memory page, there are two +// processes active, the original and the destination one. This can create the +// impression that we're using more resources than we actually are. This +// redirect solves the problem by eliminating the process transition during the +// time that about memory is being computed. +std::string GetAboutMemoryRedirectResponse(Profile* profile) { + InitializeAboutDataSource(chrome::kChromeUIMemoryRedirectHost, profile); + return StringPrintf("<meta http-equiv=\"refresh\" content=\"0;%s\">", + chrome::kChromeUIMemoryRedirectURL); +} + // Handling about:memory is complicated enough to encapsulate its related // methods into a single class. The user should create it (on the heap) and call // its |StartFetch()| method. class AboutMemoryHandler : public MemoryDetails { public: AboutMemoryHandler(AboutSource* source, int request_id) - : source_(source), request_id_(request_id) {} - + : source_(source), + request_id_(request_id) { + } virtual void OnDetailsAvailable(); @@ -297,10 +313,10 @@ class ChromeOSTermsHandler void LoadFileOnFileThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - std::string path = StringPrintf(kEULAPathFormat, locale_.c_str()); + std::string path = StringPrintf(chrome::kEULAPathFormat, locale_.c_str()); if (!file_util::ReadFileToString(FilePath(path), &contents_)) { // No EULA for given language - try en-US as default. - path = StringPrintf(kEULAPathFormat, "en-US"); + path = StringPrintf(chrome::kEULAPathFormat, "en-US"); if (!file_util::ReadFileToString(FilePath(path), &contents_)) { // File with EULA not found, ResponseOnUIThread will load EULA from // resources if contents_ is empty. @@ -338,36 +354,19 @@ class ChromeOSTermsHandler // Individual about handlers --------------------------------------------------- -std::string AboutAbout() { - std::string html("<html><head><title>About Pages</title></head>\n" - "<body><h2>List of About pages</h2>\n<ul>"); - std::vector<std::string> paths(AboutPaths()); +std::string ChromeURLs() { + std::string html("<html><head><title>Chrome URLs</title></head>\n" + "<body><h2>List of Chrome URLs</h2>\n<ul>"); + std::vector<std::string> paths(ChromePaths()); for (std::vector<std::string>::const_iterator i = paths.begin(); - i != paths.end(); ++i) { - html += "<li><a href='chrome://"; - if ((*i != kAppCacheInternalsPath) && - (*i != kBlobInternalsPath) && - (*i != kCachePath) && - #if defined(OS_WIN) - (*i != kConflictsPath) && - #endif - (*i != kFlagsPath) && - (*i != kFlashPath) && - (*i != kGpuPath) && - (*i != kNetInternalsPath) && - (*i != kPluginsPath)) { - html += "about/"; - } - html += *i + "/'>about:" + *i + "</a></li>\n"; - } - const char *debug[] = { "crash", "kill", "hang", "shorthang", - "gpuclean", "gpucrash", "gpuhang" }; + i != paths.end(); ++i) + html += "<li><a href='chrome://" + *i + "/'>chrome://" + *i + "</a></li>\n"; html += "</ul>\n<h2>For Debug</h2>\n" "<p>The following pages are for debugging purposes only. Because they " "crash or hang the renderer, they're not linked directly; you can type " "them into the address bar if you need them.</p>\n<ul>"; - for (size_t i = 0; i < arraysize(debug); i++) - html += "<li>about:" + std::string(debug[i]) + "</li>\n"; + for (size_t i = 0; i < arraysize(kDebugChromePaths); i++) + html += "<li>chrome://" + std::string(kDebugChromePaths[i]) + "</li>\n"; html += "</ul>\n</body></html>"; return html; } @@ -600,7 +599,7 @@ class AboutDnsHandler : public base::RefCountedThreadSafe<AboutDnsHandler> { }; #if defined(USE_TCMALLOC) -std::string AboutTcmalloc(const std::string& query) { +std::string AboutTcmalloc() { std::string data; AboutTcmallocOutputsType* outputs = AboutTcmallocOutputs::GetInstance()->outputs(); @@ -1020,51 +1019,40 @@ std::string AboutVersion(DictionaryValue* localized_strings, Profile* profile) { // AboutSource ----------------------------------------------------------------- -AboutSource::AboutSource() - : DataSource(chrome::kAboutScheme, MessageLoop::current()) { -} - -AboutSource::AboutSource(Profile* profile) - : DataSource(chrome::kAboutScheme, MessageLoop::current()), +AboutSource::AboutSource(const std::string& source_name, Profile* profile) + : DataSource(source_name, MessageLoop::current()), profile_(profile) { } AboutSource::~AboutSource() { } -void AboutSource::StartDataRequest(const std::string& path_raw, - bool is_incognito, int request_id) { - std::string path = path_raw; - std::string info; - if (path.find("/") != std::string::npos) { - size_t pos = path.find("/"); - info = path.substr(pos + 1, path.length() - (pos + 1)); - path = path.substr(0, pos); - } - path = StringToLowerASCII(path); - +void AboutSource::StartDataRequest(const std::string& path, + bool is_incognito, + int request_id) { std::string response; - if (path == kDnsPath) { + std::string host = source_name(); + if (host == chrome::kChromeUIDNSHost) { AboutDnsHandler::Start(this, request_id); return; - } else if (path == kHistogramsPath) { - response = AboutHistograms(info); - } else if (path == kMemoryPath) { + } else if (host == chrome::kChromeUIHistogramsHost) { + response = AboutHistograms(path); + } else if (host == chrome::kChromeUIMemoryHost) { + response = GetAboutMemoryRedirectResponse(profile()); + } else if (host == chrome::kChromeUIMemoryRedirectHost) { AboutMemory(this, request_id); return; - } else if (path == kMemoryRedirectPath) { - response = GetAboutMemoryRedirectResponse(); #ifdef TRACK_ALL_TASK_OBJECTS - } else if (path == kTasksPath) { - response = AboutObjects(info); + } else if (host == chrome::kChromeUITasksHost) { + response = AboutObjects(path); #endif - } else if (path == kStatsPath) { - response = AboutStats(info); + } else if (host == chrome::kChromeUIStatsHost) { + response = AboutStats(path); #if defined(USE_TCMALLOC) - } else if (path == kTcmallocPath) { - response = AboutTcmalloc(info); + } else if (host == chrome::kChromeUITCMallocHost) { + response = AboutTcmalloc(); #endif - } else if (path == kVersionPath || path.empty()) { + } else if (host == chrome::kChromeUIVersionHost) { #if defined(OS_CHROMEOS) new ChromeOSAboutVersionHandler(this, request_id); return; @@ -1073,19 +1061,19 @@ void AboutSource::StartDataRequest(const std::string& path_raw, localized_strings.SetString("os_version", ""); response = AboutVersion(&localized_strings, profile_); #endif - } else if (path == kCreditsPath) { + } else if (host == chrome::kChromeUICreditsHost) { response = ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_CREDITS_HTML).as_string(); - } else if (path == kAboutPath) { - response = AboutAbout(); + } else if (host == chrome::kChromeUIChromeURLsHost) { + response = ChromeURLs(); #if defined(OS_CHROMEOS) - } else if (path == kOSCreditsPath) { + } else if (host == chrome::kChromeUIOSCreditsHost) { response = ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_OS_CREDITS_HTML).as_string(); - } else if (path == kNetworkPath) { - response = AboutNetwork(info); + } else if (host == chrome::kChromeUINetworkHost) { + response = AboutNetwork(path); #endif - } else if (path == kTermsPath) { + } else if (host == chrome::kChromeUITermsHost) { #if defined(OS_CHROMEOS) ChromeOSTermsHandler::Start(this, request_id); return; @@ -1094,9 +1082,9 @@ void AboutSource::StartDataRequest(const std::string& path_raw, IDR_TERMS_HTML).as_string(); #endif #if defined(OS_LINUX) - } else if (path == kLinuxProxyConfigPath) { + } else if (host == chrome::kChromeUILinuxProxyConfigHost) { response = AboutLinuxProxyConfig(); - } else if (path == kSandboxPath) { + } else if (host == chrome::kChromeUISandboxHost) { response = AboutSandbox(); #endif } @@ -1104,11 +1092,10 @@ void AboutSource::StartDataRequest(const std::string& path_raw, FinishDataRequest(response, request_id); } -void AboutSource::FinishDataRequest(const std::string& response, - int request_id) { +void AboutSource::FinishDataRequest(const std::string& html, int request_id) { scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); - html_bytes->data.resize(response.size()); - std::copy(response.begin(), response.end(), html_bytes->data.begin()); + html_bytes->data.resize(html.size()); + std::copy(html.begin(), html.end(), html_bytes->data.begin()); SendResponse(request_id, html_bytes); } @@ -1272,152 +1259,71 @@ 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 // ----------------------------------------------------------------------------- bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) { - // We only handle about: schemes. - if (!url->SchemeIs(chrome::kAboutScheme)) - return false; - - // about:blank is special. Frames are allowed to access about:blank, - // but they are not allowed to access other types of about pages. - // Just ignore the about:blank and let the TAB_CONTENTS_WEB handle it. - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBlankURL)) - return false; - - // Rewrite about:cache/* URLs to chrome://view-http-cache/* - if (StartsWithAboutSpecifier(*url, chrome::kAboutCacheURL)) { - *url = RemapAboutURL(chrome::kNetworkViewCacheURL, *url); - return true; - } - -#if defined(OS_WIN) - // Rewrite about:conflicts/* URLs to chrome://conflicts/* - if (StartsWithAboutSpecifier(*url, chrome::kAboutConflicts)) { - *url = GURL(chrome::kChromeUIConflictsURL); - return true; - } -#endif - - // Rewrite about:flags to chrome://flags/. - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutFlagsURL)) { - *url = GURL(chrome::kChromeUIFlagsURL); - return true; - } - - // Rewrite about:flash to chrome://flash/. - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutFlashURL)) { - *url = GURL(chrome::kChromeUIFlashURL); - return true; - } - - // Rewrite about:net-internals/* URLs to chrome://net-internals/* - if (StartsWithAboutSpecifier(*url, chrome::kAboutNetInternalsURL)) { - *url = RemapAboutURL(chrome::kNetworkViewInternalsURL, *url); - return true; - } - - // Rewrite about:gpu/* URLs to chrome://gpu-internals/* - if (StartsWithAboutSpecifier(*url, chrome::kAboutGpuURL)) { - *url = RemapAboutURL(chrome::kGpuInternalsURL, *url); - return true; - } + // TODO(msw): Eliminate "about:*" constants and literals from code and tests, + // then hopefully we can remove this forced fixup. + *url = URLFixerUpper::FixupURL(url->possibly_invalid_spec(), std::string()); - // Rewrite about:appcache-internals/* URLs to chrome://appcache/* - if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { - *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); - return true; - } + // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. + DCHECK((*url == GURL(chrome::kAboutBlankURL)) || + !url->SchemeIs(chrome::kAboutScheme)); - // Rewrite about:sync-internals/* URLs (and about:sync, too, for - // legacy reasons) to chrome://sync-internals/* - if (StartsWithAboutSpecifier(*url, chrome::kAboutSyncInternalsURL) || - StartsWithAboutSpecifier(*url, chrome::kAboutSyncURL)) { - *url = RemapAboutURL(chrome::kSyncViewInternalsURL, *url); - return true; - } + // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. + // TAB_CONTENTS_WEB handles about:blank, which frames are allowed to access. + if (!url->SchemeIs(chrome::kChromeUIScheme)) + return false; - // Rewrite about:plugins to chrome://plugins/. - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutPluginsURL)) { - *url = GURL(chrome::kChromeUIPluginsURL); - return true; - } + // Circumvent processing URLs that the renderer process will handle. + if (chrome_about_handler::WillHandle(*url)) + return false; - // Handle URL to crash the browser process. - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBrowserCrash)) { + std::string host(url->host()); + // Replace about with chrome-urls. + if (host == chrome::kChromeUIAboutHost) + host = chrome::kChromeUIChromeURLsHost; + // Replace cache with view-http-cache. + if (host == chrome::kChromeUICacheHost) + host = chrome::kChromeUINetworkViewCacheHost; + // Replace gpu with gpu-internals. + else if (host == chrome::kChromeUIGpuHost) + host = chrome::kChromeUIGpuInternalsHost; + // Replace sync with sync-internals (for legacy reasons). + else if (host == chrome::kChromeUISyncHost) + host = chrome::kChromeUISyncInternalsHost; + GURL::Replacements replacements; + replacements.SetHostStr(host); + *url = url->ReplaceComponents(replacements); + + // Handle URLs to crash the browser or wreck the gpu process. + if (host == chrome::kChromeUIBrowserCrashHost) { // Induce an intentional crash in the browser process. - int* bad_pointer = NULL; - *bad_pointer = 42; - return true; - } - - // Handle URLs to wreck the gpu process. - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuCleanURL)) { + CHECK(false); + } else if (host == chrome::kChromeUIGpuCleanHost) { GpuProcessHost::SendOnIO( 0, content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, new GpuMsg_Clean()); - } - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuCrashURL)) { + } else if (host == chrome::kChromeUIGpuCrashHost) { GpuProcessHost::SendOnIO( 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUCRASH, new GpuMsg_Crash()); - } - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuHangURL)) { + } else if (host == chrome::kChromeUIGpuHangHost) { GpuProcessHost::SendOnIO( 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUHANG, new GpuMsg_Hang()); } - // There are a few about: URLs that we hand over to the renderer. If the - // renderer wants them, don't do any rewriting. - if (chrome_about_handler::WillHandle(*url)) - return false; - - // Anything else requires our special handler; make sure it's initialized. - InitializeAboutDataSource(profile); - - // Special case about:memory to go through a redirect before ending up on - // the final page. See GetAboutMemoryRedirectResponse above for why. - if (LowerCaseEqualsASCII(url->path(), kMemoryPath)) { - *url = GURL("chrome://about/memory-redirect"); - return true; - } - - // Rewrite the about URL to use chrome:. WebKit treats all about URLS the - // same (blank page), so if we want to display content, we need another - // scheme. - std::string about_url = "chrome://about/"; - about_url.append(url->path()); - *url = GURL(about_url); + // Initialize any potentially corresponding AboutSource handler. + InitializeAboutDataSource(host, profile); return true; } -void InitializeAboutDataSource(Profile* profile) { - profile->GetChromeURLDataManager()->AddDataSource(new AboutSource(profile)); -} - bool HandleNonNavigationAboutURL(const GURL& url) { - // about:ipc is currently buggy, so we disable it for official builds. + // chrome://ipc/ is currently buggy, so we disable it for official builds. #if !defined(OFFICIAL_BUILD) #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED) - if (LowerCaseEqualsASCII(url.spec(), chrome::kAboutIPCURL)) { + if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { // Run the dialog. This will re-use the existing one if it's already up. browser::ShowAboutIPCDialog(); return true; @@ -1429,10 +1335,10 @@ bool HandleNonNavigationAboutURL(const GURL& url) { return false; } -std::vector<std::string> AboutPaths() { +std::vector<std::string> ChromePaths() { std::vector<std::string> paths; - paths.reserve(arraysize(kAllAboutPaths)); - for (size_t i = 0; i < arraysize(kAllAboutPaths); i++) - paths.push_back(kAllAboutPaths[i]); + paths.reserve(arraysize(kChromePaths)); + for (size_t i = 0; i < arraysize(kChromePaths); i++) + paths.push_back(kChromePaths[i]); return paths; } diff --git a/chrome/browser/browser_about_handler.h b/chrome/browser/browser_about_handler.h index caaeba3..5fa8051 100644 --- a/chrome/browser/browser_about_handler.h +++ b/chrome/browser/browser_about_handler.h @@ -19,25 +19,21 @@ template <typename T> struct DefaultSingletonTraits; class GURL; class Profile; -// Decides whether the given URL will be handled by the browser about handler -// and returns true if so. On true, it may also modify the given URL to be the -// final form (we fix up most "about:" URLs to be "chrome:" because WebKit -// handles all "about:" URLs as "about:blank. +// Returns true if the given URL will be handled by the browser about handler. +// |url| should have been processed by URLFixerUpper::FixupURL, which replaces +// the about: scheme with chrome:// for all about:foo URLs except "about:blank". +// Some |url| host values will be replaced with their respective redirects. // // This is used by BrowserURLHandler. bool WillHandleBrowserAboutURL(GURL* url, Profile* profile); -// Register the data source for chrome://about URLs. -// Safe to call multiple times. -void InitializeAboutDataSource(Profile* profile); - // We have a few magic commands that don't cause navigations, but rather pop up // dialogs. This function handles those cases, and returns true if so. In this // case, normal tab navigation should be skipped. bool HandleNonNavigationAboutURL(const GURL& url); -// Gets the paths that are shown in about:about. -std::vector<std::string> AboutPaths(); +// Gets the paths that are shown in chrome://chrome-urls. +std::vector<std::string> ChromePaths(); #if defined(USE_TCMALLOC) // A map of header strings (e.g. "Browser", "Renderer PID 123") diff --git a/chrome/browser/browser_about_handler_unittest.cc b/chrome/browser/browser_about_handler_unittest.cc index 9b30550..064e807 100644 --- a/chrome/browser/browser_about_handler_unittest.cc +++ b/chrome/browser/browser_about_handler_unittest.cc @@ -16,6 +16,8 @@ typedef TestingBrowserProcessTest BrowserAboutHandlerTest; TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { + std::string chrome_prefix(chrome::kChromeUIScheme); + chrome_prefix.append(chrome::kStandardSchemeSeparator); struct AboutURLTestData { GURL test_url; GURL result_url; @@ -35,71 +37,71 @@ TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { false }, { - GURL(std::string(chrome::kAboutCacheURL) + "/mercury"), - GURL(std::string(chrome::kNetworkViewCacheURL) + "mercury"), - false, - true + GURL(chrome_prefix + chrome::kChromeUICrashHost), + GURL(chrome_prefix + chrome::kChromeUICrashHost), + true, + false }, { - GURL(std::string(chrome::kAboutNetInternalsURL) + "/venus"), - GURL(std::string(chrome::kNetworkViewInternalsURL) + "venus"), - false, - true + GURL(chrome_prefix + chrome::kChromeUIKillHost), + GURL(chrome_prefix + chrome::kChromeUIKillHost), + true, + false }, { - GURL(std::string(chrome::kAboutGpuURL) + "/jupiter"), - GURL(std::string(chrome::kGpuInternalsURL) + "jupiter"), - false, - true + GURL(chrome_prefix + chrome::kChromeUIHangHost), + GURL(chrome_prefix + chrome::kChromeUIHangHost), + true, + false }, { - GURL(std::string(chrome::kAboutAppCacheInternalsURL) + "/earth"), - GURL(std::string(chrome::kAppCacheViewInternalsURL) + "earth"), - false, - true + GURL(chrome_prefix + chrome::kChromeUIShorthangHost), + GURL(chrome_prefix + chrome::kChromeUIShorthangHost), + true, + false }, { - GURL(chrome::kAboutPluginsURL), - GURL(chrome::kChromeUIPluginsURL), + GURL(chrome_prefix + chrome::kChromeUIMemoryHost), + GURL(chrome_prefix + chrome::kChromeUIMemoryHost), false, true }, { - GURL(chrome::kAboutCrashURL), - GURL(chrome::kAboutCrashURL), - true, - false + GURL(chrome_prefix + chrome::kChromeUIDefaultHost), + GURL(chrome_prefix + chrome::kChromeUIVersionHost), + false, + true }, { - GURL(chrome::kAboutKillURL), - GURL(chrome::kAboutKillURL), - true, - false + GURL(chrome_prefix + chrome::kChromeUIAboutHost), + GURL(chrome_prefix + chrome::kChromeUIChromeURLsHost), + false, + true }, { - GURL(chrome::kAboutHangURL), - GURL(chrome::kAboutHangURL), - true, - false + GURL(chrome_prefix + chrome::kChromeUICacheHost), + GURL(chrome_prefix + chrome::kChromeUINetworkViewCacheHost), + false, + true }, { - GURL(chrome::kAboutShorthangURL), - GURL(chrome::kAboutShorthangURL), - true, - false + GURL(chrome_prefix + chrome::kChromeUIGpuHost), + GURL(chrome_prefix + chrome::kChromeUIGpuInternalsHost), + false, + true }, { - GURL("about:memory"), - GURL("chrome://about/memory-redirect"), + GURL(chrome_prefix + chrome::kChromeUISyncHost), + GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost), false, true }, { - GURL("about:mars"), - GURL("chrome://about/mars"), + GURL(chrome_prefix + "host/path?query#ref"), + GURL(chrome_prefix + "host/path?query#ref"), false, true - }, + } }; MessageLoopForUI message_loop; BrowserThread ui_thread(BrowserThread::UI, &message_loop); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 13dd1ec..8a49478 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -185,9 +185,10 @@ GURL ChromeContentBrowserClient::GetEffectiveURL(Profile* profile, } bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { - return url.spec() == chrome::kAboutKillURL || - url.spec() == chrome::kAboutHangURL || - url.spec() == chrome::kAboutShorthangURL; + return url == GURL(chrome::kChromeUICrashURL) || + url == GURL(chrome::kChromeUIKillURL) || + url == GURL(chrome::kChromeUIHangURL) || + url == GURL(chrome::kChromeUIShorthangURL); } std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( diff --git a/chrome/browser/crash_recovery_browsertest.cc b/chrome/browser/crash_recovery_browsertest.cc index e44bb49..58e4f31 100644 --- a/chrome/browser/crash_recovery_browsertest.cc +++ b/chrome/browser/crash_recovery_browsertest.cc @@ -15,7 +15,7 @@ namespace { void SimulateRendererCrash(Browser* browser) { - browser->OpenURL(GURL(chrome::kAboutCrashURL), GURL(), CURRENT_TAB, + browser->OpenURL(GURL(chrome::kChromeUICrashURL), GURL(), CURRENT_TAB, PageTransition::TYPED); LOG(ERROR) << "SimulateRendererCrash, before WaitForNotification"; ui_test_utils::WaitForNotification( diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index d34ab50..c53817b5 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc @@ -1331,7 +1331,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { ASSERT_TRUE(InitialSetup(false)); FilePath file(FILE_PATH_LITERAL("download-test1.lib")); GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); - GURL flags_url(chrome::kAboutFlagsURL); + GURL flags_url(chrome::kChromeUIFlagsURL); GURL extensions_url(chrome::kChromeUIExtensionsURL); ui_test_utils::NavigateToURL(browser(), flags_url); @@ -1356,7 +1356,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { // As of 2011/05/22, it's crashing, so it is getting disabled. // http://crbug.com/82278 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_BrowserCloseAfterDownload) { - GURL downloads_url(chrome::kAboutFlagsURL); + GURL downloads_url(chrome::kChromeUIFlagsURL); FilePath file(FILE_PATH_LITERAL("download-test1.lib")); GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); diff --git a/chrome/browser/extensions/all_urls_apitest.cc b/chrome/browser/extensions/all_urls_apitest.cc index e34e989..d9fde87 100644 --- a/chrome/browser/extensions/all_urls_apitest.cc +++ b/chrome/browser/extensions/all_urls_apitest.cc @@ -53,8 +53,8 @@ IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, WhitelistedExtension) { ASSERT_TRUE(listener2a.WaitUntilSatisfied()); ASSERT_TRUE(listener2b.WaitUntilSatisfied()); - // Now verify about:version. - url = "about:version"; + // Now verify chrome://version/. + url = "chrome://version/"; ExtensionTestMessageListener listener3a("content script: " + url, false); ExtensionTestMessageListener listener3b("execute: " + url, false); ui_test_utils::NavigateToURL(browser(), GURL(url)); diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index af2dbd4..6fc8368 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -24,7 +24,6 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/web_ui_util.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/extension_resource.h" @@ -71,7 +70,8 @@ void ShowAppInstalledAnimation(Browser* browser, const std::string& app_id) { // automatically show the install animation for any new apps. for (int i = 0; i < browser->tab_count(); ++i) { GURL url = browser->GetTabContentsAt(i)->GetURL(); - if (web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost)) { + if (url.SchemeIs(chrome::kChromeUIScheme) && + url.host() == chrome::kChromeUINewTabHost) { browser->ActivateTabAt(i, false); return; } diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 44765ba..1c185e2 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -123,6 +123,19 @@ std::string GetWindowTypeText(const Browser* browser) { return keys::kWindowTypeValueNormal; } +bool IsCrashURL(const GURL& url) { + // GURL does not parse about: URL hosts, so compare against these entire URLs. + if (url == GURL(chrome::kAboutBrowserCrash) || + url == GURL(chrome::kAboutCrashURL)) + return true; + + // Catch any crash-like URL here. + return ((url.SchemeIs(chrome::kAboutScheme) || + url.SchemeIs(chrome::kChromeUIScheme)) && + (url.host() == chrome::kChromeUIBrowserCrashHost || + url.host() == chrome::kChromeUICrashHost)); +} + } // namespace int ExtensionTabUtil::GetWindowId(const Browser* browser) { @@ -402,20 +415,16 @@ bool CreateWindowFunction::RunImpl() { keys::kInvalidUrlError, *i); return false; } + // Don't let the extension crash the browser or renderers. + if (IsCrashURL(url)) { + error_ = keys::kNoCrashBrowserError; + return false; + } urls.push_back(url); } } } - // Don't let the extension crash the browser or renderers. - GURL browser_crash(chrome::kAboutBrowserCrash); - GURL renderer_crash(chrome::kAboutCrashURL); - if (std::find(urls.begin(), urls.end(), browser_crash) != urls.end() || - std::find(urls.begin(), urls.end(), renderer_crash) != urls.end()) { - error_ = keys::kNoCrashBrowserError; - return false; - } - // Look for optional tab id. if (args) { int tab_id; @@ -746,8 +755,7 @@ bool CreateTabFunction::RunImpl() { } // Don't let extensions crash the browser or renderers. - if (url == GURL(chrome::kAboutBrowserCrash) || - url == GURL(chrome::kAboutCrashURL)) { + if (IsCrashURL(url)) { error_ = keys::kNoCrashBrowserError; return false; } @@ -863,7 +871,7 @@ bool UpdateTabFunction::RunImpl() { // -title // -favIconUrl - // Navigate the tab to a new location if the url different. + // Navigate the tab to a new location if the url is different. std::string url_string; if (update_props->HasKey(keys::kUrlKey)) { EXTENSION_FUNCTION_VALIDATE(update_props->GetString( @@ -877,8 +885,7 @@ bool UpdateTabFunction::RunImpl() { } // Don't let the extension crash the browser or renderers. - if (url == GURL(chrome::kAboutBrowserCrash) || - url == GURL(chrome::kAboutCrashURL)) { + if (IsCrashURL(url)) { error_ = keys::kNoCrashBrowserError; return false; } diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index cbed0a6..45e8364 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -704,13 +704,10 @@ bool HistoryService::CanAddURL(const GURL& url) { url.SchemeIs(chrome::kChromeInternalScheme)) return false; - if (url.SchemeIs(chrome::kAboutScheme)) { - if (LowerCaseEqualsASCII(url.path(), "blank")) - return false; - // We allow all other about URLs since the user may like to see things - // like "about:memory" or "about:histograms" in their history and - // autocomplete. - } + // Allow all about: and chrome: URLs except about:blank, since the user may + // like to see "chrome://memory/", etc. in their history and autocomplete. + if (url == GURL(chrome::kAboutBlankURL)) + return false; return true; } diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 10d930b..37125d0 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.cc @@ -406,10 +406,10 @@ std::string URLFixerUpper::SegmentURL(const std::string& text, chrome::kFtpScheme : chrome::kHttpScheme); } - // Not segmenting file schemes or nonstandard schemes. - if ((scheme == chrome::kFileScheme) || - !url_util::IsStandard(scheme.c_str(), - url_parse::Component(0, static_cast<int>(scheme.length())))) + // Proceed with about and chrome schemes, but not file or nonstandard schemes. + if ((scheme != chrome::kAboutScheme) && (scheme != chrome::kChromeUIScheme) && + ((scheme == chrome::kFileScheme) || !url_util::IsStandard(scheme.c_str(), + url_parse::Component(0, static_cast<int>(scheme.length()))))) return scheme; if (parts->scheme.is_valid()) { @@ -427,7 +427,7 @@ std::string URLFixerUpper::SegmentURL(const std::string& text, // Construct the text to parse by inserting the scheme. std::string inserted_text(scheme); - inserted_text.append("://"); + inserted_text.append(chrome::kStandardSchemeSeparator); std::string text_to_parse(text.begin(), first_nonwhite); text_to_parse.append(inserted_text); text_to_parse.append(first_nonwhite, text.end()); @@ -478,11 +478,16 @@ GURL URLFixerUpper::FixupURL(const std::string& text, if (scheme == chrome::kFileScheme) return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); + // Parse and rebuild about: and chrome: URLs, except about:blank. + bool chrome_url = !LowerCaseEqualsASCII(trimmed, chrome::kAboutBlankURL) && + ((scheme == chrome::kAboutScheme) || (scheme == chrome::kChromeUIScheme)); + // For some schemes whose layouts we understand, we rebuild it. - if (url_util::IsStandard(scheme.c_str(), + if (chrome_url || url_util::IsStandard(scheme.c_str(), url_parse::Component(0, static_cast<int>(scheme.length())))) { - std::string url(scheme); - url.append("://"); + // Replace the about: scheme with the chrome: scheme. + std::string url(chrome_url ? chrome::kChromeUIScheme : scheme); + url.append(chrome::kStandardSchemeSeparator); // We need to check whether the |username| is valid because it is our // responsibility to append the '@' to delineate the user information from @@ -494,6 +499,8 @@ GURL URLFixerUpper::FixupURL(const std::string& text, } FixupHost(trimmed, parts.host, parts.scheme.is_valid(), desired_tld, &url); + if (chrome_url && !parts.host.is_valid()) + url.append(chrome::kChromeUIDefaultHost); FixupPort(trimmed, parts.port, &url); FixupPath(trimmed, parts.path, &url); FixupQuery(trimmed, parts.query, &url); @@ -505,7 +512,7 @@ GURL URLFixerUpper::FixupURL(const std::string& text, // In the worst-case, we insert a scheme if the URL lacks one. if (!parts.scheme.is_valid()) { std::string fixed_scheme(scheme); - fixed_scheme.append("://"); + fixed_scheme.append(chrome::kStandardSchemeSeparator); trimmed.insert(0, fixed_scheme); } diff --git a/chrome/browser/net/url_fixer_upper.h b/chrome/browser/net/url_fixer_upper.h index e6096bb..f5b5327 100644 --- a/chrome/browser/net/url_fixer_upper.h +++ b/chrome/browser/net/url_fixer_upper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -41,6 +41,11 @@ namespace URLFixerUpper { // be valid, so check the return value's validity or use // possibly_invalid_spec(). // + // Schemes "about" and "chrome" are normalized to "chrome://", with slashes. + // "about:blank" is unaltered, as Webkit allows frames to access about:blank. + // Additionally, if a chrome URL does not have a valid host, as in "about:", + // the returned URL will have the host "version", as in "chrome://version". + // // If |desired_tld| is non-empty, it represents the TLD the user wishes to // append in the case of an incomplete domain. We check that this is not a // file path and there does not appear to be a valid TLD already, then append diff --git a/chrome/browser/net/url_fixer_upper_unittest.cc b/chrome/browser/net/url_fixer_upper_unittest.cc index bf08dc6..f49ea8f 100644 --- a/chrome/browser/net/url_fixer_upper_unittest.cc +++ b/chrome/browser/net/url_fixer_upper_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -57,12 +57,52 @@ static const segment_case segment_cases[] = { url_parse::Component(0, 5), // scheme url_parse::Component(), // username url_parse::Component(), // password - url_parse::Component(), // host + url_parse::Component(6, 7), // host url_parse::Component(), // port url_parse::Component(), // path url_parse::Component(), // query url_parse::Component(), // ref }, + { "about:host/path?query#ref", "about", + url_parse::Component(0, 5), // scheme + url_parse::Component(), // username + url_parse::Component(), // password + url_parse::Component(6, 4), // host + url_parse::Component(), // port + url_parse::Component(10, 5), // path + url_parse::Component(16, 5), // query + url_parse::Component(22, 3), // ref + }, + { "about://host/path?query#ref", "about", + url_parse::Component(0, 5), // scheme + url_parse::Component(), // username + url_parse::Component(), // password + url_parse::Component(8, 4), // host + url_parse::Component(), // port + url_parse::Component(12, 5), // path + url_parse::Component(18, 5), // query + url_parse::Component(24, 3), // ref + }, + { "chrome:host/path?query#ref", "chrome", + url_parse::Component(0, 6), // scheme + url_parse::Component(), // username + url_parse::Component(), // password + url_parse::Component(7, 4), // host + url_parse::Component(), // port + url_parse::Component(11, 5), // path + url_parse::Component(17, 5), // query + url_parse::Component(23, 3), // ref + }, + { "chrome://host/path?query#ref", "chrome", + url_parse::Component(0, 6), // scheme + url_parse::Component(), // username + url_parse::Component(), // password + url_parse::Component(9, 4), // host + url_parse::Component(), // port + url_parse::Component(13, 5), // path + url_parse::Component(19, 5), // query + url_parse::Component(25, 3), // ref + }, { " www.google.com:124?foo#", "http", url_parse::Component(), // scheme url_parse::Component(), // username @@ -218,8 +258,13 @@ struct fixup_case { {"http://host.com:ninety-two/", "", "http://host.com:ninety-two/"}, {"http://host.com:ninety-two?foo", "", "http://host.com:ninety-two/?foo"}, {"google.com:123", "", "http://google.com:123/"}, - {"about:", "", "about:"}, - {"about:version", "", "about:version"}, + {"about:", "", "chrome://version/"}, + {"about:foo", "", "chrome://foo/"}, + {"about:version", "", "chrome://version/"}, + {"about:usr:pwd@hst/pth?qry#ref", "", "chrome://usr:pwd@hst/pth?qry#ref"}, + {"about://usr:pwd@hst/pth?qry#ref", "", "chrome://usr:pwd@hst/pth?qry#ref"}, + {"chrome:usr:pwd@hst/pth?qry#ref", "", "chrome://usr:pwd@hst/pth?qry#ref"}, + {"chrome://usr:pwd@hst/pth?qry#ref", "", "chrome://usr:pwd@hst/pth?qry#ref"}, {"www:123", "", "http://www:123/"}, {" www:123", "", "http://www:123/"}, {"www.google.com?foo", "", "http://www.google.com/?foo"}, diff --git a/chrome/browser/net/view_blob_internals_job_factory.cc b/chrome/browser/net/view_blob_internals_job_factory.cc index 1498934..2b84f23 100644 --- a/chrome/browser/net/view_blob_internals_job_factory.cc +++ b/chrome/browser/net/view_blob_internals_job_factory.cc @@ -13,9 +13,8 @@ // static. bool ViewBlobInternalsJobFactory::IsSupportedURL(const GURL& url) { - return StartsWithASCII(url.spec(), - chrome::kBlobViewInternalsURL, - true /*case_sensitive*/); + return url.SchemeIs(chrome::kChromeUIScheme) && + url.host() == chrome::kChromeUIBlobInternalsHost; } // static. diff --git a/chrome/browser/net/view_http_cache_job_factory.cc b/chrome/browser/net/view_http_cache_job_factory.cc index 86d008c..1c4437b 100644 --- a/chrome/browser/net/view_http_cache_job_factory.cc +++ b/chrome/browser/net/view_http_cache_job_factory.cc @@ -128,12 +128,13 @@ int ViewHttpCacheJob::Core::Start(const net::URLRequest& request, AddRef(); // Released on OnIOComplete(). std::string cache_key = - request.url().spec().substr(strlen(chrome::kNetworkViewCacheURL)); + request.url().spec().substr(strlen(chrome::kChromeUINetworkViewCacheURL)); int rv; if (cache_key.empty()) { rv = cache_helper_.GetContentsHTML(request.context(), - chrome::kNetworkViewCacheURL, &data_, + chrome::kChromeUINetworkViewCacheURL, + &data_, &callback_); } else { rv = cache_helper_.GetEntryInfoHTML(cache_key, request.context(), @@ -184,8 +185,8 @@ void ViewHttpCacheJob::Core::OnIOComplete(int result) { // Static. bool ViewHttpCacheJobFactory::IsSupportedURL(const GURL& url) { - return StartsWithASCII(url.spec(), chrome::kNetworkViewCacheURL, - true /*case_sensitive*/); + return url.SchemeIs(chrome::kChromeUIScheme) && + url.host() == chrome::kChromeUINetworkViewCacheHost; } // Static. diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc index 9b5718c..eccab4e 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_source.cc @@ -40,7 +40,7 @@ void AddString(DictionaryValue* dictionary, } // namespace CloudPrintSetupSource::CloudPrintSetupSource() - : DataSource(chrome::kCloudPrintSetupHost, MessageLoop::current()) { + : DataSource(chrome::kChromeUICloudPrintSetupHost, MessageLoop::current()) { } void CloudPrintSetupSource::StartDataRequest(const std::string& path_raw, diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index 6cb1932..f80240d 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -54,7 +54,7 @@ // The constructor for PrintDialogCloud creates a // CloudPrintHtmlDialogDelegate and asks the current active browser to // show an HTML dialog using that class as the delegate. That class -// hands in the kCloudPrintResourcesURL as the URL to visit. That is +// hands in the kChromeUICloudPrintResourcesURL as the URL to visit. That is // recognized by the GetWebUIFactoryFunction as a signal to create an // ExternalHtmlDialogUI. @@ -424,7 +424,7 @@ void CloudPrintHtmlDialogDelegate::Init(int width, int height, const std::string& json_arguments) { // This information is needed to show the dialog HTML content. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - params_.url = GURL(chrome::kCloudPrintResourcesURL); + params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL); params_.height = height; params_.width = width; params_.json_input = json_arguments; diff --git a/chrome/browser/printing/print_dialog_cloud_unittest.cc b/chrome/browser/printing/print_dialog_cloud_unittest.cc index a200332..688f5e4 100644 --- a/chrome/browser/printing/print_dialog_cloud_unittest.cc +++ b/chrome/browser/printing/print_dialog_cloud_unittest.cc @@ -320,7 +320,7 @@ class CloudPrintHtmlDialogDelegateTest : public testing::Test { TEST_F(CloudPrintHtmlDialogDelegateTest, BasicChecks) { EXPECT_TRUE(delegate_->IsDialogModal()); EXPECT_THAT(delegate_->GetDialogContentURL().spec(), - StrEq(chrome::kCloudPrintResourcesURL)); + StrEq(chrome::kChromeUICloudPrintResourcesURL)); EXPECT_TRUE(delegate_->GetDialogTitle().empty()); bool close_dialog = false; diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 4b228a8..71aa909 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1588,11 +1588,9 @@ bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { if (active_entry->IsViewSourceMode()) return false; - // Don't inspect about:network, about:memory, etc. - // However, we do want to inspect about:blank, which is often - // used by ordinary web pages. - if (active_entry->virtual_url().SchemeIs(chrome::kAboutScheme) && - !LowerCaseEqualsASCII(active_entry->virtual_url().path(), "blank")) + // Do not inspect Chrome URLs (chrome://network/, chrome://memory/, etc.). + // However, do inspect about:blank, which is often used by ordinary web pages. + if (active_entry->virtual_url().SchemeIs(chrome::kChromeUIScheme)) return false; if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT) { diff --git a/chrome/browser/tab_restore_uitest.cc b/chrome/browser/tab_restore_uitest.cc index dfe1c54..1e57299 100644 --- a/chrome/browser/tab_restore_uitest.cc +++ b/chrome/browser/tab_restore_uitest.cc @@ -602,7 +602,7 @@ TEST_F(TabRestoreUITest, RestoreWindow) { EXPECT_TRUE(url == url2_); } -// Restore tab with special URL about:credits and make sure the page loads +// Restore tab with special URL chrome://credits/ and make sure the page loads // properly after restore. See http://crbug.com/31905. TEST_F(TabRestoreUITest, RestoreTabWithSpecialURL) { scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); @@ -610,7 +610,7 @@ TEST_F(TabRestoreUITest, RestoreTabWithSpecialURL) { CheckActiveWindow(browser.get()); // Navigate new tab to a special URL. - const GURL special_url(chrome::kAboutCreditsURL); + const GURL special_url(chrome::kChromeUICreditsURL); ASSERT_TRUE(browser->AppendTab(special_url)); scoped_refptr<TabProxy> tab(browser->GetActiveTab()); ASSERT_TRUE(tab.get()); @@ -643,7 +643,7 @@ TEST_F(TabRestoreUITest, RestoreTabWithSpecialURLOnBack) { CheckActiveWindow(browser.get()); // Navigate new tab to a special URL. - const GURL special_url(chrome::kAboutCreditsURL); + const GURL special_url(chrome::kChromeUICreditsURL); ASSERT_TRUE(browser->AppendTab(special_url)); scoped_refptr<TabProxy> tab(browser->GetActiveTab()); ASSERT_TRUE(tab.get()); diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index de8df7f..40f7d60 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -22,7 +22,6 @@ #include "chrome/browser/tabs/tab_strip_model_delegate.h" #include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/web_ui_util.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_process_host.h" @@ -1104,9 +1103,10 @@ std::vector<int> TabStripModel::GetIndicesForCommand(int index) const { bool TabStripModel::IsNewTabAtEndOfTabStrip( TabContentsWrapper* contents) const { const GURL& url = contents->tab_contents()->GetURL(); - return web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost) && - contents == GetContentsAt(count() - 1) && - contents->controller().entry_count() == 1; + return url.SchemeIs(chrome::kChromeUIScheme) && + url.host() == chrome::kChromeUINewTabHost && + contents == GetContentsAt(count() - 1) && + contents->controller().entry_count() == 1; } bool TabStripModel::InternalCloseTabs(const std::vector<int>& in_indices, diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index a86afce..ceb1f9d 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -96,7 +96,6 @@ #include "chrome/browser/ui/webui/active_downloads_ui.h" #include "chrome/browser/ui/webui/bug_report_ui.h" #include "chrome/browser/ui/webui/options/content_settings_handler.h" -#include "chrome/browser/ui/webui/web_ui_util.h" #include "chrome/browser/ui/window_sizer.h" #include "chrome/browser/upgrade_detector.h" #include "chrome/browser/web_applications/web_app.h" @@ -1612,7 +1611,8 @@ void Browser::ToggleFullscreenMode() { void Browser::Search() { // If the NTP is showing, close it. const GURL& url = GetSelectedTabContents()->GetURL(); - if (web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost)) { + if (url.SchemeIs(chrome::kChromeUIScheme) && + url.host() == chrome::kChromeUINewTabHost) { CloseTab(); return; } diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc index a401f54..06238dd 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc @@ -35,7 +35,6 @@ #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" #include "chrome/browser/ui/gtk/view_id_util.h" #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" -#include "chrome/browser/ui/webui/web_ui_util.h" #include "chrome/browser/upgrade_detector.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -607,8 +606,8 @@ void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, if (!url.is_valid()) return; - bool url_is_newtab = - web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost); + bool url_is_newtab = url.SchemeIs(chrome::kChromeUIScheme) && + url.host() == chrome::kChromeUINewTabHost; home_page_is_new_tab_page_.SetValue(url_is_newtab); if (!url_is_newtab) home_page_.SetValue(url.spec()); diff --git a/chrome/browser/ui/webui/BidiCheckerWebUITest.cc b/chrome/browser/ui/webui/BidiCheckerWebUITest.cc index 29b430a..96a5bb1 100644 --- a/chrome/browser/ui/webui/BidiCheckerWebUITest.cc +++ b/chrome/browser/ui/webui/BidiCheckerWebUITest.cc @@ -63,10 +63,6 @@ IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestMainHistoryPageLTR) { RunBidiCheckerOnPage(chrome::kChromeUIHistoryURL, false); } -IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestAboutAboutPageLTR) {\ - RunBidiCheckerOnPage(chrome::kChromeUIAboutAboutURL, false);\ -} - IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestAboutPageLTR) {\ RunBidiCheckerOnPage(chrome::kChromeUIAboutURL, false);\ } diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc index 6717ab4..0e7f85f 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc @@ -220,9 +220,8 @@ void URLRequestChromeJob::StartAsync() { namespace { bool IsViewAppCacheInternalsURL(const GURL& url) { - return StartsWithASCII(url.spec(), - chrome::kAppCacheViewInternalsURL, - true /*case_sensitive*/); + return url.SchemeIs(chrome::kChromeUIScheme) && + url.host() == chrome::kChromeUIAppCacheInternalsHost; } class ChromeProtocolHandler diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc index f209202..0e9dc25 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc @@ -101,7 +101,7 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, // All platform builds of Chrome will need to have a cloud printing // dialog as backup. It's just that on Chrome OS, it's the only // print dialog. - if (url.host() == chrome::kCloudPrintResourcesHost) + if (url.host() == chrome::kChromeUICloudPrintResourcesHost) return &NewWebUI<ExternalHtmlDialogUI>; // This will get called a lot to check all URLs, so do a quick check of other @@ -112,7 +112,7 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, return NULL; if (url.host() == chrome::kChromeUISyncResourcesHost || - url.host() == chrome::kCloudPrintSetupHost) + url.host() == chrome::kChromeUICloudPrintSetupHost) return &NewWebUI<HtmlDialogUI>; // Special case the new tab page. In older versions of Chrome, the new tab @@ -123,8 +123,9 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, url.SchemeIs(chrome::kChromeInternalScheme)) return &NewWebUI<NewTabUI>; - // Give about:about a generic Web UI so it can navigate to pages with Web UIs. - if (url.spec() == chrome::kChromeUIAboutAboutURL) + // Return a generic Web UI so chrome:chrome-urls can navigate to Web UI pages. + if (url.host() == chrome::kChromeUIAboutHost || + url.host() == chrome::kChromeUIChromeURLsHost) return &NewWebUI<ChromeWebUI>; // We must compare hosts only since some of the Web UIs append extra stuff @@ -257,11 +258,11 @@ bool ChromeWebUIFactory::IsURLAcceptableForWebUI( // It's possible to load about:blank in a Web UI renderer. // See http://crbug.com/42547 url.spec() == chrome::kAboutBlankURL || - // about:crash, about:kill, about:hang, and about:shorthang are allowed. - url.spec() == chrome::kAboutCrashURL || - url.spec() == chrome::kAboutKillURL || - url.spec() == chrome::kAboutHangURL || - url.spec() == chrome::kAboutShorthangURL; + // Chrome URLs crash, kill, hang, and shorthang are allowed. + url == GURL(chrome::kChromeUICrashURL) || + url == GURL(chrome::kChromeUIKillURL) || + url == GURL(chrome::kChromeUIHangURL) || + url == GURL(chrome::kChromeUIShorthangURL); } WebUI* ChromeWebUIFactory::CreateWebUIForURL( @@ -308,7 +309,7 @@ ChromeWebUIFactory::~ChromeWebUIFactory() { } RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes( - const GURL& page_url) const { + const GURL& page_url) const { // The bookmark manager is a chrome extension, so we have to check for it // before we check for extension scheme. if (page_url.host() == extension_misc::kBookmarkManagerId) diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc b/chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc index 970e62e..f0640a0 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc @@ -82,9 +82,9 @@ TEST_F(NewTabUITest, DISABLED_NTPHasLoginName) { EXPECT_EQ(L"user@gmail.com", displayed_username); } -// Loads about:hang into two NTP tabs, ensuring we don't crash. +// Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. // See http://crbug.com/59859. -TEST_F(NewTabUITest, AboutHangInNTP) { +TEST_F(NewTabUITest, ChromeHangInNTP) { scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); ASSERT_TRUE(window.get()); @@ -93,15 +93,15 @@ TEST_F(NewTabUITest, AboutHangInNTP) { scoped_refptr<TabProxy> tab = window->GetActiveTab(); ASSERT_TRUE(tab.get()); - // Navigate to about:hang to stall the process. - ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); + // Navigate to chrome://hang/ to stall the process. + ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kChromeUIHangURL))); - // Visit about:hang again in another NTP. Don't bother waiting for the + // Visit chrome://hang/ again in another NTP. Don't bother waiting for the // NTP to load, because it's hung. ASSERT_TRUE(window->RunCommandAsync(IDC_NEW_TAB)); scoped_refptr<TabProxy> tab2 = window->GetActiveTab(); ASSERT_TRUE(tab2.get()); - ASSERT_TRUE(tab2->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); + ASSERT_TRUE(tab2->NavigateToURLAsync(GURL(chrome::kChromeUIHangURL))); } // Allows testing NTP in process-per-tab mode. @@ -128,8 +128,8 @@ TEST_F(NewTabUIProcessPerTabTest, NavBeforeNTPCommits) { scoped_refptr<TabProxy> tab = window->GetActiveTab(); ASSERT_TRUE(tab.get()); - // Navigate to about:hang to stall the process. - ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); + // Navigate to chrome://hang/ to stall the process. + ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kChromeUIHangURL))); // Visit a normal URL in another NTP that hasn't committed. ASSERT_TRUE(window->RunCommandAsync(IDC_NEW_TAB)); diff --git a/chrome/browser/ui/webui/options/about_page_handler.cc b/chrome/browser/ui/webui/options/about_page_handler.cc index 70b8216..04f43b4 100644 --- a/chrome/browser/ui/webui/options/about_page_handler.cc +++ b/chrome/browser/ui/webui/options/about_page_handler.cc @@ -187,16 +187,14 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { localized_strings->SetString(chromium_url_appears_first ? "license_link_0" : "license_link_1", url.spec()); - // The Open Source link within the main text of the dialog. We need to use - // the chrome:// variant instead of about:credits; the latter will get - // rewritten to about:blank. + // The Open Source link within the main text of the dialog. localized_strings->SetString(chromium_url_appears_first ? "license_link_content_1" : "license_link_content_0", StringSubRange(text, text.find(kBeginLinkOss) + strlen(kBeginLinkOss), text.find(kEndLinkOss))); localized_strings->SetString(chromium_url_appears_first ? - "license_link_1" : "license_link_0", chrome::kChromeUIAboutCreditsURL); + "license_link_1" : "license_link_0", chrome::kChromeUICreditsURL); #if defined(OS_CHROMEOS) std::string cros_text = @@ -215,7 +213,7 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { StringSubRange(cros_text, cros_link + strlen(kBeginLinkCrosOss), cros_link_end)); localized_strings->SetString("cros_license_link_0", - chrome::kChromeUIAboutOSCreditsURL); + chrome::kChromeUIOSCreditsURL); #endif // webkit diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc index be9ad89..4f0c72e 100644 --- a/chrome/browser/ui/webui/options/options_ui.cc +++ b/chrome/browser/ui/webui/options/options_ui.cc @@ -282,10 +282,6 @@ OptionsUI::OptionsUI(TabContents* contents) contents->profile()->GetChromeURLDataManager()->AddDataSource( user_image_source); #endif - - // Initialize the chrome://about/ source in case the user clicks the credits - // link. - InitializeAboutDataSource(contents->profile()); } OptionsUI::~OptionsUI() { diff --git a/chrome/browser/ui/webui/web_ui_util.cc b/chrome/browser/ui/webui/web_ui_util.cc index b6f49b3..ee854ac 100644 --- a/chrome/browser/ui/webui/web_ui_util.cc +++ b/chrome/browser/ui/webui/web_ui_util.cc @@ -7,9 +7,6 @@ #include <vector> #include "base/base64.h" -#include "base/string_util.h" -#include "chrome/common/url_constants.h" -#include "googleurl/src/gurl.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/codec/png_codec.h" @@ -42,10 +39,4 @@ std::string GetImageDataUrlFromResource(int res) { return str_url; } -bool ChromeURLHostEquals(const GURL& url, const char* host) { - return (url.SchemeIs(chrome::kChromeUIScheme) || - url.SchemeIs(chrome::kAboutScheme)) && - LowerCaseEqualsASCII(url.host(), host); -} - } // namespace web_ui_util diff --git a/chrome/browser/ui/webui/web_ui_util.h b/chrome/browser/ui/webui/web_ui_util.h index 0a0eebf..2a7743f 100644 --- a/chrome/browser/ui/webui/web_ui_util.h +++ b/chrome/browser/ui/webui/web_ui_util.h @@ -8,7 +8,6 @@ #include <string> -class GURL; class SkBitmap; namespace web_ui_util { @@ -25,10 +24,6 @@ std::string GetImageDataUrl(const SkBitmap& bitmap); // |resource_id|. std::string GetImageDataUrlFromResource(int resource_id); -// Returns true if |url| has a chrome: or about: scheme and matching |host|. -// The url may contain a path under the host. -bool ChromeURLHostEquals(const GURL& url, const char* host); - } // namespace web_ui_util #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ |