| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/browser_about_rewriter.h" | 5 #include "ios/chrome/browser/browser_about_rewriter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "components/url_formatter/url_fixer.h" | 10 #include "components/url_formatter/url_fixer.h" |
| 11 #include "ios/chrome/browser/chrome_url_constants.h" | 11 #include "ios/chrome/browser/chrome_url_constants.h" |
| 12 #include "url/url_constants.h" | 12 #include "url/url_constants.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const struct HostReplacement { | 16 const struct HostReplacement { |
| 17 const char* old_host_name; | 17 const char* old_host_name; |
| 18 const char* new_host_name; | 18 const char* new_host_name; |
| 19 } kHostReplacements[] = { | 19 } kHostReplacements[] = { |
| 20 {"about", kChromeUIChromeURLsHost}, | 20 {"about", kChromeUIChromeURLsHost}, |
| 21 {"history", kChromeUIHistoryFrameHost}, | |
| 22 {"sync", kChromeUISyncInternalsHost}, | 21 {"sync", kChromeUISyncInternalsHost}, |
| 23 }; | 22 }; |
| 24 | 23 |
| 25 } // namespace | 24 } // namespace |
| 26 | 25 |
| 27 bool WillHandleWebBrowserAboutURL(GURL* url, web::BrowserState* browser_state) { | 26 bool WillHandleWebBrowserAboutURL(GURL* url, web::BrowserState* browser_state) { |
| 28 // Ensure that any cleanup done by FixupURL happens before the rewriting | 27 // Ensure that any cleanup done by FixupURL happens before the rewriting |
| 29 // phase that determines the virtual URL, by including it in an initial | 28 // phase that determines the virtual URL, by including it in an initial |
| 30 // URLHandler. This prevents minor changes from producing a virtual URL, | 29 // URLHandler. This prevents minor changes from producing a virtual URL, |
| 31 // which could lead to a URL spoof. | 30 // which could lead to a URL spoof. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 47 break; | 46 break; |
| 48 } | 47 } |
| 49 | 48 |
| 50 GURL::Replacements replacements; | 49 GURL::Replacements replacements; |
| 51 replacements.SetHostStr(host); | 50 replacements.SetHostStr(host); |
| 52 *url = url->ReplaceComponents(replacements); | 51 *url = url->ReplaceComponents(replacements); |
| 53 | 52 |
| 54 // Having re-written the URL, make the chrome: handler process it. | 53 // Having re-written the URL, make the chrome: handler process it. |
| 55 return false; | 54 return false; |
| 56 } | 55 } |
| OLD | NEW |