diff options
88 files changed, 225 insertions, 326 deletions
diff --git a/base/android/library_loader/library_prefetcher.cc b/base/android/library_loader/library_prefetcher.cc index 9b54843..798a283 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], CompareCase::SENSITIVE)) { + if (EndsWith(path, kSuffixesToMatch[i], true)) { 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, CompareCase::SENSITIVE)) { + if (EndsWith(region.path, kLibchromeSuffix, true)) { has_libchrome_region = true; break; } } for (const base::debug::MappedMemoryRegion& region : regions) { if (has_libchrome_region && - !EndsWith(region.path, kLibchromeSuffix, CompareCase::SENSITIVE)) { + !EndsWith(region.path, kLibchromeSuffix, true)) { 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 755215c..d7a08c8 100644 --- a/base/strings/string_util.h +++ b/base/strings/string_util.h @@ -381,6 +381,19 @@ 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 eb6cd7e..5d5ba8b 100644 --- a/base/strings/string_util_unittest.cc +++ b/base/strings/string_util_unittest.cc @@ -706,83 +706,59 @@ TEST(StringUtilTest, JoinString16) { } TEST(StringUtilTest, StartsWith) { - 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(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(ASCIIToUTF16("javascript:url"), - ASCIIToUTF16("javascript"), - base::CompareCase::SENSITIVE)); + ASCIIToUTF16("javascript"), true)); EXPECT_FALSE(StartsWith(ASCIIToUTF16("JavaScript:url"), - ASCIIToUTF16("javascript"), - base::CompareCase::SENSITIVE)); + ASCIIToUTF16("javascript"), true)); EXPECT_TRUE(StartsWith(ASCIIToUTF16("javascript:url"), - ASCIIToUTF16("javascript"), - base::CompareCase::INSENSITIVE_ASCII)); + ASCIIToUTF16("javascript"), false)); EXPECT_TRUE(StartsWith(ASCIIToUTF16("JavaScript:url"), - 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)); + 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)); } TEST(StringUtilTest, EndsWith) { - 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)); + 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)); } TEST(StringUtilTest, GetStringFWithOffsets) { diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index 2910466..e281cff 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", CompareCase::INSENSITIVE_ASCII)) + if (EndsWith(default_locale, "POSIX", false)) 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 52384d4..6afac88 100644 --- a/chrome/app/delay_load_hook_win.cc +++ b/chrome/app/delay_load_hook_win.cc @@ -28,8 +28,7 @@ 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, - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(dll_name, kDelaySuffix, false)) { // 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 c61385b..d926ed3 100644 --- a/chrome/browser/banners/app_banner_data_fetcher.cc +++ b/chrome/browser/banners/app_banner_data_fetcher.cc @@ -40,8 +40,7 @@ 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, - base::CompareCase::INSENSITIVE_ASCII))) + base::EndsWith(icon.src.ExtractFileName(), kPngExtension, false))) 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 bc79830..d8dec49 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc @@ -919,8 +919,7 @@ 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, - base::CompareCase::SENSITIVE)) + if (!base::EndsWith(file_name, wallpaper::kSmallWallpaperSuffix, true)) 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 2657377..3e85b3c 100644 --- a/chrome/browser/chromeos/policy/device_local_account.cc +++ b/chrome/browser/chromeos/policy/device_local_account.cc @@ -68,8 +68,7 @@ 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, - base::CompareCase::SENSITIVE)) + if (!base::EndsWith(domain, kDeviceLocalAccountDomainSuffix, true)) 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 aa19c25..ab40b35 100644 --- a/chrome/browser/component_updater/cld_component_installer_unittest.cc +++ b/chrome/browser/component_updater/cld_component_installer_unittest.cc @@ -102,8 +102,7 @@ TEST_F(CldComponentInstallerTest, GetInstalledPath) { const base::FilePath base_dir; const base::FilePath result = CldComponentInstallerTraits::GetInstalledPath(base_dir); - ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, - base::CompareCase::SENSITIVE)); + ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, true)); } TEST_F(CldComponentInstallerTest, GetBaseDirectory) { @@ -128,10 +127,8 @@ 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(), - base::CompareCase::SENSITIVE)); - ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, - base::CompareCase::SENSITIVE)); + install_dir.AsUTF16Unsafe(), true)); + ASSERT_TRUE(base::EndsWith(result.value(), kTestCldDataFileName, true)); } } // 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 0f58e84..169f8da 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc @@ -223,8 +223,7 @@ class DelayLoadStartAndExecuteJavascript const GURL& url, ui::PageTransition transition_type) override { if (script_was_executed_ && - base::EndsWith(url.spec(), until_url_suffix_, - base::CompareCase::SENSITIVE)) { + base::EndsWith(url.spec(), until_url_suffix_, true)) { 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 2cc3228..c8078e4 100644 --- a/chrome/browser/extensions/default_apps.cc +++ b/chrome/browser/extensions/default_apps.cc @@ -37,8 +37,7 @@ 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], - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(locale, unsupported_locales[i], false)) { return false; } } diff --git a/chrome/browser/extensions/updater/local_extension_cache.cc b/chrome/browser/extensions/updater/local_extension_cache.cc index 14273a8..677b3e8 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, - base::CompareCase::INSENSITIVE_ASCII)) { + false /* case-sensitive */)) { 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 7c65d0b..8360369 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, base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(domain, kEduDomain, false /* case insensitive */)) 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 6de119ea..02469dd 100644 --- a/chrome/browser/net/pref_proxy_config_tracker_impl.cc +++ b/chrome/browser/net/pref_proxy_config_tracker_impl.cc @@ -27,8 +27,7 @@ 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", - base::CompareCase::SENSITIVE); + base::EndsWith(proxy.host_port_pair().host(), ".googlezip.net", true); } // 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 b8471ea..cb74b99 100644 --- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc @@ -45,8 +45,7 @@ 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, - base::CompareCase::SENSITIVE)) { + kDataReductionProxyDefaultHostSuffix, true)) { return true; } } diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc index 5a7929e..09e4643 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database.cc @@ -1792,8 +1792,7 @@ 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, - base::CompareCase::SENSITIVE)) { + if (base::EndsWith(filename, kPrefixSetFileSuffix, true)) { 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 @@ -1806,28 +1805,21 @@ 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, base::CompareCase::SENSITIVE)) + if (base::EndsWith(filename, kBrowseDBFile, true)) histogram_name.append(".Browse"); - else if (base::EndsWith(filename, kDownloadDBFile, - base::CompareCase::SENSITIVE)) + else if (base::EndsWith(filename, kDownloadDBFile, true)) histogram_name.append(".Download"); - else if (base::EndsWith(filename, kCsdWhitelistDBFile, - base::CompareCase::SENSITIVE)) + else if (base::EndsWith(filename, kCsdWhitelistDBFile, true)) histogram_name.append(".CsdWhitelist"); - else if (base::EndsWith(filename, kDownloadWhitelistDBFile, - base::CompareCase::SENSITIVE)) + else if (base::EndsWith(filename, kDownloadWhitelistDBFile, true)) histogram_name.append(".DownloadWhitelist"); - else if (base::EndsWith(filename, kInclusionWhitelistDBFile, - base::CompareCase::SENSITIVE)) + else if (base::EndsWith(filename, kInclusionWhitelistDBFile, true)) histogram_name.append(".InclusionWhitelist"); - else if (base::EndsWith(filename, kExtensionBlacklistDBFile, - base::CompareCase::SENSITIVE)) + else if (base::EndsWith(filename, kExtensionBlacklistDBFile, true)) histogram_name.append(".ExtensionBlacklist"); - else if (base::EndsWith(filename, kIPBlacklistDBFile, - base::CompareCase::SENSITIVE)) + else if (base::EndsWith(filename, kIPBlacklistDBFile, true)) histogram_name.append(".IPBlacklist"); - else if (base::EndsWith(filename, kUnwantedSoftwareDBFile, - base::CompareCase::SENSITIVE)) + else if (base::EndsWith(filename, kUnwantedSoftwareDBFile, true)) 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 55282b8..c611501 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", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".js", false)) return "application/javascript"; - if (base::EndsWith(path, ".png", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".png", false)) return "image/png"; - if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".css", false)) return "text/css"; - if (base::EndsWith(path, ".html", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".html", false)) 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 59e4ac8..2e60864 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, "/", base::CompareCase::SENSITIVE)) + if (base::EndsWith(path, "/", true)) 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 667fc25..b1dad56 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, ".*", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(pattern, ".*", true)) { size_t registry_length = GetRegistryLength( trimmed_host, EXCLUDE_UNKNOWN_REGISTRIES, EXCLUDE_PRIVATE_REGISTRIES); // A host without a known registry part does not match. @@ -258,8 +258,7 @@ bool SupervisedUserURLFilter::HostMatchesPattern(const std::string& host, // pattern. if (trimmed_pattern.empty() || trimmed_pattern.find('*') != std::string::npos || - !base::EndsWith(trimmed_host, trimmed_pattern, - base::CompareCase::SENSITIVE)) { + !base::EndsWith(trimmed_host, trimmed_pattern, true)) { return false; } diff --git a/chrome/browser/sync/test/integration/bookmarks_helper.cc b/chrome/browser/sync/test/integration/bookmarks_helper.cc index 08a863e..ebae3b2 100644 --- a/chrome/browser/sync/test/integration/bookmarks_helper.cc +++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc @@ -964,8 +964,7 @@ gfx::Image CreateFavicon(SkColor color) { gfx::Image Create1xFaviconFromPNGFile(const std::string& path) { const char* kPNGExtension = ".png"; - if (!base::EndsWith(path, kPNGExtension, - base::CompareCase::INSENSITIVE_ASCII)) + if (!base::EndsWith(path, kPNGExtension, false)) 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 e087266..7bd7b96 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), - base::CompareCase::SENSITIVE)); + true)); EXPECT_TRUE(base::EndsWith(form_structure()->field(0)->value, shipping_profile.GetRawInfo(ADDRESS_HOME_LINE2), - base::CompareCase::SENSITIVE)); + true)); EXPECT_TRUE(base::StartsWith(form_structure()->field(1)->value, billing_profile.GetRawInfo(ADDRESS_HOME_LINE1), - base::CompareCase::SENSITIVE)); + true)); EXPECT_TRUE(base::EndsWith(form_structure()->field(1)->value, billing_profile.GetRawInfo(ADDRESS_HOME_LINE2), - base::CompareCase::SENSITIVE)); + true)); // 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 0fa91ec..840de46 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm @@ -563,10 +563,8 @@ NSAttributedString* CreateClassifiedAttributedString( match.GetAdditionalInfo(kACMatchPropertyContentsStartIndex), &contentsStartIndex); // Ignore invalid state. - if (!base::StartsWith(match.fill_into_edit, inputText, - base::CompareCase::SENSITIVE) || - !base::EndsWith(match.fill_into_edit, match.contents, - base::CompareCase::SENSITIVE) || + if (!base::StartsWith(match.fill_into_edit, inputText, true) || + !base::EndsWith(match.fill_into_edit, match.contents, true) || ((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 0797df7..cfd6955 100644 --- a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc +++ b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc @@ -34,8 +34,7 @@ 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, - base::CompareCase::INSENSITIVE_ASCII); + return base::EndsWith(file_info->filename, *file_extension, false); } // 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 c02b0ae..4ea7fe5 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), - base::CompareCase::INSENSITIVE_ASCII)); + false)); 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 68ccc01..7960c0f 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -49,25 +49,19 @@ const char kFallbackFrontendURL[] = std::string GetMimeTypeForPath(const std::string& path) { std::string filename = PathWithoutParams(path); - if (base::EndsWith(filename, ".html", base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(filename, ".html", false)) { return "text/html"; - } else if (base::EndsWith(filename, ".css", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".css", false)) { return "text/css"; - } else if (base::EndsWith(filename, ".js", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".js", false)) { return "application/javascript"; - } else if (base::EndsWith(filename, ".png", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".png", false)) { return "image/png"; - } else if (base::EndsWith(filename, ".gif", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".gif", false)) { return "image/gif"; - } else if (base::EndsWith(filename, ".svg", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".svg", false)) { return "image/svg+xml"; - } else if (base::EndsWith(filename, ".manifest", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".manifest", false)) { 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 6cd974b..352eba5 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", base::CompareCase::SENSITIVE)) + if (!base::EndsWith(path, "/print.pdf", true)) return false; // Print Preview data. diff --git a/chrome/browser/ui/webui/profiler_ui.cc b/chrome/browser/ui/webui/profiler_ui.cc index 97629121..fda2c09 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", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".js", false)) 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 68b5929..89cad0e 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, - base::CompareCase::SENSITIVE)) { + extension_id, + true /* case_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 bf2320e..7a3c5f3 100644 --- a/chrome/common/extensions/api/networking_private/networking_private_crypto.cc +++ b/chrome/common/extensions/api/networking_private/networking_private_crypto.cc @@ -65,8 +65,7 @@ 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, - base::CompareCase::INSENSITIVE_ASCII)) { + if (!base::EndsWith(common_name, translated_mac, false)) { 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 686db97..737b49a 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, "/", base::CompareCase::SENSITIVE)) + if (base::EndsWith(gallery_prefix, "/", true)) 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 46e120c..2ca5c4c 100644 --- a/chrome/common/importer/firefox_importer_utils.cc +++ b/chrome/common/importer/firefox_importer_utils.cc @@ -116,8 +116,7 @@ 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", - base::CompareCase::SENSITIVE)) { + if (base::EndsWith(path_components[i], ".app", true)) { *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 14af917..3f75249 100644 --- a/chrome/common/service_process_util_unittest.cc +++ b/chrome/common/service_process_util_unittest.cc @@ -63,8 +63,7 @@ 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, - base::CompareCase::SENSITIVE)); + EXPECT_TRUE(base::EndsWith(scoped_name, test_str, true)); 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 349be3a..fb5829c 100644 --- a/chrome/installer/gcapi/gcapi.cc +++ b/chrome/installer/gcapi/gcapi.cc @@ -361,8 +361,7 @@ 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, - base::StartsWith::INSENSITIVE_ASCII) && + base::StartsWith(window_class, kChromeWindowClassPrefix, false) && ::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 209fdad..10b0936 100644 --- a/chrome/installer/setup/setup_util_unittest.cc +++ b/chrome/installer/setup/setup_util_unittest.cc @@ -607,6 +607,5 @@ 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", - base::CompareCase::SENSITIVE)); + EXPECT_TRUE(base::EndsWith(key, app_guid + L"\\Commands\\test_name", true)); } diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 84ae486..655d2f8 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -1105,8 +1105,7 @@ base::string16 ExtractShortcutNameFromProperties( dist->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME); } - if (!base::EndsWith(shortcut_name, installer::kLnkExt, - base::CompareCase::INSENSITIVE_ASCII)) + if (!base::EndsWith(shortcut_name, installer::kLnkExt, false)) 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 ad59ffb..48bc0a0 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -1007,10 +1007,8 @@ 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", - base::CompareCase::INSENSITIVE_ASCII) || - base::EndsWith(app_url_host, "plus.sandbox.google.com", - base::CompareCase::INSENSITIVE_ASCII)) && + (base::EndsWith(app_url_host, "plus.google.com", false) || + base::EndsWith(app_url_host, "plus.sandbox.google.com", false)) && manifest_url.DomainIs("ssl.gstatic.com") && (manifest_url_path.find("s2/oz/nacl/") == 1 || manifest_url_path.find("photos/nacl/") == 1); @@ -1023,12 +1021,9 @@ 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", - 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)) && + (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)) && // 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 e64b5cb..6932447 100644 --- a/cloud_print/service/win/service_utils.cc +++ b/cloud_print/service/win/service_utils.cc @@ -28,8 +28,7 @@ base::string16 GetLocalComputerName() { base::string16 ReplaceLocalHostInName(const base::string16& user_name) { static const wchar_t kLocalDomain[] = L".\\"; - if (base::StartsWith(user_name, kLocalDomain, - base::CompareCase::SENSITIVE)) { + if (base::StartsWith(user_name, kLocalDomain, true)) { 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 40f7edc..0080f68 100644 --- a/components/devtools_http_handler/devtools_http_handler.cc +++ b/components/devtools_http_handler/devtools_http_handler.cc @@ -359,22 +359,17 @@ static std::string PathWithoutParams(const std::string& path) { } static std::string GetMimeType(const std::string& filename) { - if (base::EndsWith(filename, ".html", base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(filename, ".html", false)) { return "text/html"; - } else if (base::EndsWith(filename, ".css", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".css", false)) { return "text/css"; - } else if (base::EndsWith(filename, ".js", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".js", false)) { return "application/javascript"; - } else if (base::EndsWith(filename, ".png", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".png", false)) { return "image/png"; - } else if (base::EndsWith(filename, ".gif", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".gif", false)) { return "image/gif"; - } else if (base::EndsWith(filename, ".json", - base::CompareCase::INSENSITIVE_ASCII)) { + } else if (base::EndsWith(filename, ".json", false)) { 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 1eada34..5326502 100644 --- a/components/google/core/browser/google_util.cc +++ b/components/google/core/browser/google_util.cc @@ -57,8 +57,7 @@ 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, - base::CompareCase::INSENSITIVE_ASCII); + return base::EndsWith(host_minus_tld, "." + domain_in_lower_case, false); 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 8992f02..b6f7877 100644 --- a/components/omnibox/browser/keyword_provider.cc +++ b/components/omnibox/browser/keyword_provider.cc @@ -139,8 +139,7 @@ const TemplateURL* KeywordProvider::GetSubstitutingTemplateURLForInput( // of the original input. if (input->cursor_position() != base::string16::npos && !remaining_input.empty() && - base::EndsWith(input->text(), remaining_input, - base::CompareCase::SENSITIVE)) { + base::EndsWith(input->text(), remaining_input, true)) { 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 30543fc..11fbdbb 100644 --- a/components/omnibox/browser/search_suggestion_parser.cc +++ b/components/omnibox/browser/search_suggestion_parser.cc @@ -151,8 +151,7 @@ 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_, - base::CompareCase::SENSITIVE) && + base::EndsWith(suggestion_, match_contents_, true) && (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 3d8cb6a..b843354 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), - base::CompareCase::INSENSITIVE_ASCII)) { + false)) { 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 49d8af6..078b627 100644 --- a/components/password_manager/core/browser/password_manager.cc +++ b/components/password_manager/core/browser/password_manager.cc @@ -477,8 +477,7 @@ 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, - base::CompareCase::SENSITIVE)) + if (base::EndsWith(iter->signon_realm, kSpdyProxyRealm, true)) 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 7b576df..af24a2b 100644 --- a/components/plugins/renderer/mobile_youtube_plugin.cc +++ b/components/plugins/renderer/mobile_youtube_plugin.cc @@ -89,10 +89,8 @@ 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", base::CompareCase::SENSITIVE) || - base::EndsWith(host, "youtube-nocookie.com", - base::CompareCase::SENSITIVE); + bool is_youtube = base::EndsWith(host, "youtube.com", true) || + base::EndsWith(host, "youtube-nocookie.com", true); 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 04ceb82..113cf8e 100644 --- a/components/plugins/renderer/plugin_placeholder.cc +++ b/components/plugins/renderer/plugin_placeholder.cc @@ -78,15 +78,14 @@ 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", base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(width_str, "px", false)) { 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", - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(height_str, "px", false)) { 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 92b8ccb..8c50d16 100644 --- a/components/search/search.cc +++ b/components/search/search.cc @@ -90,8 +90,7 @@ bool GetFieldTrialInfo(FieldTrialFlags* flags) { kInstantExtendedFieldTrialName); } - if (base::EndsWith(group_name, kDisablingSuffix, - base::CompareCase::SENSITIVE)) + if (base::EndsWith(group_name, kDisablingSuffix, true)) 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 168d2eb..6913f03 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"\\", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(mount_point, L"\\", false)) 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 ad20b1e..4b2b43a 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", base::CompareCase::INSENSITIVE_ASCII); + return base::EndsWith(host, ".test", false); } 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 583d77a..fd7be82 100644 --- a/components/variations/net/variations_http_header_provider.cc +++ b/components/variations/net/variations_http_header_provider.cc @@ -280,8 +280,7 @@ 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], - base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(host, kSuffixesToSetHeadersFor[i], false)) return true; } diff --git a/components/wifi/wifi_service_win.cc b/components/wifi/wifi_service_win.cc index 2716136..f20c26e 100644 --- a/components/wifi/wifi_service_win.cc +++ b/components/wifi/wifi_service_win.cc @@ -1154,8 +1154,7 @@ 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, - base::CompareCase::INSENSITIVE_ASCII)) { + interface_info->Adapter[adapter].Name, guid_string, false)) { *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 6ddf830..392c262 100644 --- a/content/browser/accessibility/android_granularity_movement_browsertest.cc +++ b/content/browser/accessibility/android_granularity_movement_browsertest.cc @@ -91,8 +91,7 @@ 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"), - base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(selection, base::ASCIIToUTF16("\n"), false)) selection.erase(selection.size() - 1); if (!selection.empty()) { if (!concatenated.empty()) @@ -117,8 +116,7 @@ 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"), - base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(selection, base::ASCIIToUTF16("\n"), false)) 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 68ff04d..12969f5 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", - base::CompareCase::SENSITIVE)) { + true)) { return; } net::HttpRequestHeaders headers; diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index eadffcc..93140c2 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -581,8 +581,7 @@ 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), - base::CompareCase::SENSITIVE)) + if (base::EndsWith(plugin_name, base::ASCIIToUTF16(kPluginExtension), true)) 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 d753e94..38903a01 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -2987,8 +2987,7 @@ 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, - base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(security_origin, kDotGoogleDotCom, false)) 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 09c5896..b401710 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", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".css", false)) return "text/css"; - if (base::EndsWith(path, ".js", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".js", false)) return "application/javascript"; - if (base::EndsWith(path, ".json", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".json", false)) return "application/json"; - if (base::EndsWith(path, ".pdf", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".pdf", false)) return "application/pdf"; - if (base::EndsWith(path, ".svg", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".svg", false)) return "image/svg+xml"; return "text/html"; diff --git a/content/common/set_process_title.cc b/content/common/set_process_title.cc index d74af96..229524e 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, base::CompareCase::SENSITIVE)) + if (base::EndsWith(title, kDeletedSuffix, true)) 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 16e483a..0b07786 100644 --- a/dbus/string_util.cc +++ b/dbus/string_util.cc @@ -8,10 +8,13 @@ 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::StartsWith(value, "/", base::CompareCase::SENSITIVE)) + if (!base::StartsWithASCII(value, "/", kCaseSensitive)) return false; // Elements are pieces delimited by '/'. For instance, "org", "chromium", @@ -36,8 +39,7 @@ 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, "/", base::CompareCase::SENSITIVE)) + if (value.size() > 1 && base::EndsWith(value, "/", kCaseSensitive)) 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 430a05c..615090a 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 base::CompareCase case_sensitive_; + const bool 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::StartsWith(str, data_, case_sensitive_); + return base::StartsWithASCII(str, data_, case_sensitive_); case kSuffix: return base::EndsWith(str, data_, case_sensitive_); case kEquals: return str.size() == data_.size() && - base::StartsWith(str, data_, case_sensitive_); + base::StartsWithASCII(str, data_, case_sensitive_); case kContains: - if (case_sensitive_ == base::CompareCase::INSENSITIVE_ASCII) { + if (!case_sensitive_) { return std::search(str.begin(), str.end(), data_.begin(), data_.end(), CaseInsensitiveCompareASCII<char>()) != str.end(); } else { @@ -446,8 +446,7 @@ HeaderMatcher::StringMatchTest::StringMatchTest(const std::string& data, bool case_sensitive) : data_(data), type_(type), - case_sensitive_(case_sensitive ? base::CompareCase::SENSITIVE - : base::CompareCase::INSENSITIVE_ASCII) {} + case_sensitive_(case_sensitive) {} // 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 fd73304..2f57d63 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, base::CompareCase::SENSITIVE)) { + if (base::EndsWith(host, kGoogleCom, true)) { // 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::StartsWith(host, kClient, base::CompareCase::SENSITIVE)) { + if (base::StartsWithASCII(host, kClient, true)) { bool match = true; for (std::string::const_iterator i = host.begin() + strlen(kClient), end = host.end() - strlen(kGoogleCom); i != end; ++i) { @@ -50,12 +50,10 @@ bool IsSensitiveURL(const GURL& url) { // others. sensitive_chrome_url = sensitive_chrome_url || - base::EndsWith(url.host(), ".clients.google.com", - base::CompareCase::SENSITIVE) || + base::EndsWith(url.host(), ".clients.google.com", true) || url.host() == "sb-ssl.google.com" || (url.host() == "chrome.google.com" && - base::StartsWith(url.path(), "/webstore", - base::CompareCase::SENSITIVE)); + base::StartsWithASCII(url.path(), "/webstore", true)); } GURL::Replacements replacements; replacements.ClearQuery(); diff --git a/extensions/common/user_script.cc b/extensions/common/user_script.cc index 6b64741..b3d82bb 100644 --- a/extensions/common/user_script.cc +++ b/extensions/common/user_script.cc @@ -52,8 +52,7 @@ int UserScript::GenerateUserScriptID() { bool UserScript::IsURLUserScript(const GURL& url, const std::string& mime_type) { - return base::EndsWith(url.ExtractFileName(), kFileExtension, - base::CompareCase::INSENSITIVE_ASCII) && + return base::EndsWith(url.ExtractFileName(), kFileExtension, false) && mime_type != "text/html"; } diff --git a/extensions/utility/unpacker_unittest.cc b/extensions/utility/unpacker_unittest.cc index 82e5a1f7..bb99aae 100644 --- a/extensions/utility/unpacker_unittest.cc +++ b/extensions/utility/unpacker_unittest.cc @@ -171,8 +171,7 @@ TEST_F(UnpackerTest, BadPathError) { EXPECT_FALSE(unpacker_->Run()); EXPECT_TRUE(base::StartsWith(unpacker_->error_message(), - ASCIIToUTF16(kExpected), - base::CompareCase::INSENSITIVE_ASCII)) + ASCIIToUTF16(kExpected), false)) << "Expected prefix: \"" << kExpected << "\", actual error: \"" << unpacker_->error_message() << "\""; } @@ -182,8 +181,7 @@ TEST_F(UnpackerTest, ImageDecodingError) { SetupUnpacker("bad_image.crx"); EXPECT_FALSE(unpacker_->Run()); EXPECT_TRUE(base::StartsWith(unpacker_->error_message(), - ASCIIToUTF16(kExpected), - base::CompareCase::INSENSITIVE_ASCII)) + ASCIIToUTF16(kExpected), false)) << "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 f74c794..6a22ca0 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", - base::CompareCase::SENSITIVE)) + true /* case 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 4fe76db..b1167b6 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -841,8 +841,7 @@ 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, base::CompareCase::SENSITIVE)) { + if (info->arraySize > 0 && !base::EndsWith(name, kArraySpec, true)) { *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 e20b660..ee0ed42 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", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".js", false)) return "application/javascript"; - if (base::EndsWith(path, ".json", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".json", false)) return "application/json"; - if (base::EndsWith(path, ".pdf", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".pdf", false)) return "application/pdf"; - if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".css", false)) return "text/css"; - if (base::EndsWith(path, ".svg", base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(path, ".svg", false)) return "image/svg+xml"; return "text/html"; diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc index 7cf841a..f974241 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", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(timestamp_str, "K", true)) { 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", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(timestamps[i], "P", true)) { 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 38539c1..cf54bd2 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", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(timestamps[i], "K", true)) { 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 2fdcce2..b0e9316 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", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(timestamps[i], "P", true)) { ASSERT_TRUE(buffer->is_key_frame()); scoped_refptr<StreamParserBuffer> preroll_buffer; preroll_buffer.swap(buffer); @@ -500,42 +500,40 @@ class SourceBufferStreamTest : public testing::Test { bool is_duration_estimated = false; // Handle splice frame starts. - if (base::StartsWith(timestamps[i], "S(", base::CompareCase::SENSITIVE)) { + if (base::StartsWithASCII(timestamps[i], "S(", true)) { 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], ")", base::CompareCase::SENSITIVE)) { + if (splice_frame && base::EndsWith(timestamps[i], ")", true)) { 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", base::CompareCase::SENSITIVE)) { + if (splice_frame && base::EndsWith(timestamps[i], "C", true)) { 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", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(timestamps[i], "K", true)) { 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", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(timestamps[i], "P", true)) { 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", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(timestamps[i], "E", true)) { 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 443b7f3..1fbf8ef 100644 --- a/media/video/capture/mac/video_capture_device_factory_mac.mm +++ b/media/video/capture/mac/video_capture_device_factory_mac.mm @@ -35,10 +35,8 @@ 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, - base::CompareCase::INSENSITIVE_ASCII); + is_device_blacklisted = base::EndsWith(name.id(), + kBlacklistedCameras[i].unique_id_signature, false); } DVLOG_IF(2, is_device_blacklisted) << "Blacklisted camera: " << name.name() << ", id: " << name.id(); @@ -186,7 +184,7 @@ void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { if (base::EndsWith(device.id(), kBlacklistedCameras[i].unique_id_signature, - base::CompareCase::INSENSITIVE_ASCII)) { + false)) { 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 cb03dba..e474489 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, base::CompareCase::SENSITIVE)) + if (base::EndsWith(device_name_, suffix, true /* case sensitive */)) return device_name_; return device_name_ + suffix; } diff --git a/mojo/runner/shell_apptest.cc b/mojo/runner/shell_apptest.cc index 2a943d6..70f7864 100644 --- a/mojo/runner/shell_apptest.cc +++ b/mojo/runner/shell_apptest.cc @@ -184,8 +184,7 @@ 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", - base::CompareCase::SENSITIVE)); + EXPECT_TRUE(base::EndsWith(app_url, "/pingable_app.mojo", true)); 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 9adb2fe..27c547b 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, "/*", base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(mime_type, "/*", false)) { 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 e045441..39a8591 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", base::CompareCase::SENSITIVE); + return base::EndsWith(host, ".localhost", true); } // |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, base::CompareCase::INSENSITIVE_ASCII)) + if (base::EndsWith(host, suffix, false)) return true; } return false; diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 7fe07c6..76e352e 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -1444,8 +1444,7 @@ void HttpNetworkTransaction::RecordSSLFallbackMetrics(int result) { return; const std::string& host = request_->url.host(); - bool is_google = base::EndsWith(host, "google.com", - base::CompareCase::SENSITIVE) && + bool is_google = base::EndsWith(host, "google.com", true) && (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 d1c259e..15871b5 100644 --- a/net/http/http_server_properties_impl.cc +++ b/net/http/http_server_properties_impl.cc @@ -117,8 +117,7 @@ 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], - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(it->first.host(), canonical_suffixes_[i], false)) { canonical_host_to_origin_map_[canonical_host] = it->first; break; } @@ -261,8 +260,7 @@ 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], - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(host, canonical_suffixes_[i], false)) { return canonical_suffix; } } @@ -370,8 +368,7 @@ 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], - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(origin.host(), canonical_suffixes_[i], false)) { HostPortPair canonical_host(canonical_suffix, origin.port()); canonical_host_to_origin_map_[canonical_host] = origin; break; @@ -614,8 +611,7 @@ 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], - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(server.host(), canonical_suffixes_[i], false)) { 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 f9af055..a041f4c 100644 --- a/net/quic/crypto/quic_crypto_client_config.cc +++ b/net/quic/crypto/quic_crypto_client_config.cc @@ -904,8 +904,7 @@ 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], - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(server_id.host(), canonical_suffixes_[i], false)) { break; } } diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index e611042..1252c6a 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -2978,8 +2978,7 @@ 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", - base::CompareCase::INSENSITIVE_ASCII)) { + if (base::EndsWith(host_port_pair().host(), "google.com", false)) { 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 36e4c57..e817ce1 100644 --- a/net/spdy/spdy_session_test_util.cc +++ b/net/spdy/spdy_session_test_util.cc @@ -28,10 +28,9 @@ void SpdySessionTestTaskObserver::WillProcessTask( void SpdySessionTestTaskObserver::DidProcessTask( const base::PendingTask& pending_task) { - if (base::EndsWith(pending_task.posted_from.file_name(), file_name_, - base::CompareCase::SENSITIVE) && + if (base::EndsWith(pending_task.posted_from.file_name(), file_name_, true) && base::EndsWith(pending_task.posted_from.function_name(), function_name_, - base::CompareCase::SENSITIVE)) { + true)) { ++executed_count_; } } diff --git a/net/tools/flip_server/mem_cache.cc b/net/tools/flip_server/mem_cache.cc index 485c91e..b280b98 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", base::CompareCase::SENSITIVE)) { + if (base::EndsWith(filename, ".html", true)) { 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 d1f41a7..8e4d9c4 100644 --- a/net/websockets/websocket_stream_cookie_test.cc +++ b/net/websockets/websocket_stream_cookie_test.cc @@ -35,8 +35,7 @@ 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", base::CompareCase::SENSITIVE)); + CHECK(cookie_header.empty() || base::EndsWith(cookie_header, "\r\n", true)); url_request_context_host_.SetExpectations( WebSocketStandardRequestWithCookies(url.path(), url.host(), origin, diff --git a/pdf/document_loader.cc b/pdf/document_loader.cc index 28a6ee4..f696656 100644 --- a/pdf/document_loader.cc +++ b/pdf/document_loader.cc @@ -68,15 +68,12 @@ std::string GetMultiPartBoundary(const std::string& headers) { } bool IsValidContentType(const std::string& type) { - 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)); + 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)); } } // namespace diff --git a/remoting/host/it2me/it2me_host.cc b/remoting/host/it2me/it2me_host.cc index fe9e8c6..49cca62 100644 --- a/remoting/host/it2me/it2me_host.cc +++ b/remoting/host/it2me/it2me_host.cc @@ -197,8 +197,7 @@ void It2MeHost::FinishConnect() { // Check the host domain policy. if (!required_host_domain_.empty() && !base::EndsWith(xmpp_server_config_.username, - std::string("@") + required_host_domain_, - base::CompareCase::INSENSITIVE_ASCII)) { + std::string("@") + required_host_domain_, false)) { SetState(kInvalidDomainError, ""); return; } diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 0970feb..7174184 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -1096,8 +1096,7 @@ void HostProcess::ApplyHostDomainPolicy() { ShutdownHost(kInvalidHostDomainExitCode); } - if (!base::EndsWith(host_owner_, std::string("@") + host_domain_, - base::CompareCase::INSENSITIVE_ASCII)) { + if (!base::EndsWith(host_owner_, std::string("@") + host_domain_, false)) { 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 e0871c8..d3c2775 100644 --- a/third_party/zlib/google/zip_reader.cc +++ b/third_party/zlib/google/zip_reader.cc @@ -131,8 +131,7 @@ 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, "/", - base::CompareCase::INSENSITIVE_ASCII); + is_directory_ = base::EndsWith(file_name_in_zip, "/", false); // 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 971f4d8..1fc06b2 100644 --- a/tools/gn/ninja_binary_target_writer.cc +++ b/tools/gn/ninja_binary_target_writer.cc @@ -650,8 +650,7 @@ 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, - base::CompareCase::INSENSITIVE_ASCII)) { + base::EndsWith(all_libs[i], framework_ending, false)) { // 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 7913735..e03b2d2 100644 --- a/tools/gn/ninja_target_writer.cc +++ b/tools/gn/ninja_target_writer.cc @@ -242,8 +242,7 @@ 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", - base::CompareCase::INSENSITIVE_ASCII)) + CHECK(base::EndsWith(stamp_file.value(), ".stamp", false)) << "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 010dbde..de0e620 100644 --- a/ui/base/l10n/l10n_util.cc +++ b/ui/base/l10n/l10n_util.cc @@ -201,9 +201,8 @@ bool IsDuplicateName(const std::string& locale_name) { }; // Skip all the es_Foo other than es_419 for now. - if (base::StartsWith(locale_name, "es_", - base::CompareCase::INSENSITIVE_ASCII)) - return !base::EndsWith(locale_name, "419", base::CompareCase::SENSITIVE); + if (base::StartsWithASCII(locale_name, "es_", false)) + return !base::EndsWith(locale_name, "419", true); 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 7bdf903..d0df023 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", base::CompareCase::SENSITIVE)) + if (!base::EndsWith(size_string, "px", true /* case_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", base::CompareCase::SENSITIVE)); + base::EndsWith(font_description, "px", true)); 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 3eb55be..907f4ef 100644 --- a/ui/gfx/font_list_impl.cc +++ b/ui/gfx/font_list_impl.cc @@ -44,8 +44,7 @@ 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", - base::CompareCase::SENSITIVE)); + DCHECK(base::EndsWith(font_description_string, "px", true)); } FontListImpl::FontListImpl(const std::vector<std::string>& font_names, |