| 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/ui/browser_dialogs.h" | 17 #include "chrome/browser/ui/browser_dialogs.h" |
| 18 #include "chrome/browser/ui/chrome_pages.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 |
| 23 bool FixupBrowserAboutURL(GURL* url, | 24 bool FixupBrowserAboutURL(GURL* url, |
| 24 content::BrowserContext* browser_context) { | 25 content::BrowserContext* browser_context) { |
| 25 // Ensure that any cleanup done by FixupURL happens before the rewriting | 26 // Ensure that any cleanup done by FixupURL happens before the rewriting |
| 26 // phase that determines the virtual URL, by including it in an initial | 27 // phase that determines the virtual URL, by including it in an initial |
| 27 // URLHandler. This prevents minor changes from producing a virtual URL, | 28 // URLHandler. This prevents minor changes from producing a virtual URL, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } else { | 82 } else { |
| 82 #if defined(OS_ANDROID) | 83 #if defined(OS_ANDROID) |
| 83 // On Android, redirect directly to chrome://history-frame since | 84 // On Android, redirect directly to chrome://history-frame since |
| 84 // uber page is unsupported. | 85 // uber page is unsupported. |
| 85 host = chrome::kChromeUIHistoryFrameHost; | 86 host = chrome::kChromeUIHistoryFrameHost; |
| 86 #else | 87 #else |
| 87 host = chrome::kChromeUIUberHost; | 88 host = chrome::kChromeUIUberHost; |
| 88 path = chrome::kChromeUIHistoryHost + url->path(); | 89 path = chrome::kChromeUIHistoryHost + url->path(); |
| 89 #endif | 90 #endif |
| 90 } | 91 } |
| 91 // Redirect chrome://settings | 92 // Redirect legacy settings page to uber page. |
| 92 } else if (host == chrome::kChromeUISettingsHost) { | 93 } else if (host == chrome::GetLegacySettingsHost()) { |
| 93 if (::switches::AboutInSettingsEnabled()) { | 94 if (::switches::AboutInSettingsEnabled()) { |
| 94 host = chrome::kChromeUISettingsFrameHost; | 95 host = chrome::kChromeUISettingsFrameHost; |
| 95 } else { | 96 } else { |
| 96 host = chrome::kChromeUIUberHost; | 97 host = chrome::kChromeUIUberHost; |
| 97 path = chrome::kChromeUISettingsHost + url->path(); | 98 path = chrome::GetLegacySettingsHost() + url->path(); |
| 98 } | 99 } |
| 99 // Redirect chrome://help | 100 // Redirect chrome://help |
| 100 } else if (host == chrome::kChromeUIHelpHost) { | 101 } else if (host == chrome::kChromeUIHelpHost) { |
| 101 if (::switches::AboutInSettingsEnabled()) { | 102 if (::switches::AboutInSettingsEnabled()) { |
| 102 host = chrome::kChromeUISettingsFrameHost; | 103 host = chrome::kChromeUISettingsFrameHost; |
| 103 if (url->path().empty() || url->path() == "/") | 104 if (url->path().empty() || url->path() == "/") |
| 104 path = chrome::kChromeUIHelpHost; | 105 path = chrome::kChromeUIHelpHost; |
| 105 } else { | 106 } else { |
| 106 host = chrome::kChromeUIUberHost; | 107 host = chrome::kChromeUIUberHost; |
| 107 path = chrome::kChromeUIHelpHost + url->path(); | 108 path = chrome::kChromeUIHelpHost + url->path(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 128 FROM_HERE, base::Bind(&chrome::AttemptRestart)); | 129 FROM_HERE, base::Bind(&chrome::AttemptRestart)); |
| 129 return true; | 130 return true; |
| 130 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { | 131 } else if (base::LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { |
| 131 base::ThreadTaskRunnerHandle::Get()->PostTask( | 132 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 132 FROM_HERE, base::Bind(&chrome::AttemptExit)); | 133 FROM_HERE, base::Bind(&chrome::AttemptExit)); |
| 133 return true; | 134 return true; |
| 134 } | 135 } |
| 135 | 136 |
| 136 return false; | 137 return false; |
| 137 } | 138 } |
| OLD | NEW |