| 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/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser_dialogs.h" | 18 #include "chrome/browser/ui/browser_dialogs.h" |
| 19 #include "chrome/common/chrome_features.h" | 19 #include "chrome/common/chrome_features.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "components/url_formatter/url_fixer.h" | 22 #include "components/url_formatter/url_fixer.h" |
| 23 #include "extensions/features/features.h" |
| 23 | 24 |
| 24 #if !defined(OS_ANDROID) | 25 #if !defined(OS_ANDROID) |
| 25 #include "chrome/browser/ui/webui/md_history_ui.h" | 26 #include "chrome/browser/ui/webui/md_history_ui.h" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 bool FixupBrowserAboutURL(GURL* url, | 29 bool FixupBrowserAboutURL(GURL* url, |
| 29 content::BrowserContext* browser_context) { | 30 content::BrowserContext* browser_context) { |
| 30 // Ensure that any cleanup done by FixupURL happens before the rewriting | 31 // Ensure that any cleanup done by FixupURL happens before the rewriting |
| 31 // phase that determines the virtual URL, by including it in an initial | 32 // phase that determines the virtual URL, by including it in an initial |
| 32 // URLHandler. This prevents minor changes from producing a virtual URL, | 33 // URLHandler. This prevents minor changes from producing a virtual URL, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 54 // Replace about with chrome-urls. | 55 // Replace about with chrome-urls. |
| 55 if (host == chrome::kChromeUIAboutHost) | 56 if (host == chrome::kChromeUIAboutHost) |
| 56 host = chrome::kChromeUIChromeURLsHost; | 57 host = chrome::kChromeUIChromeURLsHost; |
| 57 // Replace cache with view-http-cache. | 58 // Replace cache with view-http-cache. |
| 58 if (host == chrome::kChromeUICacheHost) { | 59 if (host == chrome::kChromeUICacheHost) { |
| 59 host = content::kChromeUINetworkViewCacheHost; | 60 host = content::kChromeUINetworkViewCacheHost; |
| 60 // Replace sync with sync-internals (for legacy reasons). | 61 // Replace sync with sync-internals (for legacy reasons). |
| 61 } else if (host == chrome::kChromeUISyncHost) { | 62 } else if (host == chrome::kChromeUISyncHost) { |
| 62 host = chrome::kChromeUISyncInternalsHost; | 63 host = chrome::kChromeUISyncInternalsHost; |
| 63 // Redirect chrome://extensions. | 64 // Redirect chrome://extensions. |
| 64 #if defined(ENABLE_EXTENSIONS) | 65 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 65 } else if (host == chrome::kChromeUIExtensionsHost) { | 66 } else if (host == chrome::kChromeUIExtensionsHost) { |
| 66 // If the material design extensions page is enabled, it gets its own host. | 67 // If the material design extensions page is enabled, it gets its own host. |
| 67 // Otherwise, it's handled by the uber settings page. | 68 // Otherwise, it's handled by the uber settings page. |
| 68 if (base::FeatureList::IsEnabled(features::kMaterialDesignExtensions)) { | 69 if (base::FeatureList::IsEnabled(features::kMaterialDesignExtensions)) { |
| 69 host = chrome::kChromeUIExtensionsHost; | 70 host = chrome::kChromeUIExtensionsHost; |
| 70 path = url->path(); | 71 path = url->path(); |
| 71 } else { | 72 } else { |
| 72 host = chrome::kChromeUIUberHost; | 73 host = chrome::kChromeUIUberHost; |
| 73 path = chrome::kChromeUIExtensionsHost + url->path(); | 74 path = chrome::kChromeUIExtensionsHost + url->path(); |
| 74 } | 75 } |
| 75 // Redirect chrome://settings/extensions (legacy URL). | 76 // Redirect chrome://settings/extensions (legacy URL). |
| 76 } else if (host == chrome::kChromeUISettingsHost && | 77 } else if (host == chrome::kChromeUISettingsHost && |
| 77 url->path() == std::string("/") + chrome::kExtensionsSubPage) { | 78 url->path() == std::string("/") + chrome::kExtensionsSubPage) { |
| 78 host = chrome::kChromeUIUberHost; | 79 host = chrome::kChromeUIUberHost; |
| 79 path = chrome::kChromeUIExtensionsHost; | 80 path = chrome::kChromeUIExtensionsHost; |
| 80 #endif // defined(ENABLE_EXTENSIONS) | 81 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 81 // Redirect chrome://history. | 82 // Redirect chrome://history. |
| 82 } else if (host == chrome::kChromeUIHistoryHost) { | 83 } else if (host == chrome::kChromeUIHistoryHost) { |
| 83 #if defined(OS_ANDROID) | 84 #if defined(OS_ANDROID) |
| 84 // On Android, redirect directly to chrome://history-frame since | 85 // On Android, redirect directly to chrome://history-frame since |
| 85 // uber page is unsupported. | 86 // uber page is unsupported. |
| 86 host = chrome::kChromeUIHistoryFrameHost; | 87 host = chrome::kChromeUIHistoryFrameHost; |
| 87 #else | 88 #else |
| 88 // Material design history is handled on the top-level chrome://history | 89 // Material design history is handled on the top-level chrome://history |
| 89 // host. | 90 // host. |
| 90 if (MdHistoryUI::IsEnabled(Profile::FromBrowserContext(browser_context))) { | 91 if (MdHistoryUI::IsEnabled(Profile::FromBrowserContext(browser_context))) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 FROM_HERE, base::Bind(&chrome::AttemptRestart)); | 141 FROM_HERE, base::Bind(&chrome::AttemptRestart)); |
| 141 return true; | 142 return true; |
| 142 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { | 143 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { |
| 143 base::ThreadTaskRunnerHandle::Get()->PostTask( | 144 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 144 FROM_HERE, base::Bind(&chrome::AttemptExit)); | 145 FROM_HERE, base::Bind(&chrome::AttemptExit)); |
| 145 return true; | 146 return true; |
| 146 } | 147 } |
| 147 | 148 |
| 148 return false; | 149 return false; |
| 149 } | 150 } |
| OLD | NEW |