Chromium Code Reviews| 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/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "chrome/browser/lifetime/application_lifetime.h" | 13 #include "chrome/browser/lifetime/application_lifetime.h" |
| 14 #include "chrome/browser/ui/browser_dialogs.h" | 14 #include "chrome/browser/ui/browser_dialogs.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "components/url_fixer/url_fixer.h" | 17 #include "components/url_fixer/url_fixer.h" |
| 18 | 18 |
| 19 bool FixupBrowserAboutURL(GURL* url, | |
| 20 content::BrowserContext* browser_context) { | |
| 21 // Ensure that any cleanup done by FixupURL happens before the rewriting | |
| 22 // phase that determines the virtual URL, by including it in an initial | |
| 23 // URLHandler. This prevents minor changes from producing a virtual URL, | |
| 24 // which could lead to a URL spoof. | |
| 25 *url = url_fixer::FixupURL(url->possibly_invalid_spec(), std::string()); | |
| 26 return true; | |
| 27 } | |
| 28 | |
| 19 bool WillHandleBrowserAboutURL(GURL* url, | 29 bool WillHandleBrowserAboutURL(GURL* url, |
| 20 content::BrowserContext* browser_context) { | 30 content::BrowserContext* browser_context) { |
| 21 // TODO(msw): Eliminate "about:*" constants and literals from code and tests, | 31 // TODO(msw): Eliminate "about:*" constants and literals from code and tests, |
| 22 // then hopefully we can remove this forced fixup. | 32 // then hopefully we can remove this forced fixup. |
| 23 *url = url_fixer::FixupURL(url->possibly_invalid_spec(), std::string()); | 33 *url = url_fixer::FixupURL(url->possibly_invalid_spec(), std::string()); |
|
msw
2015/02/18 22:01:23
Should this call FixupBrowserAboutURL instead?
Charlie Reis
2015/02/18 22:16:17
Good idea. Done.
| |
| 24 | 34 |
| 25 // Check that about: URLs are fixed up to chrome: by url_fixer::FixupURL. | 35 // Check that about: URLs are fixed up to chrome: by url_fixer::FixupURL. |
| 26 DCHECK((*url == GURL(url::kAboutBlankURL)) || | 36 DCHECK((*url == GURL(url::kAboutBlankURL)) || |
| 27 !url->SchemeIs(url::kAboutScheme)); | 37 !url->SchemeIs(url::kAboutScheme)); |
| 28 | 38 |
| 29 // Only handle chrome://foo/, url_fixer::FixupURL translates about:foo. | 39 // Only handle chrome://foo/, url_fixer::FixupURL translates about:foo. |
| 30 if (!url->SchemeIs(content::kChromeUIScheme)) | 40 if (!url->SchemeIs(content::kChromeUIScheme)) |
| 31 return false; | 41 return false; |
| 32 | 42 |
| 33 std::string host(url->host()); | 43 std::string host(url->host()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 base::Bind(&chrome::AttemptRestart)); | 110 base::Bind(&chrome::AttemptRestart)); |
| 101 return true; | 111 return true; |
| 102 } else if (LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { | 112 } else if (LowerCaseEqualsASCII(spec, chrome::kChromeUIQuitURL)) { |
| 103 base::MessageLoop::current()->PostTask(FROM_HERE, | 113 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 104 base::Bind(&chrome::AttemptExit)); | 114 base::Bind(&chrome::AttemptExit)); |
| 105 return true; | 115 return true; |
| 106 } | 116 } |
| 107 | 117 |
| 108 return false; | 118 return false; |
| 109 } | 119 } |
| OLD | NEW |