| 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/thread_task_runner_handle.h" | 14 #include "base/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/ui/browser_dialogs.h" | 17 #include "chrome/browser/ui/browser_dialogs.h" |
| 18 #include "chrome/common/chrome_features.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 20 #include "components/url_formatter/url_fixer.h" | 21 #include "components/url_formatter/url_fixer.h" |
| 21 | 22 |
| 22 bool FixupBrowserAboutURL(GURL* url, | 23 bool FixupBrowserAboutURL(GURL* url, |
| 23 content::BrowserContext* browser_context) { | 24 content::BrowserContext* browser_context) { |
| 24 // Ensure that any cleanup done by FixupURL happens before the rewriting | 25 // Ensure that any cleanup done by FixupURL happens before the rewriting |
| 25 // phase that determines the virtual URL, by including it in an initial | 26 // phase that determines the virtual URL, by including it in an initial |
| 26 // URLHandler. This prevents minor changes from producing a virtual URL, | 27 // URLHandler. This prevents minor changes from producing a virtual URL, |
| 27 // which could lead to a URL spoof. | 28 // which could lead to a URL spoof. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 68 } |
| 68 // Redirect chrome://settings/extensions (legacy URL). | 69 // Redirect chrome://settings/extensions (legacy URL). |
| 69 } else if (host == chrome::kChromeUISettingsHost && | 70 } else if (host == chrome::kChromeUISettingsHost && |
| 70 url->path() == std::string("/") + chrome::kExtensionsSubPage) { | 71 url->path() == std::string("/") + chrome::kExtensionsSubPage) { |
| 71 host = chrome::kChromeUIUberHost; | 72 host = chrome::kChromeUIUberHost; |
| 72 path = chrome::kChromeUIExtensionsHost; | 73 path = chrome::kChromeUIExtensionsHost; |
| 73 // Redirect chrome://history. | 74 // Redirect chrome://history. |
| 74 } else if (host == chrome::kChromeUIHistoryHost) { | 75 } else if (host == chrome::kChromeUIHistoryHost) { |
| 75 // Material design history is handled on the top-level chrome://history | 76 // Material design history is handled on the top-level chrome://history |
| 76 // host. | 77 // host. |
| 77 if (::switches::MdHistoryEnabled()) { | 78 if (base::FeatureList::IsEnabled(features::kMaterialDesignHistoryFeature)) { |
| 78 host = chrome::kChromeUIHistoryHost; | 79 host = chrome::kChromeUIHistoryHost; |
| 79 path = url->path(); | 80 path = url->path(); |
| 80 } else { | 81 } else { |
| 81 #if defined(OS_ANDROID) | 82 #if defined(OS_ANDROID) |
| 82 // On Android, redirect directly to chrome://history-frame since | 83 // On Android, redirect directly to chrome://history-frame since |
| 83 // uber page is unsupported. | 84 // uber page is unsupported. |
| 84 host = chrome::kChromeUIHistoryFrameHost; | 85 host = chrome::kChromeUIHistoryFrameHost; |
| 85 #else | 86 #else |
| 86 host = chrome::kChromeUIUberHost; | 87 host = chrome::kChromeUIUberHost; |
| 87 path = chrome::kChromeUIHistoryHost + url->path(); | 88 path = chrome::kChromeUIHistoryHost + url->path(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 FROM_HERE, base::Bind(&chrome::AttemptRestart)); | 128 FROM_HERE, base::Bind(&chrome::AttemptRestart)); |
| 128 return true; | 129 return true; |
| 129 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { | 130 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { |
| 130 base::ThreadTaskRunnerHandle::Get()->PostTask( | 131 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 131 FROM_HERE, base::Bind(&chrome::AttemptExit)); | 132 FROM_HERE, base::Bind(&chrome::AttemptExit)); |
| 132 return true; | 133 return true; |
| 133 } | 134 } |
| 134 | 135 |
| 135 return false; | 136 return false; |
| 136 } | 137 } |
| OLD | NEW |