| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
| 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/browser_dialogs.h" | 18 #include "chrome/browser/ui/browser_dialogs.h" |
| 18 #include "chrome/common/chrome_features.h" | 19 #include "chrome/common/chrome_features.h" |
| 19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 21 #include "components/url_formatter/url_fixer.h" | 22 #include "components/url_formatter/url_fixer.h" |
| 22 | 23 |
| 24 #if !defined(OS_ANDROID) |
| 25 #include "chrome/browser/ui/webui/md_history_ui.h" |
| 26 #endif |
| 27 |
| 23 bool FixupBrowserAboutURL(GURL* url, | 28 bool FixupBrowserAboutURL(GURL* url, |
| 24 content::BrowserContext* browser_context) { | 29 content::BrowserContext* browser_context) { |
| 25 // Ensure that any cleanup done by FixupURL happens before the rewriting | 30 // Ensure that any cleanup done by FixupURL happens before the rewriting |
| 26 // phase that determines the virtual URL, by including it in an initial | 31 // phase that determines the virtual URL, by including it in an initial |
| 27 // URLHandler. This prevents minor changes from producing a virtual URL, | 32 // URLHandler. This prevents minor changes from producing a virtual URL, |
| 28 // which could lead to a URL spoof. | 33 // which could lead to a URL spoof. |
| 29 *url = url_formatter::FixupURL(url->possibly_invalid_spec(), std::string()); | 34 *url = url_formatter::FixupURL(url->possibly_invalid_spec(), std::string()); |
| 30 return true; | 35 return true; |
| 31 } | 36 } |
| 32 | 37 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 host = chrome::kChromeUIUberHost; | 71 host = chrome::kChromeUIUberHost; |
| 67 path = chrome::kChromeUIExtensionsHost + url->path(); | 72 path = chrome::kChromeUIExtensionsHost + url->path(); |
| 68 } | 73 } |
| 69 // Redirect chrome://settings/extensions (legacy URL). | 74 // Redirect chrome://settings/extensions (legacy URL). |
| 70 } else if (host == chrome::kChromeUISettingsHost && | 75 } else if (host == chrome::kChromeUISettingsHost && |
| 71 url->path() == std::string("/") + chrome::kExtensionsSubPage) { | 76 url->path() == std::string("/") + chrome::kExtensionsSubPage) { |
| 72 host = chrome::kChromeUIUberHost; | 77 host = chrome::kChromeUIUberHost; |
| 73 path = chrome::kChromeUIExtensionsHost; | 78 path = chrome::kChromeUIExtensionsHost; |
| 74 // Redirect chrome://history. | 79 // Redirect chrome://history. |
| 75 } else if (host == chrome::kChromeUIHistoryHost) { | 80 } else if (host == chrome::kChromeUIHistoryHost) { |
| 81 #if defined(OS_ANDROID) |
| 82 // On Android, redirect directly to chrome://history-frame since |
| 83 // uber page is unsupported. |
| 84 host = chrome::kChromeUIHistoryFrameHost; |
| 85 #else |
| 76 // Material design history is handled on the top-level chrome://history | 86 // Material design history is handled on the top-level chrome://history |
| 77 // host. | 87 // host. |
| 78 if (base::FeatureList::IsEnabled(features::kMaterialDesignHistoryFeature)) { | 88 if (MdHistoryUI::IsEnabled(Profile::FromBrowserContext(browser_context))) { |
| 79 host = chrome::kChromeUIHistoryHost; | 89 host = chrome::kChromeUIHistoryHost; |
| 80 path = url->path(); | 90 path = url->path(); |
| 81 } else { | 91 } else { |
| 82 #if defined(OS_ANDROID) | |
| 83 // On Android, redirect directly to chrome://history-frame since | |
| 84 // uber page is unsupported. | |
| 85 host = chrome::kChromeUIHistoryFrameHost; | |
| 86 #else | |
| 87 host = chrome::kChromeUIUberHost; | 92 host = chrome::kChromeUIUberHost; |
| 88 path = chrome::kChromeUIHistoryHost + url->path(); | 93 path = chrome::kChromeUIHistoryHost + url->path(); |
| 94 } |
| 89 #endif | 95 #endif |
| 90 } | |
| 91 // Redirect chrome://settings | 96 // Redirect chrome://settings |
| 92 } else if (host == chrome::kChromeUISettingsHost) { | 97 } else if (host == chrome::kChromeUISettingsHost) { |
| 93 if (::switches::AboutInSettingsEnabled()) { | 98 if (::switches::AboutInSettingsEnabled()) { |
| 94 host = chrome::kChromeUISettingsFrameHost; | 99 host = chrome::kChromeUISettingsFrameHost; |
| 95 } else { | 100 } else { |
| 96 host = chrome::kChromeUIUberHost; | 101 host = chrome::kChromeUIUberHost; |
| 97 path = chrome::kChromeUISettingsHost + url->path(); | 102 path = chrome::kChromeUISettingsHost + url->path(); |
| 98 } | 103 } |
| 99 // Redirect chrome://help | 104 // Redirect chrome://help |
| 100 } else if (host == chrome::kChromeUIHelpHost) { | 105 } else if (host == chrome::kChromeUIHelpHost) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 128 FROM_HERE, base::Bind(&chrome::AttemptRestart)); | 133 FROM_HERE, base::Bind(&chrome::AttemptRestart)); |
| 129 return true; | 134 return true; |
| 130 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { | 135 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { |
| 131 base::ThreadTaskRunnerHandle::Get()->PostTask( | 136 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 132 FROM_HERE, base::Bind(&chrome::AttemptExit)); | 137 FROM_HERE, base::Bind(&chrome::AttemptExit)); |
| 133 return true; | 138 return true; |
| 134 } | 139 } |
| 135 | 140 |
| 136 return false; | 141 return false; |
| 137 } | 142 } |
| OLD | NEW |