summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authoryosin <yosin@chromium.org>2015-07-16 00:10:59 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-16 07:11:43 +0000
commitddbde8ff8310abbd529ad5cc43e3991e79106a52 (patch)
tree645dcf37cdb6b7386236aa97d029767adc0d0553 /extensions
parent1d63b59ad168772d9b1eb1ae45971adc65d07f94 (diff)
downloadchromium_src-ddbde8ff8310abbd529ad5cc43e3991e79106a52.zip
chromium_src-ddbde8ff8310abbd529ad5cc43e3991e79106a52.tar.gz
chromium_src-ddbde8ff8310abbd529ad5cc43e3991e79106a52.tar.bz2
Revert of Remove some legacy versions of StartsWith and EndsWith. (patchset #6 id:100001 of https://codereview.chromium.org/1239493005/)
Reason for revert: Compilation error on Windows: FAILED: ninja -t msvc -e environment.x86 -- C:\b\build\goma/gomacc "C:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\chrome\installer\gcapi\gcapi_lib.gcapi.obj.rsp /c ..\..\chrome\installer\gcapi\gcapi.cc /Foobj\chrome\installer\gcapi\gcapi_lib.gcapi.obj /Fdobj\chrome\gcapi_lib.cc.pdb c:\b\build\slave\win-latest-rel\build\src\chrome\installer\gcapi\gcapi.cc(365) : error C3083: 'StartsWith': the symbol to the left of a '::' must be a type c:\b\build\slave\win-latest-rel\build\src\chrome\installer\gcapi\gcapi.cc(365) : error C2039: 'INSENSITIVE_ASCII' : is not a member of 'base' c:\b\build\slave\win-latest-rel\build\src\chrome\installer\gcapi\gcapi.cc(365) : error C2065: 'INSENSITIVE_ASCII' : undeclared identifier ninja: build stopped: subcommand failed. Original issue's description: > 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 > > Committed: https://crrev.com/edce9a33027cc5f73c4866d70e34f690f6720a56 > Cr-Commit-Position: refs/heads/master@{#338996} TBR=jam@chromium.org,brettw@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=506255 Review URL: https://codereview.chromium.org/1233453011 Cr-Commit-Position: refs/heads/master@{#338998}
Diffstat (limited to 'extensions')
-rw-r--r--extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc11
-rw-r--r--extensions/browser/api/web_request/web_request_permissions.cc10
-rw-r--r--extensions/common/user_script.cc3
-rw-r--r--extensions/utility/unpacker_unittest.cc6
4 files changed, 12 insertions, 18 deletions
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() << "\"";
}