| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/browser/api/declarative_webrequest/webrequest_condition_att
ribute.h" | 5 #include "extensions/browser/api/declarative_webrequest/webrequest_condition_att
ribute.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 417 } |
| 418 | 418 |
| 419 HeaderMatcher::StringMatchTest::~StringMatchTest() {} | 419 HeaderMatcher::StringMatchTest::~StringMatchTest() {} |
| 420 | 420 |
| 421 bool HeaderMatcher::StringMatchTest::Matches( | 421 bool HeaderMatcher::StringMatchTest::Matches( |
| 422 const std::string& str) const { | 422 const std::string& str) const { |
| 423 switch (type_) { | 423 switch (type_) { |
| 424 case kPrefix: | 424 case kPrefix: |
| 425 return base::StartsWithASCII(str, data_, case_sensitive_); | 425 return base::StartsWithASCII(str, data_, case_sensitive_); |
| 426 case kSuffix: | 426 case kSuffix: |
| 427 return EndsWith(str, data_, case_sensitive_); | 427 return base::EndsWith(str, data_, case_sensitive_); |
| 428 case kEquals: | 428 case kEquals: |
| 429 return str.size() == data_.size() && | 429 return str.size() == data_.size() && |
| 430 base::StartsWithASCII(str, data_, case_sensitive_); | 430 base::StartsWithASCII(str, data_, case_sensitive_); |
| 431 case kContains: | 431 case kContains: |
| 432 if (!case_sensitive_) { | 432 if (!case_sensitive_) { |
| 433 return std::search(str.begin(), str.end(), data_.begin(), data_.end(), | 433 return std::search(str.begin(), str.end(), data_.begin(), data_.end(), |
| 434 CaseInsensitiveCompareASCII<char>()) != str.end(); | 434 CaseInsensitiveCompareASCII<char>()) != str.end(); |
| 435 } else { | 435 } else { |
| 436 return str.find(data_) != std::string::npos; | 436 return str.find(data_) != std::string::npos; |
| 437 } | 437 } |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 bool WebRequestConditionAttributeStages::Equals( | 869 bool WebRequestConditionAttributeStages::Equals( |
| 870 const WebRequestConditionAttribute* other) const { | 870 const WebRequestConditionAttribute* other) const { |
| 871 if (!WebRequestConditionAttribute::Equals(other)) | 871 if (!WebRequestConditionAttribute::Equals(other)) |
| 872 return false; | 872 return false; |
| 873 const WebRequestConditionAttributeStages* casted_other = | 873 const WebRequestConditionAttributeStages* casted_other = |
| 874 static_cast<const WebRequestConditionAttributeStages*>(other); | 874 static_cast<const WebRequestConditionAttributeStages*>(other); |
| 875 return allowed_stages_ == casted_other->allowed_stages_; | 875 return allowed_stages_ == casted_other->allowed_stages_; |
| 876 } | 876 } |
| 877 | 877 |
| 878 } // namespace extensions | 878 } // namespace extensions |
| OLD | NEW |