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" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. | 97 // Check that about: URLs are fixed up to chrome: by URLFixerUpper::FixupURL. |
98 DCHECK((*url == GURL(chrome::kAboutBlankURL)) || | 98 DCHECK((*url == GURL(chrome::kAboutBlankURL)) || |
99 !url->SchemeIs(chrome::kAboutScheme)); | 99 !url->SchemeIs(chrome::kAboutScheme)); |
100 | 100 |
101 // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. | 101 // Only handle chrome://foo/, URLFixerUpper::FixupURL translates about:foo. |
102 // TAB_CONTENTS_WEB handles about:blank, which frames are allowed to access. | 102 // TAB_CONTENTS_WEB handles about:blank, which frames are allowed to access. |
103 if (!url->SchemeIs(chrome::kChromeUIScheme)) | 103 if (!url->SchemeIs(chrome::kChromeUIScheme)) |
104 return false; | 104 return false; |
105 | 105 |
106 CommandLine* cl = CommandLine::ForCurrentProcess(); | |
107 bool enableUberPage = !cl->HasSwitch(switches::kDisableUberPage); | |
108 | |
109 std::string host(url->host()); | 106 std::string host(url->host()); |
110 std::string path; | 107 std::string path; |
111 // Replace about with chrome-urls. | 108 // Replace about with chrome-urls. |
112 if (host == chrome::kChromeUIAboutHost) | 109 if (host == chrome::kChromeUIAboutHost) |
113 host = chrome::kChromeUIChromeURLsHost; | 110 host = chrome::kChromeUIChromeURLsHost; |
114 // Replace cache with view-http-cache. | 111 // Replace cache with view-http-cache. |
115 if (host == chrome::kChromeUICacheHost) { | 112 if (host == chrome::kChromeUICacheHost) { |
116 host = chrome::kChromeUINetworkViewCacheHost; | 113 host = chrome::kChromeUINetworkViewCacheHost; |
117 // Replace gpu with gpu-internals. | 114 // Replace gpu with gpu-internals. |
118 } else if (host == chrome::kChromeUIGpuHost) { | 115 } else if (host == chrome::kChromeUIGpuHost) { |
119 host = chrome::kChromeUIGpuInternalsHost; | 116 host = chrome::kChromeUIGpuInternalsHost; |
120 // Replace sync with sync-internals (for legacy reasons). | 117 // Replace sync with sync-internals (for legacy reasons). |
121 } else if (host == chrome::kChromeUISyncHost) { | 118 } else if (host == chrome::kChromeUISyncHost) { |
122 host = chrome::kChromeUISyncInternalsHost; | 119 host = chrome::kChromeUISyncInternalsHost; |
123 // Redirect chrome://extensions. | 120 // Redirect chrome://extensions. |
124 } else if (host == chrome::kChromeUIExtensionsHost) { | 121 } else if (host == chrome::kChromeUIExtensionsHost) { |
125 if (enableUberPage) { | 122 host = chrome::kChromeUIUberHost; |
126 host = chrome::kChromeUIUberHost; | 123 path = chrome::kChromeUIExtensionsHost + url->path(); |
127 path = chrome::kChromeUIExtensionsHost + url->path(); | |
128 } else { | |
129 host = chrome::kChromeUISettingsHost; | |
130 path = chrome::kExtensionsSubPage; | |
131 } | |
132 } else if (host == chrome::kChromeUIHistoryHost) { | 124 } else if (host == chrome::kChromeUIHistoryHost) { |
133 if (enableUberPage) { | 125 host = chrome::kChromeUIUberHost; |
134 host = chrome::kChromeUIUberHost; | 126 path = chrome::kChromeUIHistoryHost + url->path(); |
135 path = chrome::kChromeUIHistoryHost + url->path(); | |
136 } else { | |
137 host = chrome::kChromeUIHistoryFrameHost; | |
138 } | |
139 // Redirect chrome://settings/extensions. | 127 // Redirect chrome://settings/extensions. |
140 // TODO(csilv): Fix all code paths for this page once Uber page is enabled | 128 // TODO(csilv): Fix all code paths for this page once Uber page is enabled |
141 // permanently. | 129 // permanently. |
142 } else if (enableUberPage && host == chrome::kChromeUISettingsHost && | 130 } else if (host == chrome::kChromeUISettingsHost && |
143 url->path() == std::string("/") + chrome::kExtensionsSubPage) { | 131 url->path() == std::string("/") + chrome::kExtensionsSubPage) { |
144 host = chrome::kChromeUIUberHost; | 132 host = chrome::kChromeUIUberHost; |
145 path = chrome::kChromeUIExtensionsHost; | 133 path = chrome::kChromeUIExtensionsHost; |
146 // Redirect chrome://settings | 134 // Redirect chrome://settings |
147 } else if (enableUberPage && host == chrome::kChromeUISettingsHost) { | 135 } else if (host == chrome::kChromeUISettingsHost) { |
148 host = chrome::kChromeUIUberHost; | 136 host = chrome::kChromeUIUberHost; |
149 path = chrome::kChromeUISettingsHost + url->path(); | 137 path = chrome::kChromeUISettingsHost + url->path(); |
150 } | 138 } |
151 GURL::Replacements replacements; | 139 GURL::Replacements replacements; |
152 replacements.SetHostStr(host); | 140 replacements.SetHostStr(host); |
153 if (!path.empty()) | 141 if (!path.empty()) |
154 replacements.SetPathStr(path); | 142 replacements.SetPathStr(path); |
155 *url = url->ReplaceComponents(replacements); | 143 *url = url->ReplaceComponents(replacements); |
156 | 144 |
157 // Having re-written the URL, make the chrome: handler process it. | 145 // Having re-written the URL, make the chrome: handler process it. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 AboutTcmallocOutputs::AboutTcmallocOutputs() {} | 202 AboutTcmallocOutputs::AboutTcmallocOutputs() {} |
215 | 203 |
216 AboutTcmallocOutputs::~AboutTcmallocOutputs() {} | 204 AboutTcmallocOutputs::~AboutTcmallocOutputs() {} |
217 | 205 |
218 // Glue between the callback task and the method in the singleton. | 206 // Glue between the callback task and the method in the singleton. |
219 void AboutTcmallocRendererCallback(base::ProcessId pid, | 207 void AboutTcmallocRendererCallback(base::ProcessId pid, |
220 const std::string& output) { | 208 const std::string& output) { |
221 AboutTcmallocOutputs::GetInstance()->RendererCallback(pid, output); | 209 AboutTcmallocOutputs::GetInstance()->RendererCallback(pid, output); |
222 } | 210 } |
223 #endif | 211 #endif |
OLD | NEW |