diff options
43 files changed, 548 insertions, 559 deletions
diff --git a/chrome/browser/accessibility/accessibility_win_browsertest.cc b/chrome/browser/accessibility/accessibility_win_browsertest.cc index 19bb413..16e12e2 100644 --- a/chrome/browser/accessibility/accessibility_win_browsertest.cc +++ b/chrome/browser/accessibility/accessibility_win_browsertest.cc @@ -11,7 +11,6 @@ #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" @@ -371,7 +370,8 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, EXPECT_NE(parent_dispatch, reinterpret_cast<IDispatch*>(NULL)); // Navigate to another page. - ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIVersionURL)); + GURL about_url("about:"); + ui_test_utils::NavigateToURL(browser(), about_url); // 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 507d9ed..96843cf 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(ChromePaths()); + std::vector<std::string> builtins(AboutPaths()); 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 9e87089..2bc1f17 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::kChromeUICrashURL)); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutCrashURL)); } diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index f26d0b1..0ae9771 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -31,7 +31,6 @@ #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" @@ -103,93 +102,107 @@ void AboutTcmallocRendererCallback(base::ProcessId pid, namespace { -// 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 +// 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"; #if defined(OS_WIN) - chrome::kChromeUIConflictsHost, +const char kConflictsPath[] = "conflicts"; #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) - chrome::kChromeUISandboxHost, +const char kLinuxProxyConfigPath[] = "linux-proxy-config"; +const char kSandboxPath[] = "sandbox"; #endif + #if defined(OS_CHROMEOS) - chrome::kChromeUINetworkHost, - chrome::kChromeUIOSCreditsHost, +const char kNetworkPath[] = "network"; +const char kOSCreditsPath[] = "os-credits"; +const char kEULAPathFormat[] = "/usr/share/chromeos-assets/eula/%s/eula.html"; #endif -}; - -// 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 - chrome::kChromeUITasksHost, -#endif -#if defined(USE_TCMALLOC) - chrome::kChromeUITCMallocHost, +// 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, +#ifdef TRACK_ALL_TASK_OBJECTS + kTasksPath, +#endif // TRACK_ALL_TASK_OBJECTS + kTcmallocPath, + kTermsPath, + kVersionPath, #if defined(OS_LINUX) - chrome::kChromeUILinuxProxyConfigHost, - chrome::kChromeUISandboxHost, + kSandboxPath, #endif #if defined(OS_CHROMEOS) - chrome::kChromeUINetworkHost, - chrome::kChromeUIOSCreditsHost, + kNetworkPath, + kOSCreditsPath, #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: - // Construct a data source for the specified |source_name|. - AboutSource(const std::string& source_name, Profile* profile); + // Creates our datasource. + AboutSource(); + explicit AboutSource(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) OVERRIDE; + int request_id); - virtual std::string GetMimeType(const std::string&) const OVERRIDE { + virtual std::string GetMimeType(const std::string&) const { return "text/html"; } @@ -206,43 +219,14 @@ 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(); @@ -313,10 +297,10 @@ class ChromeOSTermsHandler void LoadFileOnFileThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - std::string path = StringPrintf(chrome::kEULAPathFormat, locale_.c_str()); + std::string path = StringPrintf(kEULAPathFormat, locale_.c_str()); if (!file_util::ReadFileToString(FilePath(path), &contents_)) { // No EULA for given language - try en-US as default. - path = StringPrintf(chrome::kEULAPathFormat, "en-US"); + path = StringPrintf(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. @@ -354,19 +338,36 @@ class ChromeOSTermsHandler // Individual about handlers --------------------------------------------------- -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()); +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()); for (std::vector<std::string>::const_iterator i = paths.begin(); - i != paths.end(); ++i) - html += "<li><a href='chrome://" + *i + "/'>chrome://" + *i + "</a></li>\n"; + 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" }; 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(kDebugChromePaths); i++) - html += "<li>chrome://" + std::string(kDebugChromePaths[i]) + "</li>\n"; + for (size_t i = 0; i < arraysize(debug); i++) + html += "<li>about:" + std::string(debug[i]) + "</li>\n"; html += "</ul>\n</body></html>"; return html; } @@ -599,7 +600,7 @@ class AboutDnsHandler : public base::RefCountedThreadSafe<AboutDnsHandler> { }; #if defined(USE_TCMALLOC) -std::string AboutTcmalloc() { +std::string AboutTcmalloc(const std::string& query) { std::string data; AboutTcmallocOutputsType* outputs = AboutTcmallocOutputs::GetInstance()->outputs(); @@ -1019,40 +1020,51 @@ std::string AboutVersion(DictionaryValue* localized_strings, Profile* profile) { // AboutSource ----------------------------------------------------------------- -AboutSource::AboutSource(const std::string& source_name, Profile* profile) - : DataSource(source_name, MessageLoop::current()), +AboutSource::AboutSource() + : DataSource(chrome::kAboutScheme, MessageLoop::current()) { +} + +AboutSource::AboutSource(Profile* profile) + : DataSource(chrome::kAboutScheme, MessageLoop::current()), profile_(profile) { } AboutSource::~AboutSource() { } -void AboutSource::StartDataRequest(const std::string& path, - bool is_incognito, - int request_id) { +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); + std::string response; - std::string host = source_name(); - if (host == chrome::kChromeUIDNSHost) { + if (path == kDnsPath) { AboutDnsHandler::Start(this, request_id); return; - } else if (host == chrome::kChromeUIHistogramsHost) { - response = AboutHistograms(path); - } else if (host == chrome::kChromeUIMemoryHost) { - response = GetAboutMemoryRedirectResponse(profile()); - } else if (host == chrome::kChromeUIMemoryRedirectHost) { + } else if (path == kHistogramsPath) { + response = AboutHistograms(info); + } else if (path == kMemoryPath) { AboutMemory(this, request_id); return; + } else if (path == kMemoryRedirectPath) { + response = GetAboutMemoryRedirectResponse(); #ifdef TRACK_ALL_TASK_OBJECTS - } else if (host == chrome::kChromeUITasksHost) { - response = AboutObjects(path); + } else if (path == kTasksPath) { + response = AboutObjects(info); #endif - } else if (host == chrome::kChromeUIStatsHost) { - response = AboutStats(path); + } else if (path == kStatsPath) { + response = AboutStats(info); #if defined(USE_TCMALLOC) - } else if (host == chrome::kChromeUITCMallocHost) { - response = AboutTcmalloc(); + } else if (path == kTcmallocPath) { + response = AboutTcmalloc(info); #endif - } else if (host == chrome::kChromeUIVersionHost) { + } else if (path == kVersionPath || path.empty()) { #if defined(OS_CHROMEOS) new ChromeOSAboutVersionHandler(this, request_id); return; @@ -1061,19 +1073,19 @@ void AboutSource::StartDataRequest(const std::string& path, localized_strings.SetString("os_version", ""); response = AboutVersion(&localized_strings, profile_); #endif - } else if (host == chrome::kChromeUICreditsHost) { + } else if (path == kCreditsPath) { response = ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_CREDITS_HTML).as_string(); - } else if (host == chrome::kChromeUIChromeURLsHost) { - response = ChromeURLs(); + } else if (path == kAboutPath) { + response = AboutAbout(); #if defined(OS_CHROMEOS) - } else if (host == chrome::kChromeUIOSCreditsHost) { + } else if (path == kOSCreditsPath) { response = ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_OS_CREDITS_HTML).as_string(); - } else if (host == chrome::kChromeUINetworkHost) { - response = AboutNetwork(path); + } else if (path == kNetworkPath) { + response = AboutNetwork(info); #endif - } else if (host == chrome::kChromeUITermsHost) { + } else if (path == kTermsPath) { #if defined(OS_CHROMEOS) ChromeOSTermsHandler::Start(this, request_id); return; @@ -1082,9 +1094,9 @@ void AboutSource::StartDataRequest(const std::string& path, IDR_TERMS_HTML).as_string(); #endif #if defined(OS_LINUX) - } else if (host == chrome::kChromeUILinuxProxyConfigHost) { + } else if (path == kLinuxProxyConfigPath) { response = AboutLinuxProxyConfig(); - } else if (host == chrome::kChromeUISandboxHost) { + } else if (path == kSandboxPath) { response = AboutSandbox(); #endif } @@ -1092,10 +1104,11 @@ void AboutSource::StartDataRequest(const std::string& path, FinishDataRequest(response, request_id); } -void AboutSource::FinishDataRequest(const std::string& html, int request_id) { +void AboutSource::FinishDataRequest(const std::string& response, + int request_id) { scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); - html_bytes->data.resize(html.size()); - std::copy(html.begin(), html.end(), html_bytes->data.begin()); + html_bytes->data.resize(response.size()); + std::copy(response.begin(), response.end(), html_bytes->data.begin()); SendResponse(request_id, html_bytes); } @@ -1259,71 +1272,152 @@ 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) { - // 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()); - - // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. - DCHECK((*url == GURL(chrome::kAboutBlankURL)) || - !url->SchemeIs(chrome::kAboutScheme)); - - // 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)) + // We only handle about: schemes. + if (!url->SchemeIs(chrome::kAboutScheme)) return false; - // Circumvent processing URLs that the renderer process will handle. - if (chrome_about_handler::WillHandle(*url)) + // 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; - 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) { + // 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; + } + + // Rewrite about:appcache-internals/* URLs to chrome://appcache/* + if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { + *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); + return true; + } + + // 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; + } + + // Rewrite about:plugins to chrome://plugins/. + if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutPluginsURL)) { + *url = GURL(chrome::kChromeUIPluginsURL); + return true; + } + + // Handle URL to crash the browser process. + if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBrowserCrash)) { // Induce an intentional crash in the browser process. - CHECK(false); - } else if (host == chrome::kChromeUIGpuCleanHost) { + int* bad_pointer = NULL; + *bad_pointer = 42; + return true; + } + + // Handle URLs to wreck the gpu process. + if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuCleanURL)) { GpuProcessHost::SendOnIO( 0, content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, new GpuMsg_Clean()); - } else if (host == chrome::kChromeUIGpuCrashHost) { + } + if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuCrashURL)) { GpuProcessHost::SendOnIO( 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUCRASH, new GpuMsg_Crash()); - } else if (host == chrome::kChromeUIGpuHangHost) { + } + if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuHangURL)) { GpuProcessHost::SendOnIO( 0, content::CAUSE_FOR_GPU_LAUNCH_ABOUT_GPUHANG, new GpuMsg_Hang()); } - // Initialize any potentially corresponding AboutSource handler. - InitializeAboutDataSource(host, profile); + // 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); return true; } +void InitializeAboutDataSource(Profile* profile) { + profile->GetChromeURLDataManager()->AddDataSource(new AboutSource(profile)); +} + bool HandleNonNavigationAboutURL(const GURL& url) { - // chrome://ipc/ is currently buggy, so we disable it for official builds. + // about: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::kChromeUIIPCURL)) { + if (LowerCaseEqualsASCII(url.spec(), chrome::kAboutIPCURL)) { // Run the dialog. This will re-use the existing one if it's already up. browser::ShowAboutIPCDialog(); return true; @@ -1335,10 +1429,10 @@ bool HandleNonNavigationAboutURL(const GURL& url) { return false; } -std::vector<std::string> ChromePaths() { +std::vector<std::string> AboutPaths() { std::vector<std::string> paths; - paths.reserve(arraysize(kChromePaths)); - for (size_t i = 0; i < arraysize(kChromePaths); i++) - paths.push_back(kChromePaths[i]); + paths.reserve(arraysize(kAllAboutPaths)); + for (size_t i = 0; i < arraysize(kAllAboutPaths); i++) + paths.push_back(kAllAboutPaths[i]); return paths; } diff --git a/chrome/browser/browser_about_handler.h b/chrome/browser/browser_about_handler.h index 5fa8051..caaeba3 100644 --- a/chrome/browser/browser_about_handler.h +++ b/chrome/browser/browser_about_handler.h @@ -19,21 +19,25 @@ template <typename T> struct DefaultSingletonTraits; class GURL; class Profile; -// 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. +// 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. // // 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 chrome://chrome-urls. -std::vector<std::string> ChromePaths(); +// Gets the paths that are shown in about:about. +std::vector<std::string> AboutPaths(); #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 064e807..9b30550 100644 --- a/chrome/browser/browser_about_handler_unittest.cc +++ b/chrome/browser/browser_about_handler_unittest.cc @@ -16,8 +16,6 @@ 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; @@ -37,71 +35,71 @@ TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { false }, { - GURL(chrome_prefix + chrome::kChromeUICrashHost), - GURL(chrome_prefix + chrome::kChromeUICrashHost), - true, - false - }, - { - GURL(chrome_prefix + chrome::kChromeUIKillHost), - GURL(chrome_prefix + chrome::kChromeUIKillHost), - true, - false - }, - { - GURL(chrome_prefix + chrome::kChromeUIHangHost), - GURL(chrome_prefix + chrome::kChromeUIHangHost), - true, - false - }, - { - GURL(chrome_prefix + chrome::kChromeUIShorthangHost), - GURL(chrome_prefix + chrome::kChromeUIShorthangHost), - true, - false - }, - { - GURL(chrome_prefix + chrome::kChromeUIMemoryHost), - GURL(chrome_prefix + chrome::kChromeUIMemoryHost), + GURL(std::string(chrome::kAboutCacheURL) + "/mercury"), + GURL(std::string(chrome::kNetworkViewCacheURL) + "mercury"), false, true }, { - GURL(chrome_prefix + chrome::kChromeUIDefaultHost), - GURL(chrome_prefix + chrome::kChromeUIVersionHost), + GURL(std::string(chrome::kAboutNetInternalsURL) + "/venus"), + GURL(std::string(chrome::kNetworkViewInternalsURL) + "venus"), false, true }, { - GURL(chrome_prefix + chrome::kChromeUIAboutHost), - GURL(chrome_prefix + chrome::kChromeUIChromeURLsHost), + GURL(std::string(chrome::kAboutGpuURL) + "/jupiter"), + GURL(std::string(chrome::kGpuInternalsURL) + "jupiter"), false, true }, { - GURL(chrome_prefix + chrome::kChromeUICacheHost), - GURL(chrome_prefix + chrome::kChromeUINetworkViewCacheHost), + GURL(std::string(chrome::kAboutAppCacheInternalsURL) + "/earth"), + GURL(std::string(chrome::kAppCacheViewInternalsURL) + "earth"), false, true }, { - GURL(chrome_prefix + chrome::kChromeUIGpuHost), - GURL(chrome_prefix + chrome::kChromeUIGpuInternalsHost), + GURL(chrome::kAboutPluginsURL), + GURL(chrome::kChromeUIPluginsURL), false, true }, { - GURL(chrome_prefix + chrome::kChromeUISyncHost), - GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost), + GURL(chrome::kAboutCrashURL), + GURL(chrome::kAboutCrashURL), + true, + false + }, + { + GURL(chrome::kAboutKillURL), + GURL(chrome::kAboutKillURL), + true, + false + }, + { + GURL(chrome::kAboutHangURL), + GURL(chrome::kAboutHangURL), + true, + false + }, + { + GURL(chrome::kAboutShorthangURL), + GURL(chrome::kAboutShorthangURL), + true, + false + }, + { + GURL("about:memory"), + GURL("chrome://about/memory-redirect"), false, true }, { - GURL(chrome_prefix + "host/path?query#ref"), - GURL(chrome_prefix + "host/path?query#ref"), + GURL("about:mars"), + GURL("chrome://about/mars"), 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 5009c9c..c61aa45 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -182,10 +182,9 @@ GURL ChromeContentBrowserClient::GetEffectiveURL(Profile* profile, } bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { - return url == GURL(chrome::kChromeUICrashURL) || - url == GURL(chrome::kChromeUIKillURL) || - url == GURL(chrome::kChromeUIHangURL) || - url == GURL(chrome::kChromeUIShorthangURL); + return url.spec() == chrome::kAboutKillURL || + url.spec() == chrome::kAboutHangURL || + url.spec() == chrome::kAboutShorthangURL; } std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( diff --git a/chrome/browser/crash_recovery_browsertest.cc b/chrome/browser/crash_recovery_browsertest.cc index 58e4f31..e44bb49 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::kChromeUICrashURL), GURL(), CURRENT_TAB, + browser->OpenURL(GURL(chrome::kAboutCrashURL), 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 c53817b5..d34ab50 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::kChromeUIFlagsURL); + GURL flags_url(chrome::kAboutFlagsURL); 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::kChromeUIFlagsURL); + GURL downloads_url(chrome::kAboutFlagsURL); 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 d9fde87..e34e989 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 chrome://version/. - url = "chrome://version/"; + // Now verify about:version. + url = "about: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 6fc8368..af2dbd4 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -24,6 +24,7 @@ #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" @@ -70,8 +71,7 @@ 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 (url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUINewTabHost) { + if (web_ui_util::ChromeURLHostEquals(url, 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 1c185e2..44765ba 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -123,19 +123,6 @@ 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) { @@ -415,16 +402,20 @@ 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; @@ -755,7 +746,8 @@ bool CreateTabFunction::RunImpl() { } // Don't let extensions crash the browser or renderers. - if (IsCrashURL(url)) { + if (url == GURL(chrome::kAboutBrowserCrash) || + url == GURL(chrome::kAboutCrashURL)) { error_ = keys::kNoCrashBrowserError; return false; } @@ -871,7 +863,7 @@ bool UpdateTabFunction::RunImpl() { // -title // -favIconUrl - // Navigate the tab to a new location if the url is different. + // Navigate the tab to a new location if the url different. std::string url_string; if (update_props->HasKey(keys::kUrlKey)) { EXTENSION_FUNCTION_VALIDATE(update_props->GetString( @@ -885,7 +877,8 @@ bool UpdateTabFunction::RunImpl() { } // Don't let the extension crash the browser or renderers. - if (IsCrashURL(url)) { + if (url == GURL(chrome::kAboutBrowserCrash) || + url == GURL(chrome::kAboutCrashURL)) { error_ = keys::kNoCrashBrowserError; return false; } diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index 45e8364..cbed0a6 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -704,10 +704,13 @@ bool HistoryService::CanAddURL(const GURL& url) { url.SchemeIs(chrome::kChromeInternalScheme)) return false; - // 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; + 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. + } return true; } diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 37125d0..10d930b 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); } - // 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()))))) + // 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())))) 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(chrome::kStandardSchemeSeparator); + inserted_text.append("://"); std::string text_to_parse(text.begin(), first_nonwhite); text_to_parse.append(inserted_text); text_to_parse.append(first_nonwhite, text.end()); @@ -478,16 +478,11 @@ 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 (chrome_url || url_util::IsStandard(scheme.c_str(), + if (url_util::IsStandard(scheme.c_str(), url_parse::Component(0, static_cast<int>(scheme.length())))) { - // Replace the about: scheme with the chrome: scheme. - std::string url(chrome_url ? chrome::kChromeUIScheme : scheme); - url.append(chrome::kStandardSchemeSeparator); + std::string url(scheme); + url.append("://"); // We need to check whether the |username| is valid because it is our // responsibility to append the '@' to delineate the user information from @@ -499,8 +494,6 @@ 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); @@ -512,7 +505,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(chrome::kStandardSchemeSeparator); + fixed_scheme.append("://"); trimmed.insert(0, fixed_scheme); } diff --git a/chrome/browser/net/url_fixer_upper.h b/chrome/browser/net/url_fixer_upper.h index f5b5327..e6096bb 100644 --- a/chrome/browser/net/url_fixer_upper.h +++ b/chrome/browser/net/url_fixer_upper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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,11 +41,6 @@ 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 f49ea8f..bf08dc6 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) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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,52 +57,12 @@ static const segment_case segment_cases[] = { url_parse::Component(0, 5), // scheme url_parse::Component(), // username url_parse::Component(), // password - url_parse::Component(6, 7), // host + url_parse::Component(), // 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 @@ -258,13 +218,8 @@ 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:", "", "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"}, + {"about:", "", "about:"}, + {"about:version", "", "about:version"}, {"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 2b84f23..1498934 100644 --- a/chrome/browser/net/view_blob_internals_job_factory.cc +++ b/chrome/browser/net/view_blob_internals_job_factory.cc @@ -13,8 +13,9 @@ // static. bool ViewBlobInternalsJobFactory::IsSupportedURL(const GURL& url) { - return url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUIBlobInternalsHost; + return StartsWithASCII(url.spec(), + chrome::kBlobViewInternalsURL, + true /*case_sensitive*/); } // static. diff --git a/chrome/browser/net/view_http_cache_job_factory.cc b/chrome/browser/net/view_http_cache_job_factory.cc index 06f06d1..cc61983 100644 --- a/chrome/browser/net/view_http_cache_job_factory.cc +++ b/chrome/browser/net/view_http_cache_job_factory.cc @@ -127,13 +127,12 @@ int ViewHttpCacheJob::Core::Start(const net::URLRequest& request, AddRef(); // Released on OnIOComplete(). std::string cache_key = - request.url().spec().substr(strlen(chrome::kChromeUINetworkViewCacheURL)); + request.url().spec().substr(strlen(chrome::kNetworkViewCacheURL)); int rv; if (cache_key.empty()) { rv = cache_helper_.GetContentsHTML(request.context(), - chrome::kChromeUINetworkViewCacheURL, - &data_, + chrome::kNetworkViewCacheURL, &data_, &callback_); } else { rv = cache_helper_.GetEntryInfoHTML(cache_key, request.context(), @@ -184,8 +183,8 @@ void ViewHttpCacheJob::Core::OnIOComplete(int result) { // Static. bool ViewHttpCacheJobFactory::IsSupportedURL(const GURL& url) { - return url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUINetworkViewCacheHost; + return StartsWithASCII(url.spec(), chrome::kNetworkViewCacheURL, + true /*case_sensitive*/); } // 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 eccab4e..9b5718c 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::kChromeUICloudPrintSetupHost, MessageLoop::current()) { + : DataSource(chrome::kCloudPrintSetupHost, 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 f80240d..6cb1932 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 kChromeUICloudPrintResourcesURL as the URL to visit. That is +// hands in the kCloudPrintResourcesURL 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::kChromeUICloudPrintResourcesURL); + params_.url = GURL(chrome::kCloudPrintResourcesURL); 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 688f5e4..a200332 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::kChromeUICloudPrintResourcesURL)); + StrEq(chrome::kCloudPrintResourcesURL)); 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 71aa909..4b228a8 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1588,9 +1588,11 @@ bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { if (active_entry->IsViewSourceMode()) return false; - // 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)) + // 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")) 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 1e57299..dfe1c54 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 chrome://credits/ and make sure the page loads +// Restore tab with special URL about: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::kChromeUICreditsURL); + const GURL special_url(chrome::kAboutCreditsURL); 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::kChromeUICreditsURL); + const GURL special_url(chrome::kAboutCreditsURL); 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 8750483..ea3977e 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -22,6 +22,7 @@ #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" @@ -1103,10 +1104,9 @@ std::vector<int> TabStripModel::GetIndicesForCommand(int index) const { bool TabStripModel::IsNewTabAtEndOfTabStrip( TabContentsWrapper* contents) const { const GURL& url = contents->tab_contents()->GetURL(); - return url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUINewTabHost && - contents == GetContentsAt(count() - 1) && - contents->controller().entry_count() == 1; + return web_ui_util::ChromeURLHostEquals(url, 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 405003a..629d5d3 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -96,6 +96,7 @@ #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" @@ -1611,8 +1612,7 @@ void Browser::ToggleFullscreenMode() { void Browser::Search() { // If the NTP is showing, close it. const GURL& url = GetSelectedTabContents()->GetURL(); - if (url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUINewTabHost) { + if (web_ui_util::ChromeURLHostEquals(url, 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 06238dd..a401f54 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc @@ -35,6 +35,7 @@ #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" @@ -606,8 +607,8 @@ void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, if (!url.is_valid()) return; - bool url_is_newtab = url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUINewTabHost; + bool url_is_newtab = + web_ui_util::ChromeURLHostEquals(url, 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 96a5bb1..29b430a 100644 --- a/chrome/browser/ui/webui/BidiCheckerWebUITest.cc +++ b/chrome/browser/ui/webui/BidiCheckerWebUITest.cc @@ -63,6 +63,10 @@ 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 0e7f85f..6717ab4 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc @@ -220,8 +220,9 @@ void URLRequestChromeJob::StartAsync() { namespace { bool IsViewAppCacheInternalsURL(const GURL& url) { - return url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUIAppCacheInternalsHost; + return StartsWithASCII(url.spec(), + chrome::kAppCacheViewInternalsURL, + true /*case_sensitive*/); } 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 f5bdd6b..56060bc 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc @@ -100,7 +100,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::kChromeUICloudPrintResourcesHost) + if (url.host() == chrome::kCloudPrintResourcesHost) return &NewWebUI<ExternalHtmlDialogUI>; // This will get called a lot to check all URLs, so do a quick check of other @@ -111,7 +111,7 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, return NULL; if (url.host() == chrome::kChromeUISyncResourcesHost || - url.host() == chrome::kChromeUICloudPrintSetupHost) + url.host() == chrome::kCloudPrintSetupHost) return &NewWebUI<HtmlDialogUI>; // Special case the new tab page. In older versions of Chrome, the new tab @@ -122,9 +122,8 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, url.SchemeIs(chrome::kChromeInternalScheme)) return &NewWebUI<NewTabUI>; - // Return a generic Web UI so chrome:chrome-urls can navigate to Web UI pages. - if (url.host() == chrome::kChromeUIAboutHost || - url.host() == chrome::kChromeUIChromeURLsHost) + // Give about:about a generic Web UI so it can navigate to pages with Web UIs. + if (url.spec() == chrome::kChromeUIAboutAboutURL) return &NewWebUI<ChromeWebUI>; // We must compare hosts only since some of the Web UIs append extra stuff @@ -255,11 +254,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 || - // 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); + // 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; } WebUI* ChromeWebUIFactory::CreateWebUIForURL( @@ -306,7 +305,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 f0640a0..970e62e 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 chrome://hang/ into two NTP tabs, ensuring we don't crash. +// Loads about:hang into two NTP tabs, ensuring we don't crash. // See http://crbug.com/59859. -TEST_F(NewTabUITest, ChromeHangInNTP) { +TEST_F(NewTabUITest, AboutHangInNTP) { scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); ASSERT_TRUE(window.get()); @@ -93,15 +93,15 @@ TEST_F(NewTabUITest, ChromeHangInNTP) { scoped_refptr<TabProxy> tab = window->GetActiveTab(); ASSERT_TRUE(tab.get()); - // Navigate to chrome://hang/ to stall the process. - ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kChromeUIHangURL))); + // Navigate to about:hang to stall the process. + ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); - // Visit chrome://hang/ again in another NTP. Don't bother waiting for the + // Visit about: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::kChromeUIHangURL))); + ASSERT_TRUE(tab2->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); } // 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 chrome://hang/ to stall the process. - ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kChromeUIHangURL))); + // Navigate to about:hang to stall the process. + ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); // 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 04f43b4..70b8216 100644 --- a/chrome/browser/ui/webui/options/about_page_handler.cc +++ b/chrome/browser/ui/webui/options/about_page_handler.cc @@ -187,14 +187,16 @@ 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. + // 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. 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::kChromeUICreditsURL); + "license_link_1" : "license_link_0", chrome::kChromeUIAboutCreditsURL); #if defined(OS_CHROMEOS) std::string cros_text = @@ -213,7 +215,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::kChromeUIOSCreditsURL); + chrome::kChromeUIAboutOSCreditsURL); #endif // webkit diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc index 4f0c72e..be9ad89 100644 --- a/chrome/browser/ui/webui/options/options_ui.cc +++ b/chrome/browser/ui/webui/options/options_ui.cc @@ -282,6 +282,10 @@ 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 ee854ac..b6f49b3 100644 --- a/chrome/browser/ui/webui/web_ui_util.cc +++ b/chrome/browser/ui/webui/web_ui_util.cc @@ -7,6 +7,9 @@ #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" @@ -39,4 +42,10 @@ 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 2a7743f..0a0eebf 100644 --- a/chrome/browser/ui/webui/web_ui_util.h +++ b/chrome/browser/ui/webui/web_ui_util.h @@ -8,6 +8,7 @@ #include <string> +class GURL; class SkBitmap; namespace web_ui_util { @@ -24,6 +25,10 @@ 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_ diff --git a/chrome/common/about_handler.cc b/chrome/common/about_handler.cc index fded391..6e3e152 100644 --- a/chrome/common/about_handler.cc +++ b/chrome/common/about_handler.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -11,16 +11,18 @@ namespace chrome_about_handler { // This needs to match up with about_urls_handlers in // chrome/renderer/about_handler.cc. const char* const about_urls[] = { - chrome::kChromeUICrashURL, - chrome::kChromeUIKillURL, - chrome::kChromeUIHangURL, - chrome::kChromeUIShorthangURL, + chrome::kAboutCrashURL, + chrome::kAboutKillURL, + chrome::kAboutHangURL, + chrome::kAboutShorthangURL, NULL, }; const size_t about_urls_size = arraysize(about_urls); +const char* const kAboutScheme = "about"; + bool WillHandle(const GURL& url) { - if (!url.SchemeIs(chrome::kChromeUIScheme)) + if (url.scheme() != kAboutScheme) return false; const char* const* url_handler = about_urls; diff --git a/chrome/common/about_handler.h b/chrome/common/about_handler.h index 5de13ee..49b16ad 100644 --- a/chrome/common/about_handler.h +++ b/chrome/common/about_handler.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -14,6 +14,7 @@ namespace chrome_about_handler { extern const char* const about_urls[]; extern const size_t about_urls_size; // Only used for testing +extern const char* const kAboutScheme; // Returns true if the URL is one that AboutHandler will handle when // AboutHandler::MaybeHandle is called. diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 3cfe859..e2e0d1d 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -52,15 +52,14 @@ const char kAboutVersionURL[] = "about:version"; // to be used for testing. const char kAboutBrowserCrash[] = "about:inducebrowsercrashforrealz"; -const char kChromeUIAboutURL[] = "chrome://about/"; +const char kChromeUIAboutAboutURL[] = "chrome://about/about/"; +const char kChromeUIAboutCreditsURL[] = "chrome://about/credits/"; +const char kChromeUIAboutURL[] = "chrome://settings/about/"; const char kChromeUIBookmarksURL[] = "chrome://bookmarks/"; const char kChromeUIBugReportURL[] = "chrome://bugreport/"; -const char kChromeUICloudPrintResourcesURL[] = "chrome://cloudprintresources/"; const char kChromeUIConflictsURL[] = "chrome://conflicts/"; const char kChromeUIConstrainedHTMLTestURL[] = "chrome://constrained-test/"; const char kChromeUICrashesURL[] = "chrome://crashes/"; -const char kChromeUICrashURL[] = "chrome://crash/"; -const char kChromeUICreditsURL[] = "chrome://credits/"; const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/"; const char kChromeUIDownloadsURL[] = "chrome://downloads/"; const char kChromeUIExtensionIconURL[] = "chrome://extension-icon/"; @@ -68,23 +67,17 @@ const char kChromeUIExtensionsURL[] = "chrome://extensions/"; const char kChromeUIFaviconURL[] = "chrome://favicon/"; const char kChromeUIFlagsURL[] = "chrome://flags/"; const char kChromeUIFlashURL[] = "chrome://flash/"; -const char kChromeUIHangURL[] = "chrome://hang/"; const char kChromeUIHistory2URL[] = "chrome://history2/"; const char kChromeUIHistoryURL[] = "chrome://history/"; -const char kChromeUIIPCURL[] = "chrome://ipc/"; const char kChromeUIKeyboardURL[] = "chrome://keyboard/"; -const char kChromeUIKillURL[] = "chrome://kill/"; -const char kChromeUIMemoryRedirectURL[] = "chrome://memory-redirect/"; -const char kChromeUINetworkViewCacheURL[] = "chrome://view-http-cache/"; const char kChromeUINewTabURL[] = "chrome://newtab/"; const char kChromeUIPluginsURL[] = "chrome://plugins/"; const char kChromeUIPrintURL[] = "chrome://print/"; const char kChromeUISettingsURL[] = "chrome://settings/"; -const char kChromeUIShorthangURL[] = "chrome://shorthang/"; const char kChromeUITextfieldsURL[] = "chrome://textfields/"; -const char kChromeUIVersionURL[] = "chrome://version/"; #if defined(OS_CHROMEOS) +const char kChromeUIAboutOSCreditsURL[] = "chrome://about/os-credits/"; const char kChromeUIActivationMessage[] = "chrome://activationmessage/"; const char kChromeUIActiveDownloadsURL[] = "chrome://active-downloads/"; const char kChromeUIChooseMobileNetworkURL[] = @@ -96,7 +89,6 @@ const char kChromeUIKeyboardOverlayURL[] = "chrome://keyboardoverlay/"; const char kChromeUIMediaplayerURL[] = "chrome://mediaplayer/"; const char kChromeUIMobileSetupURL[] = "chrome://mobilesetup/"; const char kChromeUIOobeURL[] = "chrome://oobe/"; -const char kChromeUIOSCreditsURL[] = "chrome://os-credits/"; const char kChromeUIProxySettingsURL[] = "chrome://proxy-settings/"; const char kChromeUIRegisterPageURL[] = "chrome://register/"; const char kChromeUISlideshowURL[] = "chrome://slideshow/"; @@ -108,104 +100,79 @@ const char kChromeUIEnterpriseEnrollmentURL[] = #endif // Keep this list sorted please. -const char kChromeUIAboutHost[] = "about"; -const char kChromeUIAppCacheInternalsHost[] = "appcache-internals"; -const char kChromeUIBlankHost[] = "blank"; -const char kChromeUIBlobInternalsHost[] = "blob-internals"; const char kChromeUIBookmarksHost[] = "bookmarks"; -const char kChromeUIBrowserCrashHost[] = "inducebrowsercrashforrealz"; const char kChromeUIBugReportHost[] = "bugreport"; -const char kChromeUICacheHost[] = "cache"; -const char kChromeUIChromeURLsHost[] = "chrome-urls"; -const char kChromeUICloudPrintResourcesHost[] = "cloudprintresources"; -const char kChromeUICloudPrintSetupHost[] = "cloudprintsetup"; const char kChromeUIConflictsHost[] = "conflicts"; -const char kChromeUIConstrainedHTMLTestHost[] = "constrained-test"; -const char kChromeUICrashHost[] = "crash"; const char kChromeUICrashesHost[] = "crashes"; -const char kChromeUICreditsHost[] = "credits"; -const char kChromeUIDefaultHost[] = "version"; const char kChromeUIDevToolsHost[] = "devtools"; const char kChromeUIDialogHost[] = "dialog"; -const char kChromeUIDNSHost[] = "dns"; const char kChromeUIDownloadsHost[] = "downloads"; const char kChromeUIExtensionIconHost[] = "extension-icon"; const char kChromeUIExtensionsHost[] = "extensions"; const char kChromeUIFaviconHost[] = "favicon"; +const char kChromeUITouchIconHost[] = "touch-icon"; const char kChromeUIFlagsHost[] = "flags"; const char kChromeUIFlashHost[] = "flash"; -const char kChromeUIGpuHost[] = "gpu"; -const char kChromeUIGpuCleanHost[] = "gpuclean"; -const char kChromeUIGpuCrashHost[] = "gpucrash"; -const char kChromeUIGpuHangHost[] = "gpuhang"; const char kChromeUIGpuInternalsHost[] = "gpu-internals"; -const char kChromeUIHangHost[] = "hang"; -const char kChromeUIHistory2Host[] = "history2"; const char kChromeUIHistoryHost[] = "history"; -const char kChromeUIHistogramsHost[] = "histograms"; -const char kChromeUIIPCHost[] = "ipc"; +const char kChromeUIHistory2Host[] = "history2"; +const char kChromeUIInspectorHost[] = "inspector"; const char kChromeUIKeyboardHost[] = "keyboard"; -const char kChromeUIKillHost[] = "kill"; -const char kChromeUIMemoryHost[] = "memory"; -const char kChromeUIMemoryRedirectHost[] = "memory-redirect"; const char kChromeUINetInternalsHost[] = "net-internals"; -const char kChromeUINetworkViewCacheHost[] = "view-http-cache"; const char kChromeUINewTabHost[] = "newtab"; const char kChromeUIPluginsHost[] = "plugins"; const char kChromeUIPrintHost[] = "print"; const char kChromeUIResourcesHost[] = "resources"; +const char kChromeUIScreenshotPath[] = "screenshots"; const char kChromeUISettingsHost[] = "settings"; -const char kChromeUIShorthangHost[] = "shorthang"; -const char kChromeUIStatsHost[] = "stats"; -const char kChromeUISyncHost[] = "sync"; const char kChromeUISyncInternalsHost[] = "sync-internals"; const char kChromeUISyncResourcesHost[] = "syncresources"; -const char kChromeUITasksHost[] = "tasks"; -const char kChromeUITCMallocHost[] = "tcmalloc"; const char kChromeUITextfieldsHost[] = "textfields"; -const char kChromeUITermsHost[] = "terms"; -const char kChromeUITouchIconHost[] = "touch-icon"; -const char kChromeUIVersionHost[] = "version"; - -const char kChromeUIScreenshotPath[] = "screenshots"; const char kChromeUIThemePath[] = "theme"; const char kChromeUIThumbnailPath[] = "thumb"; -#if defined(OS_LINUX) -const char kChromeUILinuxProxyConfigHost[] = "linux-proxy-config"; -const char kChromeUISandboxHost[] = "sandbox"; -#endif - #if defined(OS_CHROMEOS) -const char kChromeUIActivationMessageHost[] = "activationmessage"; const char kChromeUIActiveDownloadsHost[] = "active-downloads"; +const char kChromeUIActivationMessageHost[] = "activationmessage"; const char kChromeUIChooseMobileNetworkHost[] = "choose-mobile-network"; const char kChromeUICollectedCookiesHost[] = "collected-cookies"; -const char kChromeUIEnterpriseEnrollmentHost[] = "enterprise-enrollment"; const char kChromeUIHttpAuthHost[] = "http-auth"; const char kChromeUIImageBurnerHost[] = "imageburner"; const char kChromeUIKeyboardOverlayHost[] = "keyboardoverlay"; -const char kChromeUILoginContainerHost[] = "login-container"; -const char kChromeUILoginHost[] = "login"; const char kChromeUIMediaplayerHost[] = "mediaplayer"; const char kChromeUIMobileSetupHost[] = "mobilesetup"; -const char kChromeUINetworkHost[] = "network"; const char kChromeUIOobeHost[] = "oobe"; -const char kChromeUIOSCreditsHost[] = "os-credits"; const char kChromeUIProxySettingsHost[] = "proxy-settings"; const char kChromeUIRegisterPageHost[] = "register"; const char kChromeUISlideshowHost[] = "slideshow"; const char kChromeUISimUnlockHost[] = "sim-unlock"; const char kChromeUISystemInfoHost[] = "system"; -const char kChromeUIUserImageHost[] = "userimage"; - const char kChromeUIMenu[] = "menu"; const char kChromeUIWrenchMenu[] = "wrench-menu"; const char kChromeUINetworkMenu[] = "network-menu"; - -const char kEULAPathFormat[] = "/usr/share/chromeos-assets/eula/%s/eula.html"; +const char kChromeUIUserImageHost[] = "userimage"; +const char kChromeUIEnterpriseEnrollmentHost[] = "enterprise-enrollment"; +const char kChromeUILoginContainerHost[] = "login-container"; +const char kChromeUILoginHost[] = "login"; #endif +const char kAppCacheViewInternalsURL[] = "chrome://appcache-internals/"; + +const char kBlobViewInternalsURL[] = "chrome://blob-internals/"; + +const char kCloudPrintResourcesURL[] = "chrome://cloudprintresources/"; +const char kCloudPrintResourcesHost[] = "cloudprintresources"; +const char kCloudPrintSetupHost[] = "cloudprintsetup"; + +const char kNetworkViewInternalsURL[] = "chrome://net-internals/"; +const char kNetworkViewCacheURL[] = "chrome://view-http-cache/"; + +const char kSyncViewInternalsURL[] = "chrome://sync-internals/"; +const char kSyncGoogleDashboardURL[] = "https://www.google.com/dashboard/"; + +// GPU sub pages +const char kGpuInternalsURL[] = "chrome://gpu-internals/"; + // Option sub pages. const char kAdvancedOptionsSubPage[] = "advanced"; const char kAutofillSubPage[] = "autofill"; @@ -225,8 +192,6 @@ const char kInternetOptionsSubPage[] = "internet"; const char kSystemOptionsSubPage[] = "system"; #endif -const char kSyncGoogleDashboardURL[] = "https://www.google.com/dashboard/"; - const char kPasswordManagerLearnMoreURL[] = #if defined(OS_CHROMEOS) "https://www.google.com/support/chromeos/bin/answer.py?answer=95606"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index a76480a..c3ca665 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -8,7 +8,6 @@ #define CHROME_COMMON_URL_CONSTANTS_H_ #pragma once -#include "build/build_config.h" #include "content/common/url_constants.h" namespace chrome { @@ -45,15 +44,14 @@ extern const char kAboutVersionURL[]; // chrome: URLs (including schemes). Should be kept in sync with the // components below. +extern const char kChromeUIAboutAboutURL[]; +extern const char kChromeUIAboutCreditsURL[]; extern const char kChromeUIAboutURL[]; extern const char kChromeUIBookmarksURL[]; extern const char kChromeUIBugReportURL[]; -extern const char kChromeUICloudPrintResourcesURL[]; extern const char kChromeUIConflictsURL[]; extern const char kChromeUIConstrainedHTMLTestURL[]; extern const char kChromeUICrashesURL[]; -extern const char kChromeUICrashURL[]; -extern const char kChromeUICreditsURL[]; extern const char kChromeUIDevToolsURL[]; extern const char kChromeUIDownloadsURL[]; extern const char kChromeUIExtensionIconURL[]; @@ -61,23 +59,17 @@ extern const char kChromeUIExtensionsURL[]; extern const char kChromeUIFlagsURL[]; extern const char kChromeUIFlashURL[]; extern const char kChromeUIFaviconURL[]; -extern const char kChromeUIHangURL[]; extern const char kChromeUIHistory2URL[]; extern const char kChromeUIHistoryURL[]; -extern const char kChromeUIIPCURL[]; extern const char kChromeUIKeyboardURL[]; -extern const char kChromeUIKillURL[]; -extern const char kChromeUIMemoryRedirectURL[]; -extern const char kChromeUINetworkViewCacheURL[]; extern const char kChromeUINewTabURL[]; extern const char kChromeUIPluginsURL[]; extern const char kChromeUIPrintURL[]; extern const char kChromeUISettingsURL[]; -extern const char kChromeUIShorthangURL[]; extern const char kChromeUITextfieldsURL[]; -extern const char kChromeUIVersionURL[]; #if defined(OS_CHROMEOS) +extern const char kChromeUIAboutOSCreditsURL[]; extern const char kChromeUIActivationMessage[]; extern const char kChromeUIActiveDownloadsURL[]; extern const char kChromeUIChooseMobileNetworkURL[]; @@ -88,7 +80,6 @@ extern const char kChromeUIKeyboardOverlayURL[]; extern const char kChromeUIMediaplayerURL[]; extern const char kChromeUIMobileSetupURL[]; extern const char kChromeUIOobeURL[]; -extern const char kChromeUIOSCreditsURL[]; extern const char kChromeUIProxySettingsURL[]; extern const char kChromeUIRegisterPageURL[]; extern const char kChromeUISlideshowURL[]; @@ -98,105 +89,85 @@ extern const char kChromeUIUserImageURL[]; extern const char kChromeUIEnterpriseEnrollmentURL[]; #endif -// chrome components of URLs. Should be kept in sync with the full URLs above. -extern const char kChromeUIAboutHost[]; -extern const char kChromeUIAppCacheInternalsHost[]; -extern const char kChromeUIBlankHost[]; -extern const char kChromeUIBlobInternalsHost[]; +// chrome components of URLs. Should be kept in sync with the full URLs +// above. extern const char kChromeUIBookmarksHost[]; -extern const char kChromeUIBrowserCrashHost[]; extern const char kChromeUIBugReportHost[]; -extern const char kChromeUICacheHost[]; -extern const char kChromeUIChromeURLsHost[]; -extern const char kChromeUICloudPrintResourcesHost[]; -extern const char kChromeUICloudPrintSetupHost[]; extern const char kChromeUIConflictsHost[]; -extern const char kChromeUIConstrainedHTMLTestHost[]; -extern const char kChromeUICrashHost[]; extern const char kChromeUICrashesHost[]; -extern const char kChromeUICreditsHost[]; -extern const char kChromeUIDefaultHost[]; extern const char kChromeUIDevToolsHost[]; extern const char kChromeUIDialogHost[]; -extern const char kChromeUIDNSHost[]; extern const char kChromeUIDownloadsHost[]; extern const char kChromeUIExtensionIconHost[]; extern const char kChromeUIExtensionsHost[]; extern const char kChromeUIFaviconHost[]; +extern const char kChromeUITouchIconHost[]; extern const char kChromeUIFlagsHost[]; extern const char kChromeUIFlashHost[]; -extern const char kChromeUIGpuHost[]; -extern const char kChromeUIGpuCleanHost[]; -extern const char kChromeUIGpuCrashHost[]; -extern const char kChromeUIGpuHangHost[]; extern const char kChromeUIGpuInternalsHost[]; -extern const char kChromeUIHangHost[]; extern const char kChromeUIHistory2Host[]; extern const char kChromeUIHistoryHost[]; -extern const char kChromeUIHistogramsHost[]; -extern const char kChromeUIIPCHost[]; extern const char kChromeUIKeyboardHost[]; -extern const char kChromeUIKillHost[]; -extern const char kChromeUIMemoryHost[]; -extern const char kChromeUIMemoryRedirectHost[]; extern const char kChromeUINetInternalsHost[]; -extern const char kChromeUINetworkViewCacheHost[]; extern const char kChromeUINewTabHost[]; extern const char kChromeUIPluginsHost[]; extern const char kChromeUIPrintHost[]; extern const char kChromeUIResourcesHost[]; +extern const char kChromeUIScreenshotPath[]; extern const char kChromeUISettingsHost[]; -extern const char kChromeUIShorthangHost[]; -extern const char kChromeUIStatsHost[]; -extern const char kChromeUISyncHost[]; extern const char kChromeUISyncInternalsHost[]; extern const char kChromeUISyncResourcesHost[]; -extern const char kChromeUITasksHost[]; -extern const char kChromeUITCMallocHost[]; extern const char kChromeUITextfieldsHost[]; -extern const char kChromeUITermsHost[]; -extern const char kChromeUITouchIconHost[]; -extern const char kChromeUIVersionHost[]; - -extern const char kChromeUIScreenshotPath[]; extern const char kChromeUIThemePath[]; extern const char kChromeUIThumbnailPath[]; -#if defined(OS_LINUX) -extern const char kChromeUILinuxProxyConfigHost[]; -extern const char kChromeUISandboxHost[]; -#endif - #if defined(OS_CHROMEOS) -extern const char kChromeUIActivationMessageHost[]; extern const char kChromeUIActiveDownloadsHost[]; +extern const char kChromeUIActivationMessageHost[]; extern const char kChromeUIChooseMobileNetworkHost[]; extern const char kChromeUICollectedCookiesHost[]; -extern const char kChromeUIEnterpriseEnrollmentHost[]; extern const char kChromeUIHttpAuthHost[]; extern const char kChromeUIImageBurnerHost[]; extern const char kChromeUIKeyboardOverlayHost[]; -extern const char kChromeUILoginContainerHost[]; -extern const char kChromeUILoginHost[]; extern const char kChromeUIMediaplayerHost[]; extern const char kChromeUIMobileSetupHost[]; -extern const char kChromeUINetworkHost[]; extern const char kChromeUIOobeHost[]; -extern const char kChromeUIOSCreditsHost[]; extern const char kChromeUIProxySettingsHost[]; extern const char kChromeUIRegisterPageHost[]; extern const char kChromeUISlideshowHost[]; extern const char kChromeUISimUnlockHost[]; extern const char kChromeUISystemInfoHost[]; -extern const char kChromeUIUserImageHost[]; - extern const char kChromeUIMenu[]; extern const char kChromeUIWrenchMenu[]; extern const char kChromeUINetworkMenu[]; - -extern const char kEULAPathFormat[]; +extern const char kChromeUIUserImageHost[]; +extern const char kChromeUIEnterpriseEnrollmentHost[]; +extern const char kChromeUILoginContainerHost[]; +extern const char kChromeUILoginHost[]; #endif +// AppCache related URL. +extern const char kAppCacheViewInternalsURL[]; + +// Blob related URL. +extern const char kBlobViewInternalsURL[]; + +// Cloud Print dialog URL components. +extern const char kCloudPrintResourcesURL[]; +extern const char kCloudPrintResourcesHost[]; +extern const char kCloudPrintSetupHost[]; + +// Network related URLs. +extern const char kNetworkViewCacheURL[]; +extern const char kNetworkViewInternalsURL[]; + +// Sync related URLs. +extern const char kSyncViewInternalsURL[]; +extern const char kSyncGoogleDashboardURL[]; + +// GPU related URLs +extern const char kGpuInternalsURL[]; + // Options sub-pages. extern const char kAdvancedOptionsSubPage[]; extern const char kAutofillSubPage[]; @@ -216,8 +187,6 @@ extern const char kInternetOptionsSubPage[]; extern const char kSystemOptionsSubPage[]; #endif -extern const char kSyncGoogleDashboardURL[]; - extern const char kPasswordManagerLearnMoreURL[]; // General help link for Chrome. diff --git a/chrome/renderer/about_handler.cc b/chrome/renderer/about_handler.cc index de4b57a..e748aa1 100644 --- a/chrome/renderer/about_handler.cc +++ b/chrome/renderer/about_handler.cc @@ -1,14 +1,12 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. #include "chrome/renderer/about_handler.h" -#include "base/logging.h" #include "base/process_util.h" #include "base/threading/platform_thread.h" #include "chrome/common/about_handler.h" -#include "content/common/url_constants.h" #include "googleurl/src/gurl.h" typedef void (*AboutHandlerFuncPtr)(); @@ -25,7 +23,7 @@ static const AboutHandlerFuncPtr about_urls_handlers[] = { // static bool AboutHandler::MaybeHandle(const GURL& url) { - if (!url.SchemeIs(chrome::kChromeUIScheme)) + if (url.scheme() != chrome_about_handler::kAboutScheme) return false; int about_urls_handler_index = 0; @@ -43,7 +41,8 @@ bool AboutHandler::MaybeHandle(const GURL& url) { // static void AboutHandler::AboutCrash() { - CHECK(false); + int *zero = NULL; + *zero = 0; // Null pointer dereference: kaboom! } // static diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 4e5ba9b..3e4981e 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -134,7 +134,7 @@ TEST_F(AutomationProxyVisibleTest, MAYBE_WindowGetViewBounds) { ASSERT_TRUE(tab1->GetCurrentURL(&tab1_url)); // Add another tab so we can simulate dragging. - ASSERT_TRUE(browser->AppendTab(GURL(chrome::kChromeUIVersionURL))); + ASSERT_TRUE(browser->AppendTab(GURL("about:"))); scoped_refptr<TabProxy> tab2(browser->GetTab(1)); ASSERT_TRUE(tab2.get()); diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc index 4ef3306..f1f214c 100644 --- a/content/browser/child_process_security_policy_unittest.cc +++ b/content/browser/child_process_security_policy_unittest.cc @@ -45,8 +45,6 @@ TEST_F(ChildProcessSecurityPolicyTest, IsWebSafeSchemeTest) { EXPECT_FALSE(p->IsWebSafeScheme("registered-web-safe-scheme")); p->RegisterWebSafeScheme("registered-web-safe-scheme"); EXPECT_TRUE(p->IsWebSafeScheme("registered-web-safe-scheme")); - - EXPECT_FALSE(p->IsWebSafeScheme(chrome::kChromeUIScheme)); } TEST_F(ChildProcessSecurityPolicyTest, IsPseudoSchemeTest) { @@ -59,8 +57,6 @@ TEST_F(ChildProcessSecurityPolicyTest, IsPseudoSchemeTest) { EXPECT_FALSE(p->IsPseudoScheme("registered-pseudo-scheme")); p->RegisterPseudoScheme("registered-pseudo-scheme"); EXPECT_TRUE(p->IsPseudoScheme("registered-pseudo-scheme")); - - EXPECT_FALSE(p->IsPseudoScheme(chrome::kChromeUIScheme)); } TEST_F(ChildProcessSecurityPolicyTest, IsDisabledSchemeTest) { @@ -123,7 +119,6 @@ TEST_F(ChildProcessSecurityPolicyTest, AboutTest) { EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:CrASh"))); EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("abOuT:cAChe"))); - // These requests for about: pages should be denied. p->GrantRequestURL(kRendererID, GURL(chrome::kTestMemoryURL)); EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kTestMemoryURL))); @@ -136,16 +131,6 @@ TEST_F(ChildProcessSecurityPolicyTest, AboutTest) { p->GrantRequestURL(kRendererID, GURL(chrome::kTestHangURL)); EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kTestHangURL))); - // These requests for chrome:// pages should be granted. - p->GrantRequestURL(kRendererID, GURL(chrome::kTestNewTabURL)); - EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(chrome::kTestNewTabURL))); - - p->GrantRequestURL(kRendererID, GURL(chrome::kTestHistoryURL)); - EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(chrome::kTestHistoryURL))); - - p->GrantRequestURL(kRendererID, GURL(chrome::kTestBookmarksURL)); - EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(chrome::kTestBookmarksURL))); - p->Remove(kRendererID); } diff --git a/content/browser/site_instance.cc b/content/browser/site_instance.cc index 53caf57..610de02 100644 --- a/content/browser/site_instance.cc +++ b/content/browser/site_instance.cc @@ -17,10 +17,12 @@ static bool IsURLSameAsAnySiteInstance(const GURL& url) { if (!url.is_valid()) return false; - // We treat javascript: as the same site as any URL since it is actually - // a modifier on existing pages. - if (url.SchemeIs(chrome::kJavaScriptScheme)) + // We treat javascript: and about:crash as the same site as any URL since they + // are actually modifiers on existing pages. + if (url.SchemeIs(chrome::kJavaScriptScheme) || + url.spec() == chrome::kAboutCrashURL) { return true; + } return content::GetContentClient()->browser()->IsURLSameAsAnySiteInstance(url); diff --git a/content/browser/site_instance_unittest.cc b/content/browser/site_instance_unittest.cc index 6931e5a..8bda89e 100644 --- a/content/browser/site_instance_unittest.cc +++ b/content/browser/site_instance_unittest.cc @@ -24,6 +24,10 @@ namespace { +// TODO(estade): this shouldn't need to be chrome:, but it does (or else GURL +// doesn't think that the webui URLs have a host). Figure out where this is +// coming from and fix it. +const char kWebUIScheme[] = "chrome"; const char kSameAsAnyInstanceURL[] = "about:internets"; class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory { @@ -32,7 +36,7 @@ class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory { return HasWebUIScheme(url); } virtual bool HasWebUIScheme(const GURL& url) const { - return url.SchemeIs(chrome::kChromeUIScheme); + return url.SchemeIs(kWebUIScheme); } }; @@ -43,8 +47,7 @@ class SiteInstanceTestBrowserClient : public content::ContentBrowserClient { } virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE { - return url == GURL(kSameAsAnyInstanceURL) || - url == GURL(chrome::kAboutCrashURL); + return url.spec() == kSameAsAnyInstanceURL; } private: @@ -489,12 +492,14 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) { extension2_instance->GetProcess()); // Create some WebUI instances and make sure they share a process. - scoped_refptr<SiteInstance> webui1_instance(CreateSiteInstance(&rph_factory, - GURL(chrome::kChromeUIScheme + std::string("://newtab")))); + scoped_refptr<SiteInstance> webui1_instance( + CreateSiteInstance(&rph_factory, + GURL(kWebUIScheme + std::string("://newtab")))); policy->GrantWebUIBindings(webui1_instance->GetProcess()->id()); - scoped_refptr<SiteInstance> webui2_instance( CreateSiteInstance(&rph_factory, - GURL(chrome::kChromeUIScheme + std::string("://history")))); + scoped_refptr<SiteInstance> webui2_instance( + CreateSiteInstance(&rph_factory, + GURL(kWebUIScheme + std::string("://history")))); scoped_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess()); EXPECT_EQ(webui1_instance->GetProcess(), webui2_instance->GetProcess()); |