Chromium Code Reviews| Index: chrome/browser/browser_about_handler.cc |
| diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc |
| index a2fc6b10d3b8a7f46badb0d83d9f2b2465fed211..f43e80873003074fa1bea10fcb2e7851c4e80905 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" |
| @@ -103,107 +104,95 @@ 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 about:about. |
| +// These paths will also be suggested by BuiltinProvider. |
| +const char *kAllAboutPaths[] = { |
| + chrome::kChromeUIAboutHost, |
| + chrome::kChromeUIAppCacheInternalsHost, |
| + chrome::kChromeUIBlobInternalsHost, |
| + 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, |
| -#ifdef TRACK_ALL_TASK_OBJECTS |
| - kTasksPath, |
| -#endif // TRACK_ALL_TASK_OBJECTS |
| - kTcmallocPath, |
| - kTermsPath, |
| - kVersionPath, |
| +// Debug about paths, presented without links in about:about. |
| +// These paths will not be suggested by BuiltinProvider. |
| +const char *kDebugAboutPaths[] = { |
| + chrome::kChromeUICrashHost, |
| + chrome::kChromeUIKillHost, |
| + chrome::kChromeUIHangHost, |
| + chrome::kChromeUIShorthangHost, |
| + chrome::kChromeUIGpuCleanHost, |
| + chrome::kChromeUIGpuCrashHost, |
| + chrome::kChromeUIGpuHangHost |
| +}; |
| + |
| +// AboutSource handles these about: and chrome: paths. |
| +const char *kAboutSourceNames[] = { |
| + chrome::kChromeUIAboutHost, |
| + chrome::kChromeUICreditsHost, |
| + chrome::kChromeUIDNSHost, |
| + chrome::kChromeUIHistogramsHost, |
| #if defined(OS_LINUX) |
| - kSandboxPath, |
| + chrome::kChromeUILinuxProxyConfigHost, |
| #endif |
| + chrome::kChromeUIMemoryHost, |
| + chrome::kChromeUIMemoryRedirectHost, |
| #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\">"; |
| -} |
| +#if defined(OS_LINUX) |
| + chrome::kChromeUISandboxHost, |
| +#endif |
| + chrome::kChromeUIStatsHost, |
| +#ifdef TRACK_ALL_TASK_OBJECTS |
| + chrome::kChromeUITasksHost, |
| +#endif |
| +#if defined(USE_TCMALLOC) |
| + chrome::kChromeUITCMallocHost, |
| +#endif |
| + chrome::kChromeUITermsHost, |
| + chrome::kChromeUIVersionHost |
| +}; |
| 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"; |
| } |
| @@ -220,14 +209,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(); |
| @@ -298,10 +316,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. |
| @@ -345,30 +363,14 @@ std::string AboutAbout() { |
| 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://"; |
| - 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"; |
| + html += "<li><a href='chrome://" + *i + "/'>about:" + *i + "</a></li>\n"; |
|
abarth-chromium
2011/05/31 19:27:54
It's strange that the link says "about:i" but the
msw
2011/05/31 20:58:25
Done. Further cleanup is slated for crbug.com/7392
|
| } |
| - 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(debug); i++) |
| - html += "<li>about:" + std::string(debug[i]) + "</li>\n"; |
| + for (size_t i = 0; i < arraysize(kDebugAboutPaths); i++) |
| + html += "<li>about:" + std::string(kDebugAboutPaths[i]) + "</li>\n"; |
| html += "</ul>\n</body></html>"; |
| return html; |
| } |
| @@ -602,7 +604,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(); |
| @@ -1022,51 +1024,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; |
| @@ -1075,19 +1066,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) { |
| + } else if (host == chrome::kChromeUIAboutHost) { |
| response = AboutAbout(); |
| #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; |
| @@ -1096,9 +1087,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 |
| } |
| @@ -1106,11 +1097,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); |
| } |
| @@ -1274,30 +1264,13 @@ 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)) |
| + if (!url->SchemeIs(chrome::kAboutScheme) && |
| + !url->SchemeIs(chrome::kChromeUIScheme)) |
| return false; |
| // about:blank is special. Frames are allowed to access about:blank, |
| @@ -1306,114 +1279,52 @@ bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) { |
| 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; |
| - } |
| - |
| - // 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; |
| - } |
| + // 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; |
| - // Handle URL to crash the browser process. |
| - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBrowserCrash)) { |
| + // Set the scheme to chrome://. WebKit treats all about: URLS as about:blank, |
| + // so we need another scheme to display content. Doing this scheme fixup in |
| + // URLFixerUpper::FixupURL would break extensions that override about: URLs. |
| + *url = URLFixerUpper::FixupChromeURL(*url); |
| + |
| + std::string host(url->host()); |
| + // 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); |
|
abarth-chromium
2011/05/31 19:27:54
Do we need to do all the replacements? It would b
msw
2011/05/31 20:58:25
Only the host may need replacement here. The schem
|
| + |
| + // 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; |
|
abarth-chromium
2011/05/31 19:27:54
This needs to be "volatile" right?
msw
2011/05/31 20:58:25
I'm following pkasting's offline suggestion to cha
|
| *bad_pointer = 42; |
| return true; |
| - } |
| - |
| - // Handle URLs to wreck the gpu process. |
| - if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuCleanURL)) { |
| + } 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)); |
| -} |
| - |
| // This function gets called with the fixed-up chrome: URLs, so we have to |
| // compare against those instead of "about:blah". |
| bool HandleNonNavigationAboutURL(const GURL& url) { |