| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |