| Index: chrome/browser/ui/webui/about_ui.cc
|
| ===================================================================
|
| --- chrome/browser/ui/webui/about_ui.cc (revision 110966)
|
| +++ chrome/browser/ui/webui/about_ui.cc (working copy)
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/browser_about_handler.h"
|
| +#include "chrome/browser/ui/webui/about_ui.h"
|
|
|
| #include <algorithm>
|
| #include <string>
|
| @@ -27,6 +27,7 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/about_flags.h"
|
| +#include "chrome/browser/browser_about_handler.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/defaults.h"
|
| #include "chrome/browser/memory_details.h"
|
| @@ -49,6 +50,7 @@
|
| #include "content/browser/plugin_service.h"
|
| #include "content/browser/renderer_host/render_view_host.h"
|
| #include "content/browser/sensors/sensors_provider.h"
|
| +#include "content/browser/tab_contents/tab_contents.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/common/content_client.h"
|
| @@ -90,113 +92,8 @@
|
| using base::TimeDelta;
|
| using content::BrowserThread;
|
|
|
| -#if defined(USE_TCMALLOC)
|
| -// static
|
| -AboutTcmallocOutputs* AboutTcmallocOutputs::GetInstance() {
|
| - return Singleton<AboutTcmallocOutputs>::get();
|
| -}
|
| -
|
| -AboutTcmallocOutputs::AboutTcmallocOutputs() {}
|
| -
|
| -AboutTcmallocOutputs::~AboutTcmallocOutputs() {}
|
| -
|
| -// Glue between the callback task and the method in the singleton.
|
| -void AboutTcmallocRendererCallback(base::ProcessId pid,
|
| - const std::string& output) {
|
| - AboutTcmallocOutputs::GetInstance()->RendererCallback(pid, output);
|
| -}
|
| -#endif
|
| -
|
| namespace {
|
|
|
| -// Add paths here to be included in chrome://chrome-urls (about:about).
|
| -// These paths will also be suggested by BuiltinProvider.
|
| -const char* const kChromePaths[] = {
|
| - chrome::kChromeUIAppCacheInternalsHost,
|
| - chrome::kChromeUIBlobInternalsHost,
|
| - chrome::kChromeUIBookmarksHost,
|
| - chrome::kChromeUICacheHost,
|
| - chrome::kChromeUIChromeURLsHost,
|
| - chrome::kChromeUICrashesHost,
|
| - chrome::kChromeUICreditsHost,
|
| - chrome::kChromeUIDNSHost,
|
| - chrome::kChromeUIDownloadsHost,
|
| - chrome::kChromeUIExtensionsHost,
|
| - chrome::kChromeUIFlagsHost,
|
| - chrome::kChromeUIFlashHost,
|
| - chrome::kChromeUIGpuInternalsHost,
|
| - chrome::kChromeUIHistogramsHost,
|
| - chrome::kChromeUIHistoryHost,
|
| - chrome::kChromeUIIPCHost,
|
| - chrome::kChromeUIMediaInternalsHost,
|
| - chrome::kChromeUIMemoryHost,
|
| - chrome::kChromeUINetInternalsHost,
|
| - chrome::kChromeUINetworkViewCacheHost,
|
| - chrome::kChromeUINewTabHost,
|
| - chrome::kChromeUIPluginsHost,
|
| - chrome::kChromeUIPrintHost,
|
| - chrome::kChromeUIProfilerHost,
|
| - chrome::kChromeUIQuotaInternalsHost,
|
| - chrome::kChromeUISessionsHost,
|
| - chrome::kChromeUISettingsHost,
|
| - chrome::kChromeUIStatsHost,
|
| - chrome::kChromeUISyncInternalsHost,
|
| - chrome::kChromeUITaskManagerHost,
|
| - chrome::kChromeUITCMallocHost,
|
| - chrome::kChromeUITermsHost,
|
| - chrome::kChromeUITracingHost,
|
| - chrome::kChromeUIVersionHost,
|
| - chrome::kChromeUIWorkersHost,
|
| -#if defined(OS_WIN)
|
| - chrome::kChromeUIConflictsHost,
|
| -#endif
|
| -#if defined(OS_LINUX) || defined(OS_OPENBSD)
|
| - chrome::kChromeUILinuxProxyConfigHost,
|
| - chrome::kChromeUISandboxHost,
|
| -#endif
|
| -#if defined(OS_CHROMEOS)
|
| - chrome::kChromeUIActiveDownloadsHost,
|
| - chrome::kChromeUIChooseMobileNetworkHost,
|
| - chrome::kChromeUICryptohomeHost,
|
| - chrome::kChromeUIDiscardsHost,
|
| - chrome::kChromeUIImageBurnerHost,
|
| - chrome::kChromeUIKeyboardOverlayHost,
|
| - chrome::kChromeUILoginHost,
|
| - chrome::kChromeUINetworkHost,
|
| - chrome::kChromeUIOobeHost,
|
| - chrome::kChromeUIOSCreditsHost,
|
| - chrome::kChromeUIProxySettingsHost,
|
| - chrome::kChromeUISystemInfoHost,
|
| -#endif
|
| -};
|
| -
|
| -// AboutSource handles these chrome:// paths.
|
| -const char* const kAboutSourceNames[] = {
|
| - chrome::kChromeUIChromeURLsHost,
|
| - chrome::kChromeUICreditsHost,
|
| - chrome::kChromeUIDNSHost,
|
| - chrome::kChromeUIHistogramsHost,
|
| - chrome::kChromeUIMemoryHost,
|
| - chrome::kChromeUIMemoryRedirectHost,
|
| - chrome::kChromeUIStatsHost,
|
| - chrome::kChromeUITaskManagerHost,
|
| - chrome::kChromeUITermsHost,
|
| - chrome::kChromeUIVersionHost,
|
| -#if defined(USE_TCMALLOC)
|
| - chrome::kChromeUITCMallocHost,
|
| -#endif
|
| -#if defined(OS_LINUX) || defined(OS_OPENBSD)
|
| - chrome::kChromeUILinuxProxyConfigHost,
|
| - chrome::kChromeUISandboxHost,
|
| -#endif
|
| -#if defined(OS_CHROMEOS)
|
| - chrome::kChromeUICryptohomeHost,
|
| - chrome::kChromeUIDiscardsHost,
|
| - chrome::kChromeUINetworkHost,
|
| - chrome::kChromeUIOSCreditsHost,
|
| -#endif
|
| -};
|
| -
|
| const char kCreditsJsPath[] = "credits.js";
|
| const char kMemoryJsPath[] = "memory.js";
|
| const char kStatsJsPath[] = "stats.js";
|
| @@ -240,7 +137,6 @@
|
| // 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);
|
| }
|
| @@ -1499,128 +1395,10 @@
|
| return "text/html";
|
| }
|
|
|
| -// -----------------------------------------------------------------------------
|
| -
|
| -void InitializeAboutDataSource(const std::string& name,
|
| - content::BrowserContext* browser_context) {
|
| - Profile* profile = static_cast<Profile*>(browser_context);
|
| - ChromeURLDataManager* manager = profile->GetChromeURLDataManager();
|
| - for (size_t i = 0; i < arraysize(kAboutSourceNames); i++) {
|
| - if (name == kAboutSourceNames[i]) {
|
| - manager->AddDataSource(new AboutSource(name, profile));
|
| - return;
|
| - }
|
| - }
|
| +AboutUI::AboutUI(TabContents* contents, const std::string& name)
|
| + : ChromeWebUI(contents) {
|
| + Profile* profile = Profile::FromBrowserContext(contents->browser_context());
|
| + ChromeURLDataManager::DataSource* source = new AboutSource(name, profile);
|
| + if (source)
|
| + profile->GetChromeURLDataManager()->AddDataSource(source);
|
| }
|
| -
|
| -bool WillHandleBrowserAboutURL(GURL* url,
|
| - content::BrowserContext* browser_context) {
|
| - // 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))
|
| - return false;
|
| -
|
| - // Circumvent processing URLs that the renderer process will handle.
|
| - if (chrome_about_handler::WillHandle(*url))
|
| - return false;
|
| -
|
| - std::string host(url->host());
|
| - std::string path;
|
| - // 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;
|
| - // Redirect chrome://extensions to chrome://settings/extensions.
|
| - } else if (host == chrome::kChromeUIExtensionsHost) {
|
| - host = chrome::kChromeUISettingsHost;
|
| - path = chrome::kExtensionsSubPage;
|
| - }
|
| - GURL::Replacements replacements;
|
| - replacements.SetHostStr(host);
|
| - if (!path.empty())
|
| - replacements.SetPathStr(path);
|
| - *url = url->ReplaceComponents(replacements);
|
| -
|
| - // Handle URLs to crash the browser or wreck the gpu process.
|
| - if (host == chrome::kChromeUIBrowserCrashHost) {
|
| - // Induce an intentional crash in the browser process.
|
| - CHECK(false);
|
| - } else if (host == chrome::kChromeUIGpuCleanHost) {
|
| - GpuProcessHostUIShim* shim = GpuProcessHostUIShim::FromID(0);
|
| - if (shim)
|
| - shim->SimulateRemoveAllContext();
|
| - } else if (host == chrome::kChromeUIGpuCrashHost) {
|
| - GpuProcessHostUIShim* shim = GpuProcessHostUIShim::FromID(0);
|
| - if (shim)
|
| - shim->SimulateCrash();
|
| - } else if (host == chrome::kChromeUIGpuHangHost) {
|
| - GpuProcessHostUIShim* shim = GpuProcessHostUIShim::FromID(0);
|
| - if (shim)
|
| - shim->SimulateHang();
|
| -#if defined(OS_CHROMEOS)
|
| - } else if (host == chrome::kChromeUIRotateHost) {
|
| - sensors::ScreenOrientation change;
|
| - std::string query(url->query());
|
| - if (query == "left") {
|
| - change.upward = sensors::ScreenOrientation::LEFT;
|
| - } else if (query == "right") {
|
| - change.upward = sensors::ScreenOrientation::RIGHT;
|
| - } else if (query == "top") {
|
| - change.upward = sensors::ScreenOrientation::TOP;
|
| - } else if (query == "bottom") {
|
| - change.upward = sensors::ScreenOrientation::BOTTOM;
|
| - } else {
|
| - NOTREACHED() << "Unknown orientation";
|
| - }
|
| - sensors::Provider::GetInstance()->ScreenOrientationChanged(change);
|
| - // Nothing to communicate to the user, so show a blank page.
|
| - host = chrome::kChromeUIBlankHost;
|
| - *url = GURL(chrome::kChromeUIBlankHost);
|
| -#endif
|
| - }
|
| -
|
| - // Initialize any potentially corresponding AboutSource handler.
|
| - InitializeAboutDataSource(host, browser_context);
|
| - return true;
|
| -}
|
| -
|
| -bool HandleNonNavigationAboutURL(const GURL& url) {
|
| - // chrome://ipc/ is currently buggy, so we disable it for official builds.
|
| -#if !defined(OFFICIAL_BUILD)
|
| -
|
| -#if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED)
|
| - if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) {
|
| - // Run the dialog. This will re-use the existing one if it's already up.
|
| - browser::ShowAboutIPCDialog();
|
| - return true;
|
| - }
|
| -#endif
|
| -
|
| -#endif // OFFICIAL_BUILD
|
| -
|
| - return false;
|
| -}
|
| -
|
| -std::vector<std::string> ChromePaths() {
|
| - std::vector<std::string> paths;
|
| - paths.reserve(arraysize(kChromePaths));
|
| - for (size_t i = 0; i < arraysize(kChromePaths); i++)
|
| - paths.push_back(kChromePaths[i]);
|
| - return paths;
|
| -}
|
|
|