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

Side by Side Diff: chrome/browser/ui/browser_navigator_browsertest.cc

Issue 2137503002: Revert of Replace string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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 (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/ui/browser_navigator_browsertest.h" 5 #include "chrome/browser/ui/browser_navigator_browsertest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 // Converts long uber URLs ("chrome://chrome/foo/") to short (virtual) URLs 63 // Converts long uber URLs ("chrome://chrome/foo/") to short (virtual) URLs
64 // ("chrome://foo/"). This should be used to convert the return value of 64 // ("chrome://foo/"). This should be used to convert the return value of
65 // WebContentsImpl::GetURL before comparison because it can return either the 65 // WebContentsImpl::GetURL before comparison because it can return either the
66 // real URL or the virtual URL. 66 // real URL or the virtual URL.
67 GURL ShortenUberURL(const GURL& url) { 67 GURL ShortenUberURL(const GURL& url) {
68 std::string url_string = url.spec(); 68 std::string url_string = url.spec();
69 const std::string long_prefix = "chrome://chrome/"; 69 const std::string long_prefix = "chrome://chrome/";
70 const std::string short_prefix = "chrome://"; 70 const std::string short_prefix = "chrome://";
71 if (!base::StartsWith(url_string, long_prefix, base::CompareCase::SENSITIVE)) 71 if (url_string.find(long_prefix) != 0)
72 return url; 72 return url;
73 url_string.replace(0, long_prefix.length(), short_prefix); 73 url_string.replace(0, long_prefix.length(), short_prefix);
74 return GURL(url_string); 74 return GURL(url_string);
75 } 75 }
76 76
77 } // namespace 77 } // namespace
78 78
79 chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const { 79 chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const {
80 return MakeNavigateParams(browser()); 80 return MakeNavigateParams(browser());
81 } 81 }
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 EXPECT_EQ(expected_title, params.target_contents->GetTitle()); 1443 EXPECT_EQ(expected_title, params.target_contents->GetTitle());
1444 // GURL always keeps non-ASCII characters escaped, but check them anyways. 1444 // GURL always keeps non-ASCII characters escaped, but check them anyways.
1445 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec()); 1445 EXPECT_EQ(GURL(expected_url).spec(), params.target_contents->GetURL().spec());
1446 // Check the omnibox text. It should have escaped RTL with unescaped text. 1446 // Check the omnibox text. It should have escaped RTL with unescaped text.
1447 LocationBar* location_bar = browser()->window()->GetLocationBar(); 1447 LocationBar* location_bar = browser()->window()->GetLocationBar();
1448 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 1448 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
1449 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText()); 1449 EXPECT_EQ(base::UTF8ToUTF16(expected_url), omnibox_view->GetText());
1450 } 1450 }
1451 1451
1452 } // namespace 1452 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_avatar_icon_util.cc ('k') | chrome/browser/ui/find_bar/find_bar_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698