| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/browser_about_handler.h" | 5 #include "chrome/browser/browser_about_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/browser/net/url_fixer_upper.h" | 13 #include "chrome/browser/net/url_fixer_upper.h" |
| 14 #include "chrome/browser/ui/browser_dialogs.h" | 14 #include "chrome/browser/ui/browser_dialogs.h" |
| 15 #include "chrome/common/about_handler.h" | |
| 16 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 18 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | |
| 19 #include "content/browser/sensors/sensors_provider.h" | 17 #include "content/browser/sensors/sensors_provider.h" |
| 20 | 18 |
| 21 #if defined(USE_TCMALLOC) | 19 #if defined(USE_TCMALLOC) |
| 22 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" | 20 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" |
| 23 #endif | 21 #endif |
| 24 | 22 |
| 25 namespace { | 23 namespace { |
| 26 | 24 |
| 27 // Add paths here to be included in chrome://chrome-urls (about:about). | 25 // Add paths here to be included in chrome://chrome-urls (about:about). |
| 28 // These paths will also be suggested by BuiltinProvider. | 26 // These paths will also be suggested by BuiltinProvider. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 95 |
| 98 // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. | 96 // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. |
| 99 DCHECK((*url == GURL(chrome::kAboutBlankURL)) || | 97 DCHECK((*url == GURL(chrome::kAboutBlankURL)) || |
| 100 !url->SchemeIs(chrome::kAboutScheme)); | 98 !url->SchemeIs(chrome::kAboutScheme)); |
| 101 | 99 |
| 102 // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. | 100 // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. |
| 103 // TAB_CONTENTS_WEB handles about:blank, which frames are allowed to access. | 101 // TAB_CONTENTS_WEB handles about:blank, which frames are allowed to access. |
| 104 if (!url->SchemeIs(chrome::kChromeUIScheme)) | 102 if (!url->SchemeIs(chrome::kChromeUIScheme)) |
| 105 return false; | 103 return false; |
| 106 | 104 |
| 107 // Circumvent processing URLs that the renderer process will handle. | |
| 108 if (chrome_about_handler::WillHandle(*url)) | |
| 109 return false; | |
| 110 | |
| 111 CommandLine* cl = CommandLine::ForCurrentProcess(); | 105 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 112 bool enableUberPage = !cl->HasSwitch(switches::kDisableUberPage); | 106 bool enableUberPage = !cl->HasSwitch(switches::kDisableUberPage); |
| 113 | 107 |
| 114 std::string host(url->host()); | 108 std::string host(url->host()); |
| 115 std::string path; | 109 std::string path; |
| 116 // Replace about with chrome-urls. | 110 // Replace about with chrome-urls. |
| 117 if (host == chrome::kChromeUIAboutHost) | 111 if (host == chrome::kChromeUIAboutHost) |
| 118 host = chrome::kChromeUIChromeURLsHost; | 112 host = chrome::kChromeUIChromeURLsHost; |
| 119 // Replace cache with view-http-cache. | 113 // Replace cache with view-http-cache. |
| 120 if (host == chrome::kChromeUICacheHost) { | 114 if (host == chrome::kChromeUICacheHost) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED) | 159 #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED) |
| 166 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { | 160 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { |
| 167 // Run the dialog. This will re-use the existing one if it's already up. | 161 // Run the dialog. This will re-use the existing one if it's already up. |
| 168 browser::ShowAboutIPCDialog(); | 162 browser::ShowAboutIPCDialog(); |
| 169 return true; | 163 return true; |
| 170 } | 164 } |
| 171 #endif | 165 #endif |
| 172 | 166 |
| 173 #endif // OFFICIAL_BUILD | 167 #endif // OFFICIAL_BUILD |
| 174 | 168 |
| 175 // Handle URLs to crash the browser or wreck the gpu process. | |
| 176 if (host == chrome::kChromeUIBrowserCrashHost) { | |
| 177 // Induce an intentional crash in the browser process. | |
| 178 CHECK(false); | |
| 179 } | |
| 180 | |
| 181 if (host == chrome::kChromeUIGpuCleanHost) { | |
| 182 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); | |
| 183 if (shim) | |
| 184 shim->SimulateRemoveAllContext(); | |
| 185 return true; | |
| 186 } | |
| 187 | |
| 188 if (host == chrome::kChromeUIGpuCrashHost) { | |
| 189 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); | |
| 190 if (shim) | |
| 191 shim->SimulateCrash(); | |
| 192 return true; | |
| 193 } | |
| 194 | |
| 195 if (host == chrome::kChromeUIGpuHangHost) { | |
| 196 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance(); | |
| 197 if (shim) | |
| 198 shim->SimulateHang(); | |
| 199 return true; | |
| 200 } | |
| 201 | |
| 202 #if defined(OS_CHROMEOS) | 169 #if defined(OS_CHROMEOS) |
| 203 if (host == chrome::kChromeUIRotateHost) { | 170 if (host == chrome::kChromeUIRotateHost) { |
| 204 content::ScreenOrientation change = content::SCREEN_ORIENTATION_TOP; | 171 content::ScreenOrientation change = content::SCREEN_ORIENTATION_TOP; |
| 205 std::string query(url.query()); | 172 std::string query(url.query()); |
| 206 if (query == "left") { | 173 if (query == "left") { |
| 207 change = content::SCREEN_ORIENTATION_LEFT; | 174 change = content::SCREEN_ORIENTATION_LEFT; |
| 208 } else if (query == "right") { | 175 } else if (query == "right") { |
| 209 change = content::SCREEN_ORIENTATION_RIGHT; | 176 change = content::SCREEN_ORIENTATION_RIGHT; |
| 210 } else if (query == "top") { | 177 } else if (query == "top") { |
| 211 change = content::SCREEN_ORIENTATION_TOP; | 178 change = content::SCREEN_ORIENTATION_TOP; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 239 AboutTcmallocOutputs::AboutTcmallocOutputs() {} | 206 AboutTcmallocOutputs::AboutTcmallocOutputs() {} |
| 240 | 207 |
| 241 AboutTcmallocOutputs::~AboutTcmallocOutputs() {} | 208 AboutTcmallocOutputs::~AboutTcmallocOutputs() {} |
| 242 | 209 |
| 243 // Glue between the callback task and the method in the singleton. | 210 // Glue between the callback task and the method in the singleton. |
| 244 void AboutTcmallocRendererCallback(base::ProcessId pid, | 211 void AboutTcmallocRendererCallback(base::ProcessId pid, |
| 245 const std::string& output) { | 212 const std::string& output) { |
| 246 AboutTcmallocOutputs::GetInstance()->RendererCallback(pid, output); | 213 AboutTcmallocOutputs::GetInstance()->RendererCallback(pid, output); |
| 247 } | 214 } |
| 248 #endif | 215 #endif |
| OLD | NEW |