| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return true; // Prevent further rewriting - this is a valid URL. | 111 return true; // Prevent further rewriting - this is a valid URL. |
| 112 } else if (::switches::AboutInSettingsEnabled()) { | 112 } else if (::switches::AboutInSettingsEnabled()) { |
| 113 host = chrome::kChromeUISettingsFrameHost; | 113 host = chrome::kChromeUISettingsFrameHost; |
| 114 } else { | 114 } else { |
| 115 host = chrome::kChromeUIUberHost; | 115 host = chrome::kChromeUIUberHost; |
| 116 path = chrome::kChromeUISettingsHost + url->path(); | 116 path = chrome::kChromeUISettingsHost + url->path(); |
| 117 } | 117 } |
| 118 // Redirect chrome://help, unless MD settings is enabled. | 118 // Redirect chrome://help, unless MD settings is enabled. |
| 119 } else if (host == chrome::kChromeUIHelpHost) { | 119 } else if (host == chrome::kChromeUIHelpHost) { |
| 120 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { | 120 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { |
| 121 host = chrome::kChromeUISettingsHost; | 121 return false; // Handled in the HandleWebUI handler. |
| 122 path = chrome::kChromeUIHelpHost; | |
| 123 } else if (::switches::AboutInSettingsEnabled()) { | 122 } else if (::switches::AboutInSettingsEnabled()) { |
| 124 host = chrome::kChromeUISettingsFrameHost; | 123 host = chrome::kChromeUISettingsFrameHost; |
| 125 if (url->path().empty() || url->path() == "/") | 124 if (url->path().empty() || url->path() == "/") |
| 126 path = chrome::kChromeUIHelpHost; | 125 path = chrome::kChromeUIHelpHost; |
| 127 } else { | 126 } else { |
| 128 host = chrome::kChromeUIUberHost; | 127 host = chrome::kChromeUIUberHost; |
| 129 path = chrome::kChromeUIHelpHost + url->path(); | 128 path = chrome::kChromeUIHelpHost + url->path(); |
| 130 } | 129 } |
| 131 // Redirect chrome://chrome to chrome://settings/help, only for MD settings. | |
| 132 } else if (host == chrome::kChromeUIUberHost && | |
| 133 base::FeatureList::IsEnabled(features::kMaterialDesignSettings) && | |
| 134 (url->path().empty() || url->path() == "/")) { | |
| 135 host = chrome::kChromeUISettingsHost; | |
| 136 path = chrome::kChromeUIHelpHost; | |
| 137 } | 130 } |
| 138 | 131 |
| 139 GURL::Replacements replacements; | 132 GURL::Replacements replacements; |
| 140 replacements.SetHostStr(host); | 133 replacements.SetHostStr(host); |
| 141 if (!path.empty()) | 134 if (!path.empty()) |
| 142 replacements.SetPathStr(path); | 135 replacements.SetPathStr(path); |
| 143 *url = url->ReplaceComponents(replacements); | 136 *url = url->ReplaceComponents(replacements); |
| 144 | 137 |
| 145 // Having re-written the URL, make the chrome: handler process it. | 138 // Having re-written the URL, make the chrome: handler process it. |
| 146 return false; | 139 return false; |
| 147 } | 140 } |
| 148 | 141 |
| 149 bool HandleNonNavigationAboutURL(const GURL& url) { | 142 bool HandleNonNavigationAboutURL(const GURL& url) { |
| 150 const std::string spec(url.spec()); | 143 const std::string spec(url.spec()); |
| 151 | 144 |
| 152 if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIRestartURL)) { | 145 if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIRestartURL)) { |
| 153 // Call AttemptRestart after chrome::Navigate() completes to avoid access of | 146 // Call AttemptRestart after chrome::Navigate() completes to avoid access of |
| 154 // gtk objects after they are destroyed by BrowserWindowGtk::Close(). | 147 // gtk objects after they are destroyed by BrowserWindowGtk::Close(). |
| 155 base::ThreadTaskRunnerHandle::Get()->PostTask( | 148 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 156 FROM_HERE, base::Bind(&chrome::AttemptRestart)); | 149 FROM_HERE, base::Bind(&chrome::AttemptRestart)); |
| 157 return true; | 150 return true; |
| 158 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { | 151 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { |
| 159 base::ThreadTaskRunnerHandle::Get()->PostTask( | 152 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 160 FROM_HERE, base::Bind(&chrome::AttemptExit)); | 153 FROM_HERE, base::Bind(&chrome::AttemptExit)); |
| 161 return true; | 154 return true; |
| 162 } | 155 } |
| 163 | 156 |
| 164 return false; | 157 return false; |
| 165 } | 158 } |
| OLD | NEW |