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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 host = chrome::kChromeUIUberHost; | 80 host = chrome::kChromeUIUberHost; |
81 path = chrome::kChromeUIExtensionsHost + url->path(); | 81 path = chrome::kChromeUIExtensionsHost + url->path(); |
82 } | 82 } |
83 // Redirect chrome://settings/extensions (legacy URL). | 83 // Redirect chrome://settings/extensions (legacy URL). |
84 } else if (host == chrome::kChromeUISettingsHost && | 84 } else if (host == chrome::kChromeUISettingsHost && |
85 url->path() == | 85 url->path() == |
86 std::string("/") + chrome::kDeprecatedExtensionsSubPage) { | 86 std::string("/") + chrome::kDeprecatedExtensionsSubPage) { |
87 host = chrome::kChromeUIUberHost; | 87 host = chrome::kChromeUIUberHost; |
88 path = chrome::kChromeUIExtensionsHost; | 88 path = chrome::kChromeUIExtensionsHost; |
89 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 89 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
90 // Redirect chrome://history. | |
91 } else if (host == chrome::kChromeUIHistoryHost) { | 90 } else if (host == chrome::kChromeUIHistoryHost) { |
| 91 // Redirect chrome://history. |
92 path = url->path(); | 92 path = url->path(); |
93 // Redirect chrome://settings, unless MD settings is enabled. | |
94 } else if (host == chrome::kChromeUISettingsHost) { | 93 } else if (host == chrome::kChromeUISettingsHost) { |
95 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { | 94 // Redirect chrome://settings. |
96 return true; // Prevent further rewriting - this is a valid URL. | 95 return true; // Prevent further rewriting - this is a valid URL. |
97 } else if (::switches::SettingsWindowEnabled()) { | |
98 host = chrome::kChromeUISettingsFrameHost; | |
99 } else { | |
100 host = chrome::kChromeUIUberHost; | |
101 path = chrome::kChromeUISettingsHost + url->path(); | |
102 } | |
103 // Redirect chrome://help, unless MD settings is enabled. | |
104 } else if (host == chrome::kChromeUIHelpHost) { | 96 } else if (host == chrome::kChromeUIHelpHost) { |
105 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { | 97 // Redirect chrome://help, unless MD settings is enabled. |
106 return false; // Handled in the HandleWebUI handler. | 98 return false; // Handled in the HandleWebUI handler. |
107 } else if (::switches::SettingsWindowEnabled()) { | |
108 host = chrome::kChromeUISettingsFrameHost; | |
109 if (url->path().empty() || url->path() == "/") | |
110 path = chrome::kChromeUIHelpHost; | |
111 } else { | |
112 host = chrome::kChromeUIUberHost; | |
113 path = chrome::kChromeUIHelpHost + url->path(); | |
114 } | |
115 } | 99 } |
116 | 100 |
117 GURL::Replacements replacements; | 101 GURL::Replacements replacements; |
118 replacements.SetHostStr(host); | 102 replacements.SetHostStr(host); |
119 if (!path.empty()) | 103 if (!path.empty()) |
120 replacements.SetPathStr(path); | 104 replacements.SetPathStr(path); |
121 *url = url->ReplaceComponents(replacements); | 105 *url = url->ReplaceComponents(replacements); |
122 | 106 |
123 // Having re-written the URL, make the chrome: handler process it. | 107 // Having re-written the URL, make the chrome: handler process it. |
124 return false; | 108 return false; |
125 } | 109 } |
126 | 110 |
127 bool HandleNonNavigationAboutURL(const GURL& url) { | 111 bool HandleNonNavigationAboutURL(const GURL& url) { |
128 const std::string spec(url.spec()); | 112 const std::string spec(url.spec()); |
129 | 113 |
130 if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIRestartURL)) { | 114 if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIRestartURL)) { |
131 // Call AttemptRestart after chrome::Navigate() completes to avoid access of | 115 // Call AttemptRestart after chrome::Navigate() completes to avoid access of |
132 // gtk objects after they are destroyed by BrowserWindowGtk::Close(). | 116 // gtk objects after they are destroyed by BrowserWindowGtk::Close(). |
133 base::ThreadTaskRunnerHandle::Get()->PostTask( | 117 base::ThreadTaskRunnerHandle::Get()->PostTask( |
134 FROM_HERE, base::BindOnce(&chrome::AttemptRestart)); | 118 FROM_HERE, base::BindOnce(&chrome::AttemptRestart)); |
135 return true; | 119 return true; |
136 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { | 120 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { |
137 base::ThreadTaskRunnerHandle::Get()->PostTask( | 121 base::ThreadTaskRunnerHandle::Get()->PostTask( |
138 FROM_HERE, base::BindOnce(&chrome::AttemptExit)); | 122 FROM_HERE, base::BindOnce(&chrome::AttemptExit)); |
139 return true; | 123 return true; |
140 } | 124 } |
141 | 125 |
142 return false; | 126 return false; |
143 } | 127 } |
OLD | NEW |