diff options
author | brettw <brettw@chromium.org> | 2015-07-16 10:49:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-16 17:50:12 +0000 |
commit | a7ff1b291cd328e9584779a4bb9101fa9a3c01ad (patch) | |
tree | d010374be1ca156ea26405ae7b0aa85e48bb4bba | |
parent | 7befa9cf85342a0409502ed2c05d7610afec7844 (diff) | |
download | chromium_src-a7ff1b291cd328e9584779a4bb9101fa9a3c01ad.zip chromium_src-a7ff1b291cd328e9584779a4bb9101fa9a3c01ad.tar.gz chromium_src-a7ff1b291cd328e9584779a4bb9101fa9a3c01ad.tar.bz2 |
Remove some legacy versions of StartsWith and EndsWith.
This just replaces
true -> base::CompareCase::SENSITIVE
false -> base::CompareCase::INSENSITIVE_ASCII
I checked the insensitive cases to make sure they're not doing anything suspicious. The old version is a sometimes-correct Unicode comparison so converting to INSENSTITIVE_ASCII isn't a no-op. However, generally the prefix/suffix checking is done against a hardcoded string so there were very few cases to actually look at.
extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc has a not-quite search-and-replace change where I changed the type of a class variable.
BUG=506255
TBR=jam
Reland of http://crrev.com/1239493005
Review URL: https://codereview.chromium.org/1233043003
Cr-Commit-Position: refs/heads/master@{#339071}
88 files changed, 326 insertions, 225 deletions
diff --git a/base/android/library_loader/library_prefetcher.cc b/base/android/library_loader/library_prefetcher.cc index 798a283..9b54843 100644 --- a/base/android/library_loader/library_prefetcher.cc +++ b/base/android/library_loader/library_prefetcher.cc @@ -36,7 +36,7 @@ bool IsReadableAndPrivate(const base::debug::MappedMemoryRegion& region) { bool PathMatchesSuffix(const std::string& path) { for (size_t i = 0; i < arraysize(kSuffixesToMatch); i++) { - if (EndsWith(path, kSuffixesToMatch[i], true)) { + if (EndsWith(path, kSuffixesToMatch[i], CompareCase::SENSITIVE)) { return true; } } @@ -82,14 +82,14 @@ void NativeLibraryPrefetcher::FilterLibchromeRangesOnlyIfPossible( std::vector<AddressRange>* ranges) { bool has_libchrome_region = false; for (const base::debug::MappedMemoryRegion& region : regions) { - if (EndsWith(region.path, kLibchromeSuffix, true)) { + if (EndsWith(region.path, kLibchromeSuffix, CompareCase::SENSITIVE)) { has_libchrome_region = true; break; } } for (const base::debug::MappedMemoryRegion& region : regions) { if (has_libchrome_region && - !EndsWith(region.path, kLibchromeSuffix, true)) { + !EndsWith(region.path, kLibchromeSuffix, CompareCase::SENSITIVE)) { continue; } ranges->push_back(std::make_pair(region.start, region.end)); diff --git a/base/strings/string_util.h b/base/strings/string_util.h index d7a08c8..755215c 100644 --- a/base/strings/string_util.h +++ b/base/strings/string_util.h @@ -381,19 +381,6 @@ inline bool StartsWithASCII(const std::string& str, case_sensitive ? CompareCase::SENSITIVE : CompareCase::INSENSITIVE_ASCII); } -BASE_EXPORT bool StartsWith(const string16& str, - const string16& search, - bool case_sensitive); -inline bool EndsWith(const std::string& str, - const std::string& search, - bool case_sensitive) { - return EndsWith(StringPiece(str), StringPiece(search), - case_sensitive ? CompareCase::SENSITIVE - : CompareCase::INSENSITIVE_ASCII); -} -BASE_EXPORT bool EndsWith(const string16& str, - const string16& search, - bool case_sensitive); // Determines the type of ASCII character, independent of locale (the C // library versions will change based on locale). diff --git a/base/strings/string_util_unittest.cc b/base/strings/string_util_unittest.cc index 5d5ba8b..eb6cd7e 100644 --- a/base/strings/string_util_unittest.cc +++ b/base/strings/string_util_unittest.cc @@ -706,59 +706,83 @@ TEST(StringUtilTest, JoinString16) { } TEST(StringUtilTest, StartsWith) { - EXPECT_TRUE(StartsWithASCII("javascript:url", "javascript", true)); - EXPECT_FALSE(StartsWithASCII("JavaScript:url", "javascript", true)); - EXPECT_TRUE(StartsWithASCII("javascript:url", "javascript", false)); - EXPECT_TRUE(StartsWithASCII("JavaScript:url", "javascript", false)); - EXPECT_FALSE(StartsWithASCII("java", "javascript", true)); - EXPECT_FALSE(StartsWithASCII("java", "javascript", false)); - EXPECT_FALSE(StartsWithASCII(std::string(), "javascript", false)); - EXPECT_FALSE(StartsWithASCII(std::string(), "javascript", true)); - EXPECT_TRUE(StartsWithASCII("java", std::string(), false)); - EXPECT_TRUE(StartsWithASCII("java", std::string(), true)); + EXPECT_TRUE(StartsWith("javascript:url", "javascript", + base::CompareCase::SENSITIVE)); + EXPECT_FALSE(StartsWith("JavaScript:url", "javascript", + base::CompareCase::SENSITIVE)); + EXPECT_TRUE(StartsWith("javascript:url", "javascript", + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_TRUE(StartsWith("JavaScript:url", "javascript", + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(StartsWith("java", "javascript", base::CompareCase::SENSITIVE)); + EXPECT_FALSE(StartsWith("java", "javascript", + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(StartsWith(std::string(), "javascript", + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(StartsWith(std::string(), "javascript", + base::CompareCase::SENSITIVE)); + EXPECT_TRUE(StartsWith("java", std::string(), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_TRUE(StartsWith("java", std::string(), base::CompareCase::SENSITIVE)); EXPECT_TRUE(StartsWith(ASCIIToUTF16("javascript:url"), - ASCIIToUTF16("javascript"), true)); + ASCIIToUTF16("javascript"), + base::CompareCase::SENSITIVE)); EXPECT_FALSE(StartsWith(ASCIIToUTF16("JavaScript:url"), - ASCIIToUTF16("javascript"), true)); + ASCIIToUTF16("javascript"), + base::CompareCase::SENSITIVE)); EXPECT_TRUE(StartsWith(ASCIIToUTF16("javascript:url"), - ASCIIToUTF16("javascript"), false)); + ASCIIToUTF16("javascript"), + base::CompareCase::INSENSITIVE_ASCII)); EXPECT_TRUE(StartsWith(ASCIIToUTF16("JavaScript:url"), - ASCIIToUTF16("javascript"), false)); - EXPECT_FALSE(StartsWith(ASCIIToUTF16("java"), - ASCIIToUTF16("javascript"), true)); - EXPECT_FALSE(StartsWith(ASCIIToUTF16("java"), - ASCIIToUTF16("javascript"), false)); - EXPECT_FALSE(StartsWith(string16(), ASCIIToUTF16("javascript"), false)); - EXPECT_FALSE(StartsWith(string16(), ASCIIToUTF16("javascript"), true)); - EXPECT_TRUE(StartsWith(ASCIIToUTF16("java"), string16(), false)); - EXPECT_TRUE(StartsWith(ASCIIToUTF16("java"), string16(), true)); + ASCIIToUTF16("javascript"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(StartsWith(ASCIIToUTF16("java"), ASCIIToUTF16("javascript"), + base::CompareCase::SENSITIVE)); + EXPECT_FALSE(StartsWith(ASCIIToUTF16("java"), ASCIIToUTF16("javascript"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(StartsWith(string16(), ASCIIToUTF16("javascript"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(StartsWith(string16(), ASCIIToUTF16("javascript"), + base::CompareCase::SENSITIVE)); + EXPECT_TRUE(StartsWith(ASCIIToUTF16("java"), string16(), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_TRUE(StartsWith(ASCIIToUTF16("java"), string16(), + base::CompareCase::SENSITIVE)); } TEST(StringUtilTest, EndsWith) { - EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), - ASCIIToUTF16(".plugin"), true)); - EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.Plugin"), - ASCIIToUTF16(".plugin"), true)); - EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), - ASCIIToUTF16(".plugin"), false)); - EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.Plugin"), - ASCIIToUTF16(".plugin"), false)); - EXPECT_FALSE(EndsWith(ASCIIToUTF16(".plug"), ASCIIToUTF16(".plugin"), true)); - EXPECT_FALSE(EndsWith(ASCIIToUTF16(".plug"), ASCIIToUTF16(".plugin"), false)); - EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.plugin Bar"), - ASCIIToUTF16(".plugin"), true)); - EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.plugin Bar"), - ASCIIToUTF16(".plugin"), false)); - EXPECT_FALSE(EndsWith(string16(), ASCIIToUTF16(".plugin"), false)); - EXPECT_FALSE(EndsWith(string16(), ASCIIToUTF16(".plugin"), true)); - EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), string16(), false)); - EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), string16(), true)); - EXPECT_TRUE(EndsWith(ASCIIToUTF16(".plugin"), - ASCIIToUTF16(".plugin"), false)); - EXPECT_TRUE(EndsWith(ASCIIToUTF16(".plugin"), ASCIIToUTF16(".plugin"), true)); - EXPECT_TRUE(EndsWith(string16(), string16(), false)); - EXPECT_TRUE(EndsWith(string16(), string16(), true)); + EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), ASCIIToUTF16(".plugin"), + base::CompareCase::SENSITIVE)); + EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.Plugin"), ASCIIToUTF16(".plugin"), + base::CompareCase::SENSITIVE)); + EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), ASCIIToUTF16(".plugin"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.Plugin"), ASCIIToUTF16(".plugin"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(EndsWith(ASCIIToUTF16(".plug"), ASCIIToUTF16(".plugin"), + base::CompareCase::SENSITIVE)); + EXPECT_FALSE(EndsWith(ASCIIToUTF16(".plug"), ASCIIToUTF16(".plugin"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.plugin Bar"), ASCIIToUTF16(".plugin"), + base::CompareCase::SENSITIVE)); + EXPECT_FALSE(EndsWith(ASCIIToUTF16("Foo.plugin Bar"), ASCIIToUTF16(".plugin"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(EndsWith(string16(), ASCIIToUTF16(".plugin"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_FALSE(EndsWith(string16(), ASCIIToUTF16(".plugin"), + base::CompareCase::SENSITIVE)); + EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), string16(), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_TRUE(EndsWith(ASCIIToUTF16("Foo.plugin"), string16(), + base::CompareCase::SENSITIVE)); + EXPECT_TRUE(EndsWith(ASCIIToUTF16(".plugin"), ASCIIToUTF16(".plugin"), + base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_TRUE(EndsWith(ASCIIToUTF16(".plugin"), ASCIIToUTF16(".plugin"), + base::CompareCase::SENSITIVE)); + EXPECT_TRUE( + EndsWith(string16(), string16(), base::CompareCase::INSENSITIVE_ASCII)); + EXPECT_TRUE(EndsWith(string16(), string16(), base::CompareCase::SENSITIVE)); } TEST(StringUtilTest, GetStringFWithOffsets) { diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index e281cff..2910466 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -338,7 +338,7 @@ void TestSuite::Initialize() { i18n::SetICUDefaultLocale("en_US"); #else std::string default_locale(uloc_getDefault()); - if (EndsWith(default_locale, "POSIX", false)) + if (EndsWith(default_locale, "POSIX", CompareCase::INSENSITIVE_ASCII)) i18n::SetICUDefaultLocale("en_US"); #endif #endif diff --git a/chrome/app/delay_load_hook_win.cc b/chrome/app/delay_load_hook_win.cc index 6afac88..52384d4 100644 --- a/chrome/app/delay_load_hook_win.cc +++ b/chrome/app/delay_load_hook_win.cc @@ -28,7 +28,8 @@ FARPROC OnPreLoadLibrary(DelayLoadInfo* info) { // and bind to the real DLL. std::string dll_name(info->szDll); const char kDelaySuffix[] = "-delay.dll"; - if (base::EndsWith(dll_name, kDelaySuffix, false)) { + if (base::EndsWith(dll_name, kDelaySuffix, + base::CompareCase::INSENSITIVE_ASCII)) { // Trim the "-delay.dll" suffix from the string. dll_name.resize(dll_name.length() - (sizeof(kDelaySuffix) - 1)); dll_name.append(".dll"); diff --git a/chrome/browser/banners/app_banner_data_fetcher.cc b/chrome/browser/banners/app_banner_data_fetcher.cc index d926ed3..c61385b 100644 --- a/chrome/browser/banners/app_banner_data_fetcher.cc +++ b/chrome/browser/banners/app_banner_data_fetcher.cc @@ -40,7 +40,8 @@ bool DoesManifestContainRequiredIcon(const content::Manifest& manifest) { // the src extension, and allow the icon if the extension ends with png. if (!base::EqualsASCII(icon.type.string(), "image/png") && !(icon.type.is_null() && - base::EndsWith(icon.src.ExtractFileName(), kPngExtension, false))) + base::EndsWith(icon.src.ExtractFileName(), kPngExtension, + base::CompareCase::INSENSITIVE_ASCII))) continue; for (const auto& size : icon.sizes) { diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc index d8dec49..bc79830 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc @@ -919,7 +919,8 @@ void WallpaperPrivateGetOfflineWallpaperListFunction::GetList() { current = files.Next()) { std::string file_name = current.BaseName().RemoveExtension().value(); // Do not add file name of small resolution wallpaper to the list. - if (!base::EndsWith(file_name, wallpaper::kSmallWallpaperSuffix, true)) + if (!base::EndsWith(file_name, wallpaper::kSmallWallpaperSuffix, + base::CompareCase::SENSITIVE)) file_list.push_back(current.BaseName().value()); } } diff --git a/chrome/browser/chromeos/policy/device_local_account.cc b/chrome/browser/chromeos/policy/device_local_account.cc index 3e85b3c..2657377 100644 --- a/chrome/browser/chromeos/policy/device_local_account.cc +++ b/chrome/browser/chromeos/policy/device_local_account.cc @@ -68,7 +68,8 @@ bool IsDeviceLocalAccountUser(const std::string& user_id, if (user_id == chromeos::login::kGuestUserName) return false; const std::string domain = gaia::ExtractDomainName(user_id); - if (!base::EndsWith(domain, kDeviceLocalAccountDomainSuffix, true)) + if (!base::EndsWith(domain, kDeviceLocalAccountDomainSuffix, + base::CompareCase::SENSITIVE)) return false; const std::string domain_prefix = domain.substr( diff --git a/chrome/browser/component_updater/cld_component_installer_unittest.cc b/chrome/browser/component_updater/cld_component_installer_unittest.cc index ab40b35..aa19c25 100644 --- a/chrome/browser/component_updater/cld_component_installer_unittest.cc +++ b/chrome/browser/component_updater/cld_component_installer_unittest.cc @@ -102,7 +102,8 @@ TEST_F(CldComponentInstallerTest, GetInstalledPath) { const base::FilePath base_dir; const base::FilePath result = CldComponentInstallerTraits::GetInstalledPath(base_dir); - ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, true)); + ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, + base::CompareCase::SENSITIVE)); } TEST_F(CldComponentInstallerTest, GetBaseDirectory) { @@ -127,8 +128,10 @@ TEST_F(CldComponentInstallerTest, ComponentReady) { traits_.ComponentReady(version, install_dir, manifest.Pass()); base::FilePath result = CldComponentInstallerTraits::GetLatestCldDataFile(); ASSERT_TRUE(base::StartsWith(result.AsUTF16Unsafe(), - install_dir.AsUTF16Unsafe(), true)); - ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, true)); + install_dir.AsUTF16Unsafe(), + base::CompareCase::SENSITIVE)); + ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, + base::CompareCase::SENSITIVE)); } } // namespace component_updater diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc index 169f8da..0f58e84 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc @@ -223,7 +223,8 @@ class DelayLoadStartAndExecuteJavascript const GURL& url, ui::PageTransition transition_type) override { if (script_was_executed_ && - base::EndsWith(url.spec(), until_url_suffix_, true)) { + base::EndsWith(url.spec(), until_url_suffix_, + base::CompareCase::SENSITIVE)) { content::WebContentsObserver::Observe(NULL); test_navigation_listener_->ResumeAll(); } diff --git a/chrome/browser/extensions/default_apps.cc b/chrome/browser/extensions/default_apps.cc index c8078e4..2cc3228 100644 --- a/chrome/browser/extensions/default_apps.cc +++ b/chrome/browser/extensions/default_apps.cc @@ -37,7 +37,8 @@ bool IsLocaleSupported() { const std::string& locale = g_browser_process->GetApplicationLocale(); static const char* const unsupported_locales[] = {"CN", "TR", "IR"}; for (size_t i = 0; i < arraysize(unsupported_locales); ++i) { - if (base::EndsWith(locale, unsupported_locales[i], false)) { + if (base::EndsWith(locale, unsupported_locales[i], + base::CompareCase::INSENSITIVE_ASCII)) { return false; } } diff --git a/chrome/browser/extensions/updater/local_extension_cache.cc b/chrome/browser/extensions/updater/local_extension_cache.cc index 677b3e8..14273a8 100644 --- a/chrome/browser/extensions/updater/local_extension_cache.cc +++ b/chrome/browser/extensions/updater/local_extension_cache.cc @@ -421,7 +421,7 @@ void LocalExtensionCache::BackendCheckCacheContentsInternal( std::string version; std::string expected_hash; if (base::EndsWith(basename, kCRXFileExtension, - false /* case-sensitive */)) { + base::CompareCase::INSENSITIVE_ASCII)) { size_t n = basename.find('-'); if (n != std::string::npos && n + 1 < basename.size() - 4) { id = basename.substr(0, n); diff --git a/chrome/browser/metrics/chromeos_metrics_provider.cc b/chrome/browser/metrics/chromeos_metrics_provider.cc index 8360369..7c65d0b 100644 --- a/chrome/browser/metrics/chromeos_metrics_provider.cc +++ b/chrome/browser/metrics/chromeos_metrics_provider.cc @@ -115,7 +115,7 @@ EnrollmentStatus GetEnrollmentStatus() { return NON_MANAGED; std::string domain = connector->GetEnterpriseDomain(); - if (base::EndsWith(domain, kEduDomain, false /* case insensitive */)) + if (base::EndsWith(domain, kEduDomain, base::CompareCase::INSENSITIVE_ASCII)) return MANAGED_EDU; return MANAGED_NON_EDU; diff --git a/chrome/browser/net/pref_proxy_config_tracker_impl.cc b/chrome/browser/net/pref_proxy_config_tracker_impl.cc index 02469dd..6de119ea 100644 --- a/chrome/browser/net/pref_proxy_config_tracker_impl.cc +++ b/chrome/browser/net/pref_proxy_config_tracker_impl.cc @@ -27,7 +27,8 @@ namespace { // Determine if |proxy| is of the form "*.googlezip.net". bool IsGooglezipDataReductionProxy(const net::ProxyServer& proxy) { return proxy.is_valid() && !proxy.is_direct() && - base::EndsWith(proxy.host_port_pair().host(), ".googlezip.net", true); + base::EndsWith(proxy.host_port_pair().host(), ".googlezip.net", + base::CompareCase::SENSITIVE); } // Removes any Data Reduction Proxies like *.googlezip.net from |proxy_list|. diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc index cb74b99..b8471ea 100644 --- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc @@ -45,7 +45,8 @@ bool ContainsDataReductionProxyDefaultHostSuffix( for (const net::ProxyServer& proxy : proxy_list.GetAll()) { if (proxy.is_valid() && !proxy.is_direct() && base::EndsWith(proxy.host_port_pair().host(), - kDataReductionProxyDefaultHostSuffix, true)) { + kDataReductionProxyDefaultHostSuffix, + base::CompareCase::SENSITIVE)) { return true; } } diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc index 09e4643..5a7929e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database.cc @@ -1792,7 +1792,8 @@ void SafeBrowsingDatabaseNew::RecordFileSizeHistogram( // Default to logging DB sizes unless |file_path| points at PrefixSet storage. std::string histogram_name("SB2.DatabaseSizeKilobytes"); - if (base::EndsWith(filename, kPrefixSetFileSuffix, true)) { + if (base::EndsWith(filename, kPrefixSetFileSuffix, + base::CompareCase::SENSITIVE)) { histogram_name = "SB2.PrefixSetSizeKilobytes"; // Clear the PrefixSet suffix to have the histogram suffix selector below // work the same for PrefixSet-based storage as it does for simple safe @@ -1805,21 +1806,28 @@ void SafeBrowsingDatabaseNew::RecordFileSizeHistogram( // Changes to histogram suffixes below need to be mirrored in the // SafeBrowsingLists suffix enum in histograms.xml. - if (base::EndsWith(filename, kBrowseDBFile, true)) + if (base::EndsWith(filename, kBrowseDBFile, base::CompareCase::SENSITIVE)) histogram_name.append(".Browse"); - else if (base::EndsWith(filename, kDownloadDBFile, true)) + else if (base::EndsWith(filename, kDownloadDBFile, + base::CompareCase::SENSITIVE)) histogram_name.append(".Download"); - else if (base::EndsWith(filename, kCsdWhitelistDBFile, true)) + else if (base::EndsWith(filename, kCsdWhitelistDBFile, + base::CompareCase::SENSITIVE)) histogram_name.append(".CsdWhitelist"); - else if (base::EndsWith(filename, kDownloadWhitelistDBFile, true)) + else if (base::EndsWith(filename, kDownloadWhitelistDBFile, + base::CompareCase::SENSITIVE)) histogram_name.append(".DownloadWhitelist"); - else if (base::EndsWith(filename, kInclusionWhitelistDBFile, true)) + else if (base::EndsWith(filename, kInclusionWhitelistDBFile, + base::CompareCase::SENSITIVE)) histogram_name.append(".InclusionWhitelist"); - else if (base::EndsWith(filename, kExtensionBlacklistDBFile, true)) + else if (base::EndsWith(filename, kExtensionBlacklistDBFile, + base::CompareCase::SENSITIVE)) histogram_name.append(".ExtensionBlacklist"); - else if (base::EndsWith(filename, kIPBlacklistDBFile, true)) + else if (base::EndsWith(filename, kIPBlacklistDBFile, + base::CompareCase::SENSITIVE)) histogram_name.append(".IPBlacklist"); - else if (base::EndsWith(filename, kUnwantedSoftwareDBFile, true)) + else if (base::EndsWith(filename, kUnwantedSoftwareDBFile, + base::CompareCase::SENSITIVE)) histogram_name.append(".UnwantedSoftware"); else NOTREACHED(); // Add support for new lists above. diff --git a/chrome/browser/search/iframe_source.cc b/chrome/browser/search/iframe_source.cc index c611501..55282b8 100644 --- a/chrome/browser/search/iframe_source.cc +++ b/chrome/browser/search/iframe_source.cc @@ -25,13 +25,13 @@ IframeSource::~IframeSource() { std::string IframeSource::GetMimeType( const std::string& path_and_query) const { std::string path(GURL("chrome-search://host/" + path_and_query).path()); - if (base::EndsWith(path, ".js", false)) + if (base::EndsWith(path, ".js", base::CompareCase::INSENSITIVE_ASCII)) return "application/javascript"; - if (base::EndsWith(path, ".png", false)) + if (base::EndsWith(path, ".png", base::CompareCase::INSENSITIVE_ASCII)) return "image/png"; - if (base::EndsWith(path, ".css", false)) + if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII)) return "text/css"; - if (base::EndsWith(path, ".html", false)) + if (base::EndsWith(path, ".html", base::CompareCase::INSENSITIVE_ASCII)) return "text/html"; return std::string(); } diff --git a/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc b/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc index 2e60864..59e4ac8 100644 --- a/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc +++ b/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc @@ -54,7 +54,7 @@ GURL GetNormalizedURL(const GURL& url) { replacements.SetHostStr(base::StringPiece(host).substr(www.size())); // Strip trailing slash (if any). const std::string path(url.path()); - if (base::EndsWith(path, "/", true)) + if (base::EndsWith(path, "/", base::CompareCase::SENSITIVE)) replacements.SetPathStr(base::StringPiece(path).substr(0, path.size() - 1)); return url.ReplaceComponents(replacements); } diff --git a/chrome/browser/supervised_user/supervised_user_url_filter.cc b/chrome/browser/supervised_user/supervised_user_url_filter.cc index b1dad56..667fc25 100644 --- a/chrome/browser/supervised_user/supervised_user_url_filter.cc +++ b/chrome/browser/supervised_user/supervised_user_url_filter.cc @@ -239,7 +239,7 @@ bool SupervisedUserURLFilter::HostMatchesPattern(const std::string& host, const std::string& pattern) { std::string trimmed_pattern = pattern; std::string trimmed_host = host; - if (base::EndsWith(pattern, ".*", true)) { + if (base::EndsWith(pattern, ".*", base::CompareCase::SENSITIVE)) { size_t registry_length = GetRegistryLength( trimmed_host, EXCLUDE_UNKNOWN_REGISTRIES, EXCLUDE_PRIVATE_REGISTRIES); // A host without a known registry part does not match. @@ -258,7 +258,8 @@ bool SupervisedUserURLFilter::HostMatchesPattern(const std::string& host, // pattern. if (trimmed_pattern.empty() || trimmed_pattern.find('*') != std::string::npos || - !base::EndsWith(trimmed_host, trimmed_pattern, true)) { + !base::EndsWith(trimmed_host, trimmed_pattern, + base::CompareCase::SENSITIVE)) { return false; } diff --git a/chrome/browser/sync/test/integration/bookmarks_helper.cc b/chrome/browser/sync/test/integration/bookmarks_helper.cc index ebae3b2..08a863e 100644 --- a/chrome/browser/sync/test/integration/bookmarks_helper.cc +++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc @@ -964,7 +964,8 @@ gfx::Image CreateFavicon(SkColor color) { gfx::Image Create1xFaviconFromPNGFile(const std::string& path) { const char* kPNGExtension = ".png"; - if (!base::EndsWith(path, kPNGExtension, false)) + if (!base::EndsWith(path, kPNGExtension, + base::CompareCase::INSENSITIVE_ASCII)) return gfx::Image(); base::FilePath full_path; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc index 7bd7b96..e087266 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc @@ -1400,16 +1400,16 @@ TEST_F(AutofillDialogControllerTest, BillingVsShippingStreetAddress) { // separated by commas. EXPECT_TRUE(base::StartsWith(form_structure()->field(0)->value, shipping_profile.GetRawInfo(ADDRESS_HOME_LINE1), - true)); + base::CompareCase::SENSITIVE)); EXPECT_TRUE(base::EndsWith(form_structure()->field(0)->value, shipping_profile.GetRawInfo(ADDRESS_HOME_LINE2), - true)); + base::CompareCase::SENSITIVE)); EXPECT_TRUE(base::StartsWith(form_structure()->field(1)->value, billing_profile.GetRawInfo(ADDRESS_HOME_LINE1), - true)); + base::CompareCase::SENSITIVE)); EXPECT_TRUE(base::EndsWith(form_structure()->field(1)->value, billing_profile.GetRawInfo(ADDRESS_HOME_LINE2), - true)); + base::CompareCase::SENSITIVE)); // The textareas should be an exact match. EXPECT_EQ(shipping_profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS), form_structure()->field(2)->value); diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm index 840de46..0fa91ec 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm @@ -563,8 +563,10 @@ NSAttributedString* CreateClassifiedAttributedString( match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex), &contentsStartIndex); // Ignore invalid state. - if (!base::StartsWith(match.fill_into_edit, inputText, true) || - !base::EndsWith(match.fill_into_edit, match.contents, true) || + if (!base::StartsWith(match.fill_into_edit, inputText, + base::CompareCase::SENSITIVE) || + !base::EndsWith(match.fill_into_edit, match.contents, + base::CompareCase::SENSITIVE) || ((size_t)contentsStartIndex >= inputText.length())) { return 0; } diff --git a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc index cfd6955..0797df7 100644 --- a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc +++ b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc @@ -34,7 +34,8 @@ namespace { // Makes sure that .jpg also shows .JPG. gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, std::string* file_extension) { - return base::EndsWith(file_info->filename, *file_extension, false); + return base::EndsWith(file_info->filename, *file_extension, + base::CompareCase::INSENSITIVE_ASCII); } // Deletes |data| when gtk_file_filter_add_custom() is done with it. diff --git a/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc b/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc index 4ea7fe5..c02b0ae 100644 --- a/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc +++ b/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc @@ -67,7 +67,7 @@ TEST(ManagePasswordsViewUtilTest, GetSavePasswordDialogTitleTextAndLinkRange) { // Verify against expectations. EXPECT_TRUE(base::EndsWith( title, base::ASCIIToUTF16(test_cases[i].expected_title_text_ends_with), - false)); + base::CompareCase::INSENSITIVE_ASCII)); EXPECT_EQ(test_cases[i].expected_link_range_start, title_link_range.start()); EXPECT_EQ(test_cases[i].expected_link_range_end, title_link_range.end()); diff --git a/chrome/browser/ui/webui/devtools_ui.cc b/chrome/browser/ui/webui/devtools_ui.cc index 7960c0f..68ccc01 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -49,19 +49,25 @@ const char kFallbackFrontendURL[] = std::string GetMimeTypeForPath(const std::string& path) { std::string filename = PathWithoutParams(path); - if (base::EndsWith(filename, ".html", false)) { + if (base::EndsWith(filename, ".html", base::CompareCase::INSENSITIVE_ASCII)) { return "text/html"; - } else if (base::EndsWith(filename, ".css", false)) { + } else if (base::EndsWith(filename, ".css", + base::CompareCase::INSENSITIVE_ASCII)) { return "text/css"; - } else if (base::EndsWith(filename, ".js", false)) { + } else if (base::EndsWith(filename, ".js", + base::CompareCase::INSENSITIVE_ASCII)) { return "application/javascript"; - } else if (base::EndsWith(filename, ".png", false)) { + } else if (base::EndsWith(filename, ".png", + base::CompareCase::INSENSITIVE_ASCII)) { return "image/png"; - } else if (base::EndsWith(filename, ".gif", false)) { + } else if (base::EndsWith(filename, ".gif", + base::CompareCase::INSENSITIVE_ASCII)) { return "image/gif"; - } else if (base::EndsWith(filename, ".svg", false)) { + } else if (base::EndsWith(filename, ".svg", + base::CompareCase::INSENSITIVE_ASCII)) { return "image/svg+xml"; - } else if (base::EndsWith(filename, ".manifest", false)) { + } else if (base::EndsWith(filename, ".manifest", + base::CompareCase::INSENSITIVE_ASCII)) { return "text/cache-manifest"; } return "text/html"; diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc index 352eba5..6cd974b 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc @@ -124,7 +124,7 @@ bool HandleRequestCallback( const content::WebUIDataSource::GotDataCallback& callback) { // ChromeWebUIDataSource handles most requests except for the print preview // data. - if (!base::EndsWith(path, "/print.pdf", true)) + if (!base::EndsWith(path, "/print.pdf", base::CompareCase::SENSITIVE)) return false; // Print Preview data. diff --git a/chrome/browser/ui/webui/profiler_ui.cc b/chrome/browser/ui/webui/profiler_ui.cc index fda2c09..97629121 100644 --- a/chrome/browser/ui/webui/profiler_ui.cc +++ b/chrome/browser/ui/webui/profiler_ui.cc @@ -58,7 +58,7 @@ class ProfilerWebUIDataSource : public content::URLDataSource { } std::string GetMimeType(const std::string& path) const override { - if (base::EndsWith(path, ".js", false)) + if (base::EndsWith(path, ".js", base::CompareCase::INSENSITIVE_ASCII)) return "application/javascript"; return "text/html"; } diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm index 89cad0e..68b5929 100644 --- a/chrome/browser/web_applications/web_app_mac.mm +++ b/chrome/browser/web_applications/web_app_mac.mm @@ -184,8 +184,8 @@ bool HasExistingExtensionShim(const base::FilePath& destination_directory, !shim_path.empty(); shim_path = enumerator.Next()) { if (shim_path.BaseName() != own_basename && base::EndsWith(shim_path.RemoveExtension().value(), - extension_id, - true /* case_sensitive */)) { + extension_id, + base::CompareCase::SENSITIVE)) { return true; } } diff --git a/chrome/common/extensions/api/networking_private/networking_private_crypto.cc b/chrome/common/extensions/api/networking_private/networking_private_crypto.cc index 7a3c5f3..bf2320e 100644 --- a/chrome/common/extensions/api/networking_private/networking_private_crypto.cc +++ b/chrome/common/extensions/api/networking_private/networking_private_crypto.cc @@ -65,7 +65,8 @@ bool VerifyCredentials( std::string common_name = verification_context->GetCommonName(); std::string translated_mac; base::RemoveChars(connected_mac, ":", &translated_mac); - if (!base::EndsWith(common_name, translated_mac, false)) { + if (!base::EndsWith(common_name, translated_mac, + base::CompareCase::INSENSITIVE_ASCII)) { LOG(ERROR) << kErrorPrefix << "MAC addresses don't match."; return false; } diff --git a/chrome/common/extensions/chrome_extensions_client.cc b/chrome/common/extensions/chrome_extensions_client.cc index 737b49a..686db97 100644 --- a/chrome/common/extensions/chrome_extensions_client.cc +++ b/chrome/common/extensions/chrome_extensions_client.cc @@ -347,7 +347,7 @@ std::string ChromeExtensionsClient::GetWebstoreBaseURL() const { gallery_prefix = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( switches::kAppsGalleryURL); - if (base::EndsWith(gallery_prefix, "/", true)) + if (base::EndsWith(gallery_prefix, "/", base::CompareCase::SENSITIVE)) gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1); return gallery_prefix; } diff --git a/chrome/common/importer/firefox_importer_utils.cc b/chrome/common/importer/firefox_importer_utils.cc index 2ca5c4c..46e120c 100644 --- a/chrome/common/importer/firefox_importer_utils.cc +++ b/chrome/common/importer/firefox_importer_utils.cc @@ -116,7 +116,8 @@ bool ComposeMacAppPath(const std::string& path_from_file, // append Contents/MacOS. for (size_t i = 1; i < path_components.size(); ++i) { *output = output->Append(path_components[i]); - if (base::EndsWith(path_components[i], ".app", true)) { + if (base::EndsWith(path_components[i], ".app", + base::CompareCase::SENSITIVE)) { *output = output->Append("Contents"); *output = output->Append("MacOS"); return true; diff --git a/chrome/common/service_process_util_unittest.cc b/chrome/common/service_process_util_unittest.cc index 3f75249..14af917 100644 --- a/chrome/common/service_process_util_unittest.cc +++ b/chrome/common/service_process_util_unittest.cc @@ -63,7 +63,8 @@ TEST(ServiceProcessUtilTest, ScopedVersionedName) { std::string test_str = "test"; std::string scoped_name = GetServiceProcessScopedVersionedName(test_str); chrome::VersionInfo version_info; - EXPECT_TRUE(base::EndsWith(scoped_name, test_str, true)); + EXPECT_TRUE(base::EndsWith(scoped_name, test_str, + base::CompareCase::SENSITIVE)); EXPECT_NE(std::string::npos, scoped_name.find(version_info.Version())); } diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc index fb5829c..ae22fa8 100644 --- a/chrome/installer/gcapi/gcapi.cc +++ b/chrome/installer/gcapi/gcapi.cc @@ -361,7 +361,8 @@ BOOL CALLBACK ChromeWindowEnumProc(HWND hwnd, LPARAM lparam) { if (!params->shunted_hwnds.count(hwnd) && ::GetClassName(hwnd, window_class, arraysize(window_class)) && - base::StartsWith(window_class, kChromeWindowClassPrefix, false) && + base::StartsWith(window_class, kChromeWindowClassPrefix, + base::CompareCase::INSENSITIVE_ASCII) && ::SetWindowPos(hwnd, params->window_insert_after, params->x, params->y, params->width, params->height, params->flags)) { params->shunted_hwnds.insert(hwnd); diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc index 00d3150..0e01061 100644 --- a/chrome/installer/setup/setup_util_unittest.cc +++ b/chrome/installer/setup/setup_util_unittest.cc @@ -608,5 +608,6 @@ TEST(SetupUtilTest, GetRegistrationDataCommandKey) { UpdatingAppRegistrationData reg_data(app_guid); base::string16 key = installer::GetRegistrationDataCommandKey(reg_data, L"test_name"); - EXPECT_TRUE(base::EndsWith(key, app_guid + L"\\Commands\\test_name", true)); + EXPECT_TRUE(base::EndsWith(key, app_guid + L"\\Commands\\test_name", + base::CompareCase::SENSITIVE)); } diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 655d2f8..84ae486 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -1105,7 +1105,8 @@ base::string16 ExtractShortcutNameFromProperties( dist->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME); } - if (!base::EndsWith(shortcut_name, installer::kLnkExt, false)) + if (!base::EndsWith(shortcut_name, installer::kLnkExt, + base::CompareCase::INSENSITIVE_ASCII)) shortcut_name.append(installer::kLnkExt); return shortcut_name; diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 48bc0a0..ad59ffb 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -1007,8 +1007,10 @@ bool ChromeContentRendererClient::IsNaClAllowed( bool is_photo_app = // Whitelisted apps must be served over https. app_url.SchemeIsCryptographic() && manifest_url.SchemeIsCryptographic() && - (base::EndsWith(app_url_host, "plus.google.com", false) || - base::EndsWith(app_url_host, "plus.sandbox.google.com", false)) && + (base::EndsWith(app_url_host, "plus.google.com", + base::CompareCase::INSENSITIVE_ASCII) || + base::EndsWith(app_url_host, "plus.sandbox.google.com", + base::CompareCase::INSENSITIVE_ASCII)) && manifest_url.DomainIs("ssl.gstatic.com") && (manifest_url_path.find("s2/oz/nacl/") == 1 || manifest_url_path.find("photos/nacl/") == 1); @@ -1021,9 +1023,12 @@ bool ChromeContentRendererClient::IsNaClAllowed( // Whitelisted apps must be served over secure scheme. app_url.SchemeIsCryptographic() && manifest_url.SchemeIsFileSystem() && manifest_url.inner_url()->SchemeIsCryptographic() && - (base::EndsWith(app_url_host, "talkgadget.google.com", false) || - base::EndsWith(app_url_host, "plus.google.com", false) || - base::EndsWith(app_url_host, "plus.sandbox.google.com", false)) && + (base::EndsWith(app_url_host, "talkgadget.google.com", + base::CompareCase::INSENSITIVE_ASCII) || + base::EndsWith(app_url_host, "plus.google.com", + base::CompareCase::INSENSITIVE_ASCII) || + base::EndsWith(app_url_host, "plus.sandbox.google.com", + base::CompareCase::INSENSITIVE_ASCII)) && // The manifest must be loaded from the host's FileSystem. (manifest_fs_host == app_url_host); diff --git a/cloud_print/service/win/service_utils.cc b/cloud_print/service/win/service_utils.cc index 6932447..e64b5cb 100644 --- a/cloud_print/service/win/service_utils.cc +++ b/cloud_print/service/win/service_utils.cc @@ -28,7 +28,8 @@ base::string16 GetLocalComputerName() { base::string16 ReplaceLocalHostInName(const base::string16& user_name) { static const wchar_t kLocalDomain[] = L".\\"; - if (base::StartsWith(user_name, kLocalDomain, true)) { + if (base::StartsWith(user_name, kLocalDomain, + base::CompareCase::SENSITIVE)) { return GetLocalComputerName() + user_name.substr(arraysize(kLocalDomain) - 2); } diff --git a/components/devtools_http_handler/devtools_http_handler.cc b/components/devtools_http_handler/devtools_http_handler.cc index 0080f68..40f7edc 100644 --- a/components/devtools_http_handler/devtools_http_handler.cc +++ b/components/devtools_http_handler/devtools_http_handler.cc @@ -359,17 +359,22 @@ static std::string PathWithoutParams(const std::string& path) { } static std::string GetMimeType(const std::string& filename) { - if (base::EndsWith(filename, ".html", false)) { + if (base::EndsWith(filename, ".html", base::CompareCase::INSENSITIVE_ASCII)) { return "text/html"; - } else if (base::EndsWith(filename, ".css", false)) { + } else if (base::EndsWith(filename, ".css", + base::CompareCase::INSENSITIVE_ASCII)) { return "text/css"; - } else if (base::EndsWith(filename, ".js", false)) { + } else if (base::EndsWith(filename, ".js", + base::CompareCase::INSENSITIVE_ASCII)) { return "application/javascript"; - } else if (base::EndsWith(filename, ".png", false)) { + } else if (base::EndsWith(filename, ".png", + base::CompareCase::INSENSITIVE_ASCII)) { return "image/png"; - } else if (base::EndsWith(filename, ".gif", false)) { + } else if (base::EndsWith(filename, ".gif", + base::CompareCase::INSENSITIVE_ASCII)) { return "image/gif"; - } else if (base::EndsWith(filename, ".json", false)) { + } else if (base::EndsWith(filename, ".json", + base::CompareCase::INSENSITIVE_ASCII)) { return "application/json"; } LOG(ERROR) << "GetMimeType doesn't know mime type for: " diff --git a/components/google/core/browser/google_util.cc b/components/google/core/browser/google_util.cc index 5326502..1eada34 100644 --- a/components/google/core/browser/google_util.cc +++ b/components/google/core/browser/google_util.cc @@ -57,7 +57,8 @@ bool IsValidHostName(const std::string& host, if (base::LowerCaseEqualsASCII(host_minus_tld, domain_in_lower_case.c_str())) return true; if (subdomain_permission == google_util::ALLOW_SUBDOMAIN) - return base::EndsWith(host_minus_tld, "." + domain_in_lower_case, false); + return base::EndsWith(host_minus_tld, "." + domain_in_lower_case, + base::CompareCase::INSENSITIVE_ASCII); return base::LowerCaseEqualsASCII(host_minus_tld, ("www." + domain_in_lower_case).c_str()); } diff --git a/components/omnibox/browser/keyword_provider.cc b/components/omnibox/browser/keyword_provider.cc index b6f7877..8992f02 100644 --- a/components/omnibox/browser/keyword_provider.cc +++ b/components/omnibox/browser/keyword_provider.cc @@ -139,7 +139,8 @@ const TemplateURL* KeywordProvider::GetSubstitutingTemplateURLForInput( // of the original input. if (input->cursor_position() != base::string16::npos && !remaining_input.empty() && - base::EndsWith(input->text(), remaining_input, true)) { + base::EndsWith(input->text(), remaining_input, + base::CompareCase::SENSITIVE)) { int offset = input->text().length() - input->cursor_position(); // The cursor should never be past the last character or before the // first character. diff --git a/components/omnibox/browser/search_suggestion_parser.cc b/components/omnibox/browser/search_suggestion_parser.cc index 11fbdbb..30543fc 100644 --- a/components/omnibox/browser/search_suggestion_parser.cc +++ b/components/omnibox/browser/search_suggestion_parser.cc @@ -151,7 +151,8 @@ void SearchSuggestionParser::SuggestResult::ClassifyMatchContents( // contents, and the input text has an overlap with contents. if (base::StartsWith(suggestion_, input_text, base::CompareCase::SENSITIVE) && - base::EndsWith(suggestion_, match_contents_, true) && + base::EndsWith(suggestion_, match_contents_, + base::CompareCase::SENSITIVE) && (input_text.length() > contents_index)) { lookup_text = input_text.substr(contents_index); } diff --git a/components/pairing/bluetooth_controller_pairing_controller.cc b/components/pairing/bluetooth_controller_pairing_controller.cc index b843354..3d8cb6a 100644 --- a/components/pairing/bluetooth_controller_pairing_controller.cc +++ b/components/pairing/bluetooth_controller_pairing_controller.cc @@ -71,7 +71,7 @@ void BluetoothControllerPairingController::DeviceFound( DCHECK_EQ(current_stage_, STAGE_DEVICES_DISCOVERY); DCHECK(thread_checker_.CalledOnValidThread()); if (base::StartsWith(device->GetName(), base::ASCIIToUTF16(kDeviceNamePrefix), - false)) { + base::CompareCase::INSENSITIVE_ASCII)) { discovered_devices_.insert(device->GetAddress()); FOR_EACH_OBSERVER(ControllerPairingController::Observer, observers_, DiscoveredDevicesListChanged()); diff --git a/components/password_manager/core/browser/password_manager.cc b/components/password_manager/core/browser/password_manager.cc index 078b627..49d8af6 100644 --- a/components/password_manager/core/browser/password_manager.cc +++ b/components/password_manager/core/browser/password_manager.cc @@ -477,7 +477,8 @@ void PasswordManager::CreatePendingLoginManagers( iter != forms.end(); ++iter) { // Don't involve the password manager if this form corresponds to // SpdyProxy authentication, as indicated by the realm. - if (base::EndsWith(iter->signon_realm, kSpdyProxyRealm, true)) + if (base::EndsWith(iter->signon_realm, kSpdyProxyRealm, + base::CompareCase::SENSITIVE)) continue; bool old_manager_found = false; for (const auto& old_manager : old_login_managers) { diff --git a/components/plugins/renderer/mobile_youtube_plugin.cc b/components/plugins/renderer/mobile_youtube_plugin.cc index af24a2b..7b576df 100644 --- a/components/plugins/renderer/mobile_youtube_plugin.cc +++ b/components/plugins/renderer/mobile_youtube_plugin.cc @@ -89,8 +89,10 @@ MobileYouTubePlugin::~MobileYouTubePlugin() {} bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url, const std::string& mime_type) { std::string host = url.host(); - bool is_youtube = base::EndsWith(host, "youtube.com", true) || - base::EndsWith(host, "youtube-nocookie.com", true); + bool is_youtube = + base::EndsWith(host, "youtube.com", base::CompareCase::SENSITIVE) || + base::EndsWith(host, "youtube-nocookie.com", + base::CompareCase::SENSITIVE); return is_youtube && IsValidYouTubeVideo(url.path()) && base::LowerCaseEqualsASCII(mime_type, diff --git a/components/plugins/renderer/plugin_placeholder.cc b/components/plugins/renderer/plugin_placeholder.cc index 113cf8e..04ceb82 100644 --- a/components/plugins/renderer/plugin_placeholder.cc +++ b/components/plugins/renderer/plugin_placeholder.cc @@ -78,14 +78,15 @@ void PluginPlaceholderBase::HidePlugin() { if (element.hasAttribute("width") && element.hasAttribute("height")) { std::string width_str("width:[\\s]*"); width_str += element.getAttribute("width").utf8().data(); - if (base::EndsWith(width_str, "px", false)) { + if (base::EndsWith(width_str, "px", base::CompareCase::INSENSITIVE_ASCII)) { width_str = width_str.substr(0, width_str.length() - 2); } base::TrimWhitespace(width_str, base::TRIM_TRAILING, &width_str); width_str += "[\\s]*px"; std::string height_str("height:[\\s]*"); height_str += element.getAttribute("height").utf8().data(); - if (base::EndsWith(height_str, "px", false)) { + if (base::EndsWith(height_str, "px", + base::CompareCase::INSENSITIVE_ASCII)) { height_str = height_str.substr(0, height_str.length() - 2); } base::TrimWhitespace(height_str, base::TRIM_TRAILING, &height_str); diff --git a/components/search/search.cc b/components/search/search.cc index 8c50d16..92b8ccb 100644 --- a/components/search/search.cc +++ b/components/search/search.cc @@ -90,7 +90,8 @@ bool GetFieldTrialInfo(FieldTrialFlags* flags) { kInstantExtendedFieldTrialName); } - if (base::EndsWith(group_name, kDisablingSuffix, true)) + if (base::EndsWith(group_name, kDisablingSuffix, + base::CompareCase::SENSITIVE)) return false; // We have a valid trial that isn't disabled. Extract the flags. diff --git a/components/storage_monitor/volume_mount_watcher_win.cc b/components/storage_monitor/volume_mount_watcher_win.cc index 6913f03..168d2eb 100644 --- a/components/storage_monitor/volume_mount_watcher_win.cc +++ b/components/storage_monitor/volume_mount_watcher_win.cc @@ -70,7 +70,7 @@ DeviceType GetDeviceType(const base::string16& mount_point) { // Check device strings of the form "X:" and "\\.\X:" // For floppy drives, these will return strings like "/Device/Floppy0" base::string16 device = mount_point; - if (base::EndsWith(mount_point, L"\\", false)) + if (base::EndsWith(mount_point, L"\\", base::CompareCase::INSENSITIVE_ASCII)) device = mount_point.substr(0, mount_point.length() - 1); base::string16 device_path; base::string16 device_path_slash; diff --git a/components/test_runner/web_test_proxy.cc b/components/test_runner/web_test_proxy.cc index 4b2b43a..ad20b1e 100644 --- a/components/test_runner/web_test_proxy.cc +++ b/components/test_runner/web_test_proxy.cc @@ -200,7 +200,7 @@ bool IsLocalHost(const std::string& host) { } bool IsTestHost(const std::string& host) { - return base::EndsWith(host, ".test", false); + return base::EndsWith(host, ".test", base::CompareCase::INSENSITIVE_ASCII); } bool HostIsUsedBySomeTestsToGenerateError(const std::string& host) { diff --git a/components/variations/net/variations_http_header_provider.cc b/components/variations/net/variations_http_header_provider.cc index fd7be82..583d77a 100644 --- a/components/variations/net/variations_http_header_provider.cc +++ b/components/variations/net/variations_http_header_provider.cc @@ -280,7 +280,8 @@ bool VariationsHttpHeaderProvider::ShouldAppendHeaders(const GURL& url) { // is very straight forward. const std::string host = url.host(); for (size_t i = 0; i < arraysize(kSuffixesToSetHeadersFor); ++i) { - if (base::EndsWith(host, kSuffixesToSetHeadersFor[i], false)) + if (base::EndsWith(host, kSuffixesToSetHeadersFor[i], + base::CompareCase::INSENSITIVE_ASCII)) return true; } diff --git a/components/wifi/wifi_service_win.cc b/components/wifi/wifi_service_win.cc index f20c26e..2716136 100644 --- a/components/wifi/wifi_service_win.cc +++ b/components/wifi/wifi_service_win.cc @@ -1154,7 +1154,8 @@ DWORD WiFiServiceImpl::FindAdapterIndexMapByGUID( if (error == ERROR_SUCCESS) { for (int adapter = 0; adapter < interface_info->NumAdapters; ++adapter) { if (base::EndsWith( - interface_info->Adapter[adapter].Name, guid_string, false)) { + interface_info->Adapter[adapter].Name, guid_string, + base::CompareCase::INSENSITIVE_ASCII)) { *adapter_index_map = interface_info->Adapter[adapter]; break; } diff --git a/content/browser/accessibility/android_granularity_movement_browsertest.cc b/content/browser/accessibility/android_granularity_movement_browsertest.cc index 392c262..6ddf830 100644 --- a/content/browser/accessibility/android_granularity_movement_browsertest.cc +++ b/content/browser/accessibility/android_granularity_movement_browsertest.cc @@ -91,7 +91,8 @@ class AndroidGranularityMovementBrowserTest : public ContentBrowserTest { int len = (granularity == GRANULARITY_CHARACTER) ? 1 : end_index - start_index; base::string16 selection = text.substr(start_index, len); - if (base::EndsWith(selection, base::ASCIIToUTF16("\n"), false)) + if (base::EndsWith(selection, base::ASCIIToUTF16("\n"), + base::CompareCase::INSENSITIVE_ASCII)) selection.erase(selection.size() - 1); if (!selection.empty()) { if (!concatenated.empty()) @@ -116,7 +117,8 @@ class AndroidGranularityMovementBrowserTest : public ContentBrowserTest { int len = (granularity == GRANULARITY_CHARACTER) ? 1 : end_index - start_index; base::string16 selection = text.substr(start_index, len); - if (base::EndsWith(selection, base::ASCIIToUTF16("\n"), false)) + if (base::EndsWith(selection, base::ASCIIToUTF16("\n"), + base::CompareCase::INSENSITIVE_ASCII)) selection = selection.substr(0, selection.size() - 1); if (!reverse.empty()) reverse = base::ASCIIToUTF16(", ") + reverse; diff --git a/content/browser/plugin_browsertest.cc b/content/browser/plugin_browsertest.cc index 12969f5..68ff04d 100644 --- a/content/browser/plugin_browsertest.cc +++ b/content/browser/plugin_browsertest.cc @@ -528,7 +528,7 @@ class TestResourceDispatcherHostDelegate // The URL below comes from plugin_geturl_test.cc. if (!base::EndsWith(request->url().spec(), "npapi/plugin_ref_target_page.html", - true)) { + base::CompareCase::SENSITIVE)) { return; } net::HttpRequestHeaders headers; diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index 93140c2..eadffcc 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -581,7 +581,8 @@ base::string16 PluginServiceImpl::GetPluginDisplayNameByPath( // Many plugins on the Mac have .plugin in the actual name, which looks // terrible, so look for that and strip it off if present. const std::string kPluginExtension = ".plugin"; - if (base::EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), true)) + if (base::EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), + base::CompareCase::SENSITIVE)) plugin_name.erase(plugin_name.length() - kPluginExtension.length()); #endif // OS_MACOSX } diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 0f7c69a..5989a53 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -2988,7 +2988,8 @@ void WebContentsImpl::OnDidRunInsecureContent( LOG(WARNING) << security_origin << " ran insecure content from " << target_url.possibly_invalid_spec(); RecordAction(base::UserMetricsAction("SSL.RanInsecureContent")); - if (base::EndsWith(security_origin, kDotGoogleDotCom, false)) + if (base::EndsWith(security_origin, kDotGoogleDotCom, + base::CompareCase::INSENSITIVE_ASCII)) RecordAction(base::UserMetricsAction("SSL.RanInsecureContentGoogle")); controller_.ssl_manager()->DidRunInsecureContent(security_origin); displayed_insecure_content_ = true; diff --git a/content/browser/webui/web_ui_data_source_impl.cc b/content/browser/webui/web_ui_data_source_impl.cc index b401710..09c5896 100644 --- a/content/browser/webui/web_ui_data_source_impl.cc +++ b/content/browser/webui/web_ui_data_source_impl.cc @@ -190,19 +190,19 @@ std::string WebUIDataSourceImpl::GetSource() const { } std::string WebUIDataSourceImpl::GetMimeType(const std::string& path) const { - if (base::EndsWith(path, ".css", false)) + if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII)) return "text/css"; - if (base::EndsWith(path, ".js", false)) + if (base::EndsWith(path, ".js", base::CompareCase::INSENSITIVE_ASCII)) return "application/javascript"; - if (base::EndsWith(path, ".json", false)) + if (base::EndsWith(path, ".json", base::CompareCase::INSENSITIVE_ASCII)) return "application/json"; - if (base::EndsWith(path, ".pdf", false)) + if (base::EndsWith(path, ".pdf", base::CompareCase::INSENSITIVE_ASCII)) return "application/pdf"; - if (base::EndsWith(path, ".svg", false)) + if (base::EndsWith(path, ".svg", base::CompareCase::INSENSITIVE_ASCII)) return "image/svg+xml"; return "text/html"; diff --git a/content/common/set_process_title.cc b/content/common/set_process_title.cc index 229524e..d74af96 100644 --- a/content/common/set_process_title.cc +++ b/content/common/set_process_title.cc @@ -59,7 +59,7 @@ void SetProcessTitleFromCommandLine(const char** main_argv) { // If the binary has since been deleted, Linux appends " (deleted)" to the // symlink target. Remove it, since this is not really part of our name. const std::string kDeletedSuffix = " (deleted)"; - if (base::EndsWith(title, kDeletedSuffix, true)) + if (base::EndsWith(title, kDeletedSuffix, base::CompareCase::SENSITIVE)) title.resize(title.size() - kDeletedSuffix.size()); // PR_SET_NAME is available in Linux 2.6.9 and newer. diff --git a/dbus/string_util.cc b/dbus/string_util.cc index 0b07786..16e483a 100644 --- a/dbus/string_util.cc +++ b/dbus/string_util.cc @@ -8,13 +8,10 @@ namespace dbus { +// This implementation is based upon D-Bus Specification Version 0.19. bool IsValidObjectPath(const std::string& value) { - // This implementation is based upon D-Bus Specification Version 0.19. - - const bool kCaseSensitive = true; - // A valid object path begins with '/'. - if (!base::StartsWithASCII(value, "/", kCaseSensitive)) + if (!base::StartsWith(value, "/", base::CompareCase::SENSITIVE)) return false; // Elements are pieces delimited by '/'. For instance, "org", "chromium", @@ -39,7 +36,8 @@ bool IsValidObjectPath(const std::string& value) { } // A trailing '/' character is not allowed unless the path is the root path. - if (value.size() > 1 && base::EndsWith(value, "/", kCaseSensitive)) + if (value.size() > 1 && + base::EndsWith(value, "/", base::CompareCase::SENSITIVE)) return false; return true; diff --git a/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc b/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc index 615090a..430a05c 100644 --- a/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc +++ b/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc @@ -330,7 +330,7 @@ class HeaderMatcher { const std::string data_; const MatchType type_; - const bool case_sensitive_; + const base::CompareCase case_sensitive_; DISALLOW_COPY_AND_ASSIGN(StringMatchTest); }; @@ -422,14 +422,14 @@ bool HeaderMatcher::StringMatchTest::Matches( const std::string& str) const { switch (type_) { case kPrefix: - return base::StartsWithASCII(str, data_, case_sensitive_); + return base::StartsWith(str, data_, case_sensitive_); case kSuffix: return base::EndsWith(str, data_, case_sensitive_); case kEquals: return str.size() == data_.size() && - base::StartsWithASCII(str, data_, case_sensitive_); + base::StartsWith(str, data_, case_sensitive_); case kContains: - if (!case_sensitive_) { + if (case_sensitive_ == base::CompareCase::INSENSITIVE_ASCII) { return std::search(str.begin(), str.end(), data_.begin(), data_.end(), CaseInsensitiveCompareASCII<char>()) != str.end(); } else { @@ -446,7 +446,8 @@ HeaderMatcher::StringMatchTest::StringMatchTest(const std::string& data, bool case_sensitive) : data_(data), type_(type), - case_sensitive_(case_sensitive) {} + case_sensitive_(case_sensitive ? base::CompareCase::SENSITIVE + : base::CompareCase::INSENSITIVE_ASCII) {} // HeaderMatcher::HeaderMatchTest implementation. diff --git a/extensions/browser/api/web_request/web_request_permissions.cc b/extensions/browser/api/web_request/web_request_permissions.cc index 2f57d63..fd73304 100644 --- a/extensions/browser/api/web_request/web_request_permissions.cc +++ b/extensions/browser/api/web_request/web_request_permissions.cc @@ -30,12 +30,12 @@ bool IsSensitiveURL(const GURL& url) { const std::string host = url.host(); const char kGoogleCom[] = ".google.com"; const char kClient[] = "clients"; - if (base::EndsWith(host, kGoogleCom, true)) { + if (base::EndsWith(host, kGoogleCom, base::CompareCase::SENSITIVE)) { // Check for "clients[0-9]*.google.com" hosts. // This protects requests to several internal services such as sync, // extension update pings, captive portal detection, fraudulent certificate // reporting, autofill and others. - if (base::StartsWithASCII(host, kClient, true)) { + if (base::StartsWith(host, kClient, base::CompareCase::SENSITIVE)) { bool match = true; for (std::string::const_iterator i = host.begin() + strlen(kClient), end = host.end() - strlen(kGoogleCom); i != end; ++i) { @@ -50,10 +50,12 @@ bool IsSensitiveURL(const GURL& url) { // others. sensitive_chrome_url = sensitive_chrome_url || - base::EndsWith(url.host(), ".clients.google.com", true) || + base::EndsWith(url.host(), ".clients.google.com", + base::CompareCase::SENSITIVE) || url.host() == "sb-ssl.google.com" || (url.host() == "chrome.google.com" && - base::StartsWithASCII(url.path(), "/webstore", true)); + base::StartsWith(url.path(), "/webstore", + base::CompareCase::SENSITIVE)); } GURL::Replacements replacements; replacements.ClearQuery(); diff --git a/extensions/common/user_script.cc b/extensions/common/user_script.cc index b3d82bb..6b64741 100644 --- a/extensions/common/user_script.cc +++ b/extensions/common/user_script.cc @@ -52,7 +52,8 @@ int UserScript::GenerateUserScriptID() { bool UserScript::IsURLUserScript(const GURL& url, const std::string& mime_type) { - return base::EndsWith(url.ExtractFileName(), kFileExtension, false) && + return base::EndsWith(url.ExtractFileName(), kFileExtension, + base::CompareCase::INSENSITIVE_ASCII) && mime_type != "text/html"; } diff --git a/extensions/utility/unpacker_unittest.cc b/extensions/utility/unpacker_unittest.cc index bb99aae..82e5a1f7 100644 --- a/extensions/utility/unpacker_unittest.cc +++ b/extensions/utility/unpacker_unittest.cc @@ -171,7 +171,8 @@ TEST_F(UnpackerTest, BadPathError) { EXPECT_FALSE(unpacker_->Run()); EXPECT_TRUE(base::StartsWith(unpacker_->error_message(), - ASCIIToUTF16(kExpected), false)) + ASCIIToUTF16(kExpected), + base::CompareCase::INSENSITIVE_ASCII)) << "Expected prefix: \"" << kExpected << "\", actual error: \"" << unpacker_->error_message() << "\""; } @@ -181,7 +182,8 @@ TEST_F(UnpackerTest, ImageDecodingError) { SetupUnpacker("bad_image.crx"); EXPECT_FALSE(unpacker_->Run()); EXPECT_TRUE(base::StartsWith(unpacker_->error_message(), - ASCIIToUTF16(kExpected), false)) + ASCIIToUTF16(kExpected), + base::CompareCase::INSENSITIVE_ASCII)) << "Expected prefix: \"" << kExpected << "\", actual error: \"" << unpacker_->error_message() << "\""; } diff --git a/google_apis/drive/test_util.cc b/google_apis/drive/test_util.cc index 6a22ca0..f74c794 100644 --- a/google_apis/drive/test_util.cc +++ b/google_apis/drive/test_util.cc @@ -97,7 +97,7 @@ scoped_ptr<net::test_server::BasicHttpResponse> CreateHttpResponseFromFile( std::string content_type = "text/plain"; if (base::EndsWith(file_path.AsUTF8Unsafe(), ".json", - true /* case sensitive */)) + base::CompareCase::SENSITIVE)) content_type = "application/json"; scoped_ptr<net::test_server::BasicHttpResponse> http_response( diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index b1167b6..4fe76db 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -841,7 +841,8 @@ void Program::GetCorrectedUniformData( found = uniform->findInfoByMappedName(name, &info, original_name); if (found) { const std::string kArraySpec("[0]"); - if (info->arraySize > 0 && !base::EndsWith(name, kArraySpec, true)) { + if (info->arraySize > 0 && + !base::EndsWith(name, kArraySpec, base::CompareCase::SENSITIVE)) { *corrected_name = name + kArraySpec; *original_name += kArraySpec; } else { diff --git a/ios/web/webui/web_ui_ios_data_source_impl.cc b/ios/web/webui/web_ui_ios_data_source_impl.cc index ee0ed42..e20b660 100644 --- a/ios/web/webui/web_ui_ios_data_source_impl.cc +++ b/ios/web/webui/web_ui_ios_data_source_impl.cc @@ -109,19 +109,19 @@ std::string WebUIIOSDataSourceImpl::GetSource() const { } std::string WebUIIOSDataSourceImpl::GetMimeType(const std::string& path) const { - if (base::EndsWith(path, ".js", false)) + if (base::EndsWith(path, ".js", base::CompareCase::INSENSITIVE_ASCII)) return "application/javascript"; - if (base::EndsWith(path, ".json", false)) + if (base::EndsWith(path, ".json", base::CompareCase::INSENSITIVE_ASCII)) return "application/json"; - if (base::EndsWith(path, ".pdf", false)) + if (base::EndsWith(path, ".pdf", base::CompareCase::INSENSITIVE_ASCII)) return "application/pdf"; - if (base::EndsWith(path, ".css", false)) + if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII)) return "text/css"; - if (base::EndsWith(path, ".svg", false)) + if (base::EndsWith(path, ".svg", base::CompareCase::INSENSITIVE_ASCII)) return "image/svg+xml"; return "text/html"; diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc index f974241..7cf841a 100644 --- a/media/filters/chunk_demuxer_unittest.cc +++ b/media/filters/chunk_demuxer_unittest.cc @@ -449,7 +449,7 @@ class ChunkDemuxerTest : public ::testing::Test { block_info.flags = 0; block_info.duration = 0; - if (base::EndsWith(timestamp_str, "K", true)) { + if (base::EndsWith(timestamp_str, "K", base::CompareCase::SENSITIVE)) { block_info.flags = kWebMFlagKeyframe; // Remove the "K" off of the token. timestamp_str = timestamp_str.substr(0, timestamps[i].length() - 1); @@ -1082,7 +1082,7 @@ class ChunkDemuxerTest : public ::testing::Test { ss << "K"; // Handle preroll buffers. - if (base::EndsWith(timestamps[i], "P", true)) { + if (base::EndsWith(timestamps[i], "P", base::CompareCase::SENSITIVE)) { ASSERT_EQ(kInfiniteDuration(), buffer->discard_padding().first); ASSERT_EQ(base::TimeDelta(), buffer->discard_padding().second); ss << "P"; diff --git a/media/filters/frame_processor_unittest.cc b/media/filters/frame_processor_unittest.cc index cf54bd2..38539c1 100644 --- a/media/filters/frame_processor_unittest.cc +++ b/media/filters/frame_processor_unittest.cc @@ -104,7 +104,7 @@ class FrameProcessorTest : public testing::TestWithParam<bool> { BufferQueue buffers; for (size_t i = 0; i < timestamps.size(); i++) { bool is_keyframe = false; - if (base::EndsWith(timestamps[i], "K", true)) { + if (base::EndsWith(timestamps[i], "K", base::CompareCase::SENSITIVE)) { is_keyframe = true; // Remove the "K" off of the token. timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); diff --git a/media/filters/source_buffer_stream_unittest.cc b/media/filters/source_buffer_stream_unittest.cc index b0e9316..2fdcce2 100644 --- a/media/filters/source_buffer_stream_unittest.cc +++ b/media/filters/source_buffer_stream_unittest.cc @@ -306,7 +306,7 @@ class SourceBufferStreamTest : public testing::Test { } // Handle preroll buffers. - if (base::EndsWith(timestamps[i], "P", true)) { + if (base::EndsWith(timestamps[i], "P", base::CompareCase::SENSITIVE)) { ASSERT_TRUE(buffer->is_key_frame()); scoped_refptr<StreamParserBuffer> preroll_buffer; preroll_buffer.swap(buffer); @@ -500,40 +500,42 @@ class SourceBufferStreamTest : public testing::Test { bool is_duration_estimated = false; // Handle splice frame starts. - if (base::StartsWithASCII(timestamps[i], "S(", true)) { + if (base::StartsWith(timestamps[i], "S(", base::CompareCase::SENSITIVE)) { CHECK(!splice_frame); splice_frame = true; // Remove the "S(" off of the token. timestamps[i] = timestamps[i].substr(2, timestamps[i].length()); } - if (splice_frame && base::EndsWith(timestamps[i], ")", true)) { + if (splice_frame && + base::EndsWith(timestamps[i], ")", base::CompareCase::SENSITIVE)) { splice_frame = false; last_splice_frame = true; // Remove the ")" off of the token. timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); } // Handle config changes within the splice frame. - if (splice_frame && base::EndsWith(timestamps[i], "C", true)) { + if (splice_frame && + base::EndsWith(timestamps[i], "C", base::CompareCase::SENSITIVE)) { splice_config_id++; CHECK(splice_config_id < stream_->audio_configs_.size() || splice_config_id < stream_->video_configs_.size()); // Remove the "C" off of the token. timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); } - if (base::EndsWith(timestamps[i], "K", true)) { + if (base::EndsWith(timestamps[i], "K", base::CompareCase::SENSITIVE)) { is_keyframe = true; // Remove the "K" off of the token. timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); } // Handle preroll buffers. - if (base::EndsWith(timestamps[i], "P", true)) { + if (base::EndsWith(timestamps[i], "P", base::CompareCase::SENSITIVE)) { is_keyframe = true; has_preroll = true; // Remove the "P" off of the token. timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); } - if (base::EndsWith(timestamps[i], "E", true)) { + if (base::EndsWith(timestamps[i], "E", base::CompareCase::SENSITIVE)) { is_duration_estimated = true; // Remove the "E" off of the token. timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); diff --git a/media/video/capture/mac/video_capture_device_factory_mac.mm b/media/video/capture/mac/video_capture_device_factory_mac.mm index 1fbf8ef..443b7f3 100644 --- a/media/video/capture/mac/video_capture_device_factory_mac.mm +++ b/media/video/capture/mac/video_capture_device_factory_mac.mm @@ -35,8 +35,10 @@ static bool IsDeviceBlacklisted(const VideoCaptureDevice::Name& name) { bool is_device_blacklisted = false; for(size_t i = 0; !is_device_blacklisted && i < arraysize(kBlacklistedCameras); ++i) { - is_device_blacklisted = base::EndsWith(name.id(), - kBlacklistedCameras[i].unique_id_signature, false); + is_device_blacklisted = + base::EndsWith(name.id(), + kBlacklistedCameras[i].unique_id_signature, + base::CompareCase::INSENSITIVE_ASCII); } DVLOG_IF(2, is_device_blacklisted) << "Blacklisted camera: " << name.name() << ", id: " << name.id(); @@ -184,7 +186,7 @@ void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { if (base::EndsWith(device.id(), kBlacklistedCameras[i].unique_id_signature, - false)) { + base::CompareCase::INSENSITIVE_ASCII)) { supported_formats->push_back(media::VideoCaptureFormat( gfx::Size(kBlacklistedCameras[i].capture_width, kBlacklistedCameras[i].capture_height), diff --git a/media/video/capture/video_capture_device.cc b/media/video/capture/video_capture_device.cc index e474489..cb03dba 100644 --- a/media/video/capture/video_capture_device.cc +++ b/media/video/capture/video_capture_device.cc @@ -14,7 +14,7 @@ const std::string VideoCaptureDevice::Name::GetNameAndModel() const { if (model_id.empty()) return device_name_; const std::string suffix = " (" + model_id + ")"; - if (base::EndsWith(device_name_, suffix, true /* case sensitive */)) + if (base::EndsWith(device_name_, suffix, base::CompareCase::SENSITIVE)) return device_name_; return device_name_ + suffix; } diff --git a/mojo/runner/shell_apptest.cc b/mojo/runner/shell_apptest.cc index 70f7864..2a943d6 100644 --- a/mojo/runner/shell_apptest.cc +++ b/mojo/runner/shell_apptest.cc @@ -184,7 +184,8 @@ TEST_F(ShellAppTest, MojoURLQueryHandling) { application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable); auto callback = [this](const String& app_url, const String& connection_url, const String& message) { - EXPECT_TRUE(base::EndsWith(app_url, "/pingable_app.mojo", true)); + EXPECT_TRUE(base::EndsWith(app_url, "/pingable_app.mojo", + base::CompareCase::SENSITIVE)); EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); EXPECT_EQ("hello", message); base::MessageLoop::current()->Quit(); diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index 27c547b..9adb2fe 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -524,7 +524,7 @@ void GetExtensionsForMimeType( const std::string mime_type = base::StringToLowerASCII(unsafe_mime_type); base::hash_set<base::FilePath::StringType> unique_extensions; - if (base::EndsWith(mime_type, "/*", false)) { + if (base::EndsWith(mime_type, "/*", base::CompareCase::INSENSITIVE_ASCII)) { std::string leading_mime_type = mime_type.substr(0, mime_type.length() - 1); // Find the matching StandardType from within kStandardTypes, or fall diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 39a8591..e045441 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -155,7 +155,7 @@ std::string NormalizeHostname(const std::string& host) { } bool IsNormalizedLocalhostTLD(const std::string& host) { - return base::EndsWith(host, ".localhost", true); + return base::EndsWith(host, ".localhost", base::CompareCase::SENSITIVE); } // |host| should be normalized. @@ -801,7 +801,7 @@ bool HasGoogleHost(const GURL& url) { }; const std::string& host = url.host(); for (const char* suffix : kGoogleHostSuffixes) { - if (base::EndsWith(host, suffix, false)) + if (base::EndsWith(host, suffix, base::CompareCase::INSENSITIVE_ASCII)) return true; } return false; diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 76e352e..7fe07c6 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -1444,7 +1444,8 @@ void HttpNetworkTransaction::RecordSSLFallbackMetrics(int result) { return; const std::string& host = request_->url.host(); - bool is_google = base::EndsWith(host, "google.com", true) && + bool is_google = base::EndsWith(host, "google.com", + base::CompareCase::SENSITIVE) && (host.size() == 10 || host[host.size() - 11] == '.'); if (is_google) { // Some fraction of successful connections use the fallback, but only due to diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc index 15871b5..d1c259e 100644 --- a/net/http/http_server_properties_impl.cc +++ b/net/http/http_server_properties_impl.cc @@ -117,7 +117,8 @@ void HttpServerPropertiesImpl::InitializeAlternativeServiceServers( for (AlternativeServiceMap::const_iterator it = alternative_service_map_.begin(); it != alternative_service_map_.end(); ++it) { - if (base::EndsWith(it->first.host(), canonical_suffixes_[i], false)) { + if (base::EndsWith(it->first.host(), canonical_suffixes_[i], + base::CompareCase::INSENSITIVE_ASCII)) { canonical_host_to_origin_map_[canonical_host] = it->first; break; } @@ -260,7 +261,8 @@ std::string HttpServerPropertiesImpl::GetCanonicalSuffix( // suffix. for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { std::string canonical_suffix = canonical_suffixes_[i]; - if (base::EndsWith(host, canonical_suffixes_[i], false)) { + if (base::EndsWith(host, canonical_suffixes_[i], + base::CompareCase::INSENSITIVE_ASCII)) { return canonical_suffix; } } @@ -368,7 +370,8 @@ bool HttpServerPropertiesImpl::SetAlternativeServices( // canonical host. for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { std::string canonical_suffix = canonical_suffixes_[i]; - if (base::EndsWith(origin.host(), canonical_suffixes_[i], false)) { + if (base::EndsWith(origin.host(), canonical_suffixes_[i], + base::CompareCase::INSENSITIVE_ASCII)) { HostPortPair canonical_host(canonical_suffix, origin.port()); canonical_host_to_origin_map_[canonical_host] = origin; break; @@ -611,7 +614,8 @@ HttpServerPropertiesImpl::CanonicalHostMap::const_iterator HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const { for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { std::string canonical_suffix = canonical_suffixes_[i]; - if (base::EndsWith(server.host(), canonical_suffixes_[i], false)) { + if (base::EndsWith(server.host(), canonical_suffixes_[i], + base::CompareCase::INSENSITIVE_ASCII)) { HostPortPair canonical_host(canonical_suffix, server.port()); return canonical_host_to_origin_map_.find(canonical_host); } diff --git a/net/quic/crypto/quic_crypto_client_config.cc b/net/quic/crypto/quic_crypto_client_config.cc index a041f4c..f9af055 100644 --- a/net/quic/crypto/quic_crypto_client_config.cc +++ b/net/quic/crypto/quic_crypto_client_config.cc @@ -904,7 +904,8 @@ bool QuicCryptoClientConfig::PopulateFromCanonicalConfig( DCHECK(server_state->IsEmpty()); size_t i = 0; for (; i < canonical_suffixes_.size(); ++i) { - if (base::EndsWith(server_id.host(), canonical_suffixes_[i], false)) { + if (base::EndsWith(server_id.host(), canonical_suffixes_[i], + base::CompareCase::INSENSITIVE_ASCII)) { break; } } diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 1252c6a..e611042 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -2978,7 +2978,8 @@ void SpdySession::RecordProtocolErrorHistogram( SpdyProtocolErrorDetails details) { UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionErrorDetails2", details, NUM_SPDY_PROTOCOL_ERROR_DETAILS); - if (base::EndsWith(host_port_pair().host(), "google.com", false)) { + if (base::EndsWith(host_port_pair().host(), "google.com", + base::CompareCase::INSENSITIVE_ASCII)) { UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionErrorDetails_Google2", details, NUM_SPDY_PROTOCOL_ERROR_DETAILS); } diff --git a/net/spdy/spdy_session_test_util.cc b/net/spdy/spdy_session_test_util.cc index e817ce1..36e4c57 100644 --- a/net/spdy/spdy_session_test_util.cc +++ b/net/spdy/spdy_session_test_util.cc @@ -28,9 +28,10 @@ void SpdySessionTestTaskObserver::WillProcessTask( void SpdySessionTestTaskObserver::DidProcessTask( const base::PendingTask& pending_task) { - if (base::EndsWith(pending_task.posted_from.file_name(), file_name_, true) && + if (base::EndsWith(pending_task.posted_from.file_name(), file_name_, + base::CompareCase::SENSITIVE) && base::EndsWith(pending_task.posted_from.function_name(), function_name_, - true)) { + base::CompareCase::SENSITIVE)) { ++executed_count_; } } diff --git a/net/tools/flip_server/mem_cache.cc b/net/tools/flip_server/mem_cache.cc index b280b98..485c91e 100644 --- a/net/tools/flip_server/mem_cache.cc +++ b/net/tools/flip_server/mem_cache.cc @@ -204,7 +204,7 @@ void MemoryCache::ReadAndStoreFileContents(const char* filename) { FileData* MemoryCache::GetFileData(const std::string& filename) { Files::iterator fi = files_.end(); - if (base::EndsWith(filename, ".html", true)) { + if (base::EndsWith(filename, ".html", base::CompareCase::SENSITIVE)) { fi = files_.find(filename.substr(0, filename.size() - 5) + ".http"); } if (fi == files_.end()) diff --git a/net/websockets/websocket_stream_cookie_test.cc b/net/websockets/websocket_stream_cookie_test.cc index 8e4d9c4..d1f41a7 100644 --- a/net/websockets/websocket_stream_cookie_test.cc +++ b/net/websockets/websocket_stream_cookie_test.cc @@ -35,7 +35,8 @@ class TestBase : public WebSocketStreamCreateTestBase { // We assume cookie_header ends with CRLF if not empty, as // WebSocketStandardRequestWithCookies requires. Use AddCRLFIfNotEmpty // in a call site. - CHECK(cookie_header.empty() || base::EndsWith(cookie_header, "\r\n", true)); + CHECK(cookie_header.empty() || + base::EndsWith(cookie_header, "\r\n", base::CompareCase::SENSITIVE)); url_request_context_host_.SetExpectations( WebSocketStandardRequestWithCookies(url.path(), url.host(), origin, diff --git a/pdf/document_loader.cc b/pdf/document_loader.cc index f696656..28a6ee4 100644 --- a/pdf/document_loader.cc +++ b/pdf/document_loader.cc @@ -68,12 +68,15 @@ std::string GetMultiPartBoundary(const std::string& headers) { } bool IsValidContentType(const std::string& type) { - return (base::EndsWith(type, "/pdf", false) || - base::EndsWith(type, ".pdf", false) || - base::EndsWith(type, "/x-pdf", false) || - base::EndsWith(type, "/*", false) || - base::EndsWith(type, "/acrobat", false) || - base::EndsWith(type, "/unknown", false)); + return (base::EndsWith(type, "/pdf", base::CompareCase::INSENSITIVE_ASCII) || + base::EndsWith(type, ".pdf", base::CompareCase::INSENSITIVE_ASCII) || + base::EndsWith(type, "/x-pdf", + base::CompareCase::INSENSITIVE_ASCII) || + base::EndsWith(type, "/*", base::CompareCase::INSENSITIVE_ASCII) || + base::EndsWith(type, "/acrobat", + base::CompareCase::INSENSITIVE_ASCII) || + base::EndsWith(type, "/unknown", + base::CompareCase::INSENSITIVE_ASCII)); } } // namespace diff --git a/remoting/host/it2me/it2me_host.cc b/remoting/host/it2me/it2me_host.cc index 49cca62..fe9e8c6 100644 --- a/remoting/host/it2me/it2me_host.cc +++ b/remoting/host/it2me/it2me_host.cc @@ -197,7 +197,8 @@ void It2MeHost::FinishConnect() { // Check the host domain policy. if (!required_host_domain_.empty() && !base::EndsWith(xmpp_server_config_.username, - std::string("@") + required_host_domain_, false)) { + std::string("@") + required_host_domain_, + base::CompareCase::INSENSITIVE_ASCII)) { SetState(kInvalidDomainError, ""); return; } diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 7174184..0970feb 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -1096,7 +1096,8 @@ void HostProcess::ApplyHostDomainPolicy() { ShutdownHost(kInvalidHostDomainExitCode); } - if (!base::EndsWith(host_owner_, std::string("@") + host_domain_, false)) { + if (!base::EndsWith(host_owner_, std::string("@") + host_domain_, + base::CompareCase::INSENSITIVE_ASCII)) { LOG(ERROR) << "The host domain does not match the policy."; ShutdownHost(kInvalidHostDomainExitCode); } diff --git a/third_party/zlib/google/zip_reader.cc b/third_party/zlib/google/zip_reader.cc index d3c2775..e0871c8 100644 --- a/third_party/zlib/google/zip_reader.cc +++ b/third_party/zlib/google/zip_reader.cc @@ -131,7 +131,8 @@ ZipReader::EntryInfo::EntryInfo(const std::string& file_name_in_zip, original_size_ = raw_file_info.uncompressed_size; // Directory entries in zip files end with "/". - is_directory_ = base::EndsWith(file_name_in_zip, "/", false); + is_directory_ = base::EndsWith(file_name_in_zip, "/", + base::CompareCase::INSENSITIVE_ASCII); // Check the file name here for directory traversal issues. is_unsafe_ = file_path_.ReferencesParent(); diff --git a/tools/gn/ninja_binary_target_writer.cc b/tools/gn/ninja_binary_target_writer.cc index 1fc06b2..971f4d8 100644 --- a/tools/gn/ninja_binary_target_writer.cc +++ b/tools/gn/ninja_binary_target_writer.cc @@ -650,7 +650,8 @@ void NinjaBinaryTargetWriter::WriteLibs() { const std::string framework_ending(".framework"); for (size_t i = 0; i < all_libs.size(); i++) { if (settings_->IsMac() && - base::EndsWith(all_libs[i], framework_ending, false)) { + base::EndsWith(all_libs[i], framework_ending, + base::CompareCase::INSENSITIVE_ASCII)) { // Special-case libraries ending in ".framework" on Mac. Add the // -framework switch and don't add the extension to the output. out_ << " -framework "; diff --git a/tools/gn/ninja_target_writer.cc b/tools/gn/ninja_target_writer.cc index e03b2d2..7913735 100644 --- a/tools/gn/ninja_target_writer.cc +++ b/tools/gn/ninja_target_writer.cc @@ -242,7 +242,8 @@ void NinjaTargetWriter::WriteStampForTarget( // First validate that the target's dependency is a stamp file. Otherwise, // we shouldn't have gotten here! - CHECK(base::EndsWith(stamp_file.value(), ".stamp", false)) + CHECK(base::EndsWith(stamp_file.value(), ".stamp", + base::CompareCase::INSENSITIVE_ASCII)) << "Output should end in \".stamp\" for stamp file output. Instead got: " << "\"" << stamp_file.value() << "\""; diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc index de0e620..010dbde 100644 --- a/ui/base/l10n/l10n_util.cc +++ b/ui/base/l10n/l10n_util.cc @@ -201,8 +201,9 @@ bool IsDuplicateName(const std::string& locale_name) { }; // Skip all the es_Foo other than es_419 for now. - if (base::StartsWithASCII(locale_name, "es_", false)) - return !base::EndsWith(locale_name, "419", true); + if (base::StartsWith(locale_name, "es_", + base::CompareCase::INSENSITIVE_ASCII)) + return !base::EndsWith(locale_name, "419", base::CompareCase::SENSITIVE); for (size_t i = 0; i < arraysize(kDuplicateNames); ++i) { if (base::EqualsCaseInsensitiveASCII(kDuplicateNames[i], locale_name)) diff --git a/ui/gfx/font_list.cc b/ui/gfx/font_list.cc index d0df023..7bdf903 100644 --- a/ui/gfx/font_list.cc +++ b/ui/gfx/font_list.cc @@ -50,7 +50,7 @@ bool FontList::ParseDescription(const std::string& description, // The size takes the form "<INT>px". std::string size_string = styles.back(); styles.pop_back(); - if (!base::EndsWith(size_string, "px", true /* case_sensitive */)) + if (!base::EndsWith(size_string, "px", base::CompareCase::SENSITIVE)) return false; size_string.resize(size_string.size() - 2); if (!base::StringToInt(size_string, size_pixels_out) || @@ -100,7 +100,7 @@ void FontList::SetDefaultFontDescription(const std::string& font_description) { // The description string must end with "px" for size in pixel, or must be // the empty string, which specifies to use a single default font. DCHECK(font_description.empty() || - base::EndsWith(font_description, "px", true)); + base::EndsWith(font_description, "px", base::CompareCase::SENSITIVE)); g_default_font_description.Get() = font_description; g_default_impl_initialized = false; diff --git a/ui/gfx/font_list_impl.cc b/ui/gfx/font_list_impl.cc index 907f4ef..3eb55be 100644 --- a/ui/gfx/font_list_impl.cc +++ b/ui/gfx/font_list_impl.cc @@ -44,7 +44,8 @@ FontListImpl::FontListImpl(const std::string& font_description_string) font_size_(-1) { DCHECK(!font_description_string.empty()); // DCHECK description string ends with "px" for size in pixel. - DCHECK(base::EndsWith(font_description_string, "px", true)); + DCHECK(base::EndsWith(font_description_string, "px", + base::CompareCase::SENSITIVE)); } FontListImpl::FontListImpl(const std::vector<std::string>& font_names, |