Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: ios/chrome/browser/browser_about_rewriter.cc

Issue 2485253002: Remove unnecessary calls to GURL() (Closed)
Patch Set: Assert that StringPiece must always be canonicalized. Fix some constants. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 14 matching lines...) Expand all
25 } // namespace 25 } // namespace
26 26
27 bool WillHandleWebBrowserAboutURL(GURL* url, web::BrowserState* browser_state) { 27 bool WillHandleWebBrowserAboutURL(GURL* url, web::BrowserState* browser_state) {
28 // Ensure that any cleanup done by FixupURL happens before the rewriting 28 // Ensure that any cleanup done by FixupURL happens before the rewriting
29 // phase that determines the virtual URL, by including it in an initial 29 // phase that determines the virtual URL, by including it in an initial
30 // URLHandler. This prevents minor changes from producing a virtual URL, 30 // URLHandler. This prevents minor changes from producing a virtual URL,
31 // which could lead to a URL spoof. 31 // which could lead to a URL spoof.
32 *url = url_formatter::FixupURL(url->possibly_invalid_spec(), std::string()); 32 *url = url_formatter::FixupURL(url->possibly_invalid_spec(), std::string());
33 33
34 // Check that about: URLs are fixed up to chrome: by url_formatter::FixupURL. 34 // Check that about: URLs are fixed up to chrome: by url_formatter::FixupURL.
35 DCHECK((*url == GURL(url::kAboutBlankURL)) || 35 DCHECK((*url == url::kAboutBlankURL) || !url->SchemeIs(url::kAboutScheme));
36 !url->SchemeIs(url::kAboutScheme));
37 36
38 // url_formatter::FixupURL translates about:foo into chrome://foo/. 37 // url_formatter::FixupURL translates about:foo into chrome://foo/.
39 if (!url->SchemeIs(kChromeUIScheme)) 38 if (!url->SchemeIs(kChromeUIScheme))
40 return false; 39 return false;
41 40
42 std::string host(url->host()); 41 std::string host(url->host());
43 for (size_t i = 0; i < arraysize(kHostReplacements); ++i) { 42 for (size_t i = 0; i < arraysize(kHostReplacements); ++i) {
44 if (host != kHostReplacements[i].old_host_name) 43 if (host != kHostReplacements[i].old_host_name)
45 continue; 44 continue;
46 45
47 host.assign(kHostReplacements[i].new_host_name); 46 host.assign(kHostReplacements[i].new_host_name);
48 break; 47 break;
49 } 48 }
50 49
51 GURL::Replacements replacements; 50 GURL::Replacements replacements;
52 replacements.SetHostStr(host); 51 replacements.SetHostStr(host);
53 *url = url->ReplaceComponents(replacements); 52 *url = url->ReplaceComponents(replacements);
54 53
55 // Having re-written the URL, make the chrome: handler process it. 54 // Having re-written the URL, make the chrome: handler process it.
56 return false; 55 return false;
57 } 56 }
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/extension_view/extension_view_guest.cc ('k') | ios/chrome/browser/history/history_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698