Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1033)

Side by Side Diff: chrome/browser/browser_about_handler.cc

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // Replace sync with sync-internals (for legacy reasons). 60 // Replace sync with sync-internals (for legacy reasons).
61 } else if (host == chrome::kChromeUISyncHost) { 61 } else if (host == chrome::kChromeUISyncHost) {
62 host = chrome::kChromeUISyncInternalsHost; 62 host = chrome::kChromeUISyncInternalsHost;
63 // Redirect chrome://extensions. 63 // Redirect chrome://extensions.
64 #if defined(ENABLE_EXTENSIONS) 64 #if defined(ENABLE_EXTENSIONS)
65 } else if (host == chrome::kChromeUIExtensionsHost) { 65 } else if (host == chrome::kChromeUIExtensionsHost) {
66 // If the material design extensions page is enabled, it gets its own host. 66 // If the material design extensions page is enabled, it gets its own host.
67 // Otherwise, it's handled by the uber settings page. 67 // Otherwise, it's handled by the uber settings page.
68 if (base::FeatureList::IsEnabled(features::kMaterialDesignExtensions)) { 68 if (base::FeatureList::IsEnabled(features::kMaterialDesignExtensions)) {
69 host = chrome::kChromeUIExtensionsHost; 69 host = chrome::kChromeUIExtensionsHost;
70 path = url->path(); 70 path = url->path().as_string();
71 } else { 71 } else {
72 host = chrome::kChromeUIUberHost; 72 host = chrome::kChromeUIUberHost;
73 path = chrome::kChromeUIExtensionsHost + url->path(); 73 path = chrome::kChromeUIExtensionsHost + url->path().as_string();
74 } 74 }
75 // Redirect chrome://settings/extensions (legacy URL). 75 // Redirect chrome://settings/extensions (legacy URL).
76 } else if (host == chrome::kChromeUISettingsHost && 76 } else if (host == chrome::kChromeUISettingsHost &&
77 url->path() == std::string("/") + chrome::kExtensionsSubPage) { 77 url->path() == std::string("/") + chrome::kExtensionsSubPage) {
78 host = chrome::kChromeUIUberHost; 78 host = chrome::kChromeUIUberHost;
79 path = chrome::kChromeUIExtensionsHost; 79 path = chrome::kChromeUIExtensionsHost;
80 #endif // defined(ENABLE_EXTENSIONS) 80 #endif // defined(ENABLE_EXTENSIONS)
81 // Redirect chrome://history. 81 // Redirect chrome://history.
82 } else if (host == chrome::kChromeUIHistoryHost) { 82 } else if (host == chrome::kChromeUIHistoryHost) {
83 #if defined(OS_ANDROID) 83 #if defined(OS_ANDROID)
84 // On Android, redirect directly to chrome://history-frame since 84 // On Android, redirect directly to chrome://history-frame since
85 // uber page is unsupported. 85 // uber page is unsupported.
86 host = chrome::kChromeUIHistoryFrameHost; 86 host = chrome::kChromeUIHistoryFrameHost;
87 #else 87 #else
88 // Material design history is handled on the top-level chrome://history 88 // Material design history is handled on the top-level chrome://history
89 // host. 89 // host.
90 if (MdHistoryUI::IsEnabled(Profile::FromBrowserContext(browser_context))) { 90 if (MdHistoryUI::IsEnabled(Profile::FromBrowserContext(browser_context))) {
91 host = chrome::kChromeUIHistoryHost; 91 host = chrome::kChromeUIHistoryHost;
92 path = url->path(); 92 path = url->path().as_string();
93 } else { 93 } else {
94 host = chrome::kChromeUIUberHost; 94 host = chrome::kChromeUIUberHost;
95 path = chrome::kChromeUIHistoryHost + url->path(); 95 path = chrome::kChromeUIHistoryHost + url->path().as_string();
96 } 96 }
97 #endif 97 #endif
98 // Redirect chrome://settings, unless MD settings is enabled. 98 // Redirect chrome://settings, unless MD settings is enabled.
99 } else if (host == chrome::kChromeUISettingsHost) { 99 } else if (host == chrome::kChromeUISettingsHost) {
100 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { 100 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) {
101 return true; // Prevent further rewriting - this is a valid URL. 101 return true; // Prevent further rewriting - this is a valid URL.
102 } else if (::switches::AboutInSettingsEnabled()) { 102 } else if (::switches::AboutInSettingsEnabled()) {
103 host = chrome::kChromeUISettingsFrameHost; 103 host = chrome::kChromeUISettingsFrameHost;
104 } else { 104 } else {
105 host = chrome::kChromeUIUberHost; 105 host = chrome::kChromeUIUberHost;
106 path = chrome::kChromeUISettingsHost + url->path(); 106 path = chrome::kChromeUISettingsHost + url->path().as_string();
107 } 107 }
108 // Redirect chrome://help, unless MD settings is enabled. 108 // Redirect chrome://help, unless MD settings is enabled.
109 } else if (host == chrome::kChromeUIHelpHost) { 109 } else if (host == chrome::kChromeUIHelpHost) {
110 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { 110 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) {
111 host = chrome::kChromeUISettingsHost; 111 host = chrome::kChromeUISettingsHost;
112 path = chrome::kChromeUIHelpHost; 112 path = chrome::kChromeUIHelpHost;
113 } else if (::switches::AboutInSettingsEnabled()) { 113 } else if (::switches::AboutInSettingsEnabled()) {
114 host = chrome::kChromeUISettingsFrameHost; 114 host = chrome::kChromeUISettingsFrameHost;
115 if (url->path().empty() || url->path() == "/") 115 if (url->path().empty() || url->path() == "/")
116 path = chrome::kChromeUIHelpHost; 116 path = chrome::kChromeUIHelpHost;
117 } else { 117 } else {
118 host = chrome::kChromeUIUberHost; 118 host = chrome::kChromeUIUberHost;
119 path = chrome::kChromeUIHelpHost + url->path(); 119 path = chrome::kChromeUIHelpHost + url->path().as_string();
120 } 120 }
121 } 121 }
122 122
123 GURL::Replacements replacements; 123 GURL::Replacements replacements;
124 replacements.SetHostStr(host); 124 replacements.SetHostStr(host);
125 if (!path.empty()) 125 if (!path.empty())
126 replacements.SetPathStr(path); 126 replacements.SetPathStr(path);
127 *url = url->ReplaceComponents(replacements); 127 *url = url->ReplaceComponents(replacements);
128 128
129 // Having re-written the URL, make the chrome: handler process it. 129 // Having re-written the URL, make the chrome: handler process it.
(...skipping 10 matching lines...) Expand all
140 FROM_HERE, base::Bind(&chrome::AttemptRestart)); 140 FROM_HERE, base::Bind(&chrome::AttemptRestart));
141 return true; 141 return true;
142 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { 142 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) {
143 base::ThreadTaskRunnerHandle::Get()->PostTask( 143 base::ThreadTaskRunnerHandle::Get()->PostTask(
144 FROM_HERE, base::Bind(&chrome::AttemptExit)); 144 FROM_HERE, base::Bind(&chrome::AttemptExit));
145 return true; 145 return true;
146 } 146 }
147 147
148 return false; 148 return false;
149 } 149 }
OLDNEW
« no previous file with comments | « android_webview/native/aw_web_contents_delegate.cc ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698