| 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 #ifndef EXTENSIONS_COMMON_URL_PATTERN_H_ | 4 #ifndef EXTENSIONS_COMMON_URL_PATTERN_H_ |
| 5 #define EXTENSIONS_COMMON_URL_PATTERN_H_ | 5 #define EXTENSIONS_COMMON_URL_PATTERN_H_ |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // Converts this URLPattern into an equivalent set of URLPatterns that don't | 169 // Converts this URLPattern into an equivalent set of URLPatterns that don't |
| 170 // use a wildcard in the scheme component. If this URLPattern doesn't use a | 170 // use a wildcard in the scheme component. If this URLPattern doesn't use a |
| 171 // wildcard scheme, then the returned set will contain one element that is | 171 // wildcard scheme, then the returned set will contain one element that is |
| 172 // equivalent to this instance. | 172 // equivalent to this instance. |
| 173 std::vector<URLPattern> ConvertToExplicitSchemes() const; | 173 std::vector<URLPattern> ConvertToExplicitSchemes() const; |
| 174 | 174 |
| 175 static bool EffectiveHostCompare(const URLPattern& a, const URLPattern& b) { | 175 static bool EffectiveHostCompare(const URLPattern& a, const URLPattern& b) { |
| 176 if (a.match_all_urls_ && b.match_all_urls_) | 176 if (a.match_all_urls_ && b.match_all_urls_) |
| 177 return false; | 177 return false; |
| 178 return a.host_.compare(b.host_) < 0; | 178 return a.host_.compare(b.host_) < 0; |
| 179 }; | 179 } |
| 180 | 180 |
| 181 // Used for origin comparisons in a std::set. | 181 // Used for origin comparisons in a std::set. |
| 182 class EffectiveHostCompareFunctor { | 182 class EffectiveHostCompareFunctor { |
| 183 public: | 183 public: |
| 184 bool operator()(const URLPattern& a, const URLPattern& b) const { | 184 bool operator()(const URLPattern& a, const URLPattern& b) const { |
| 185 return EffectiveHostCompare(a, b); | 185 return EffectiveHostCompare(a, b); |
| 186 }; | 186 } |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 // Get an error string for a ParseResult. | 189 // Get an error string for a ParseResult. |
| 190 static const char* GetParseResultString(URLPattern::ParseResult parse_result); | 190 static const char* GetParseResultString(URLPattern::ParseResult parse_result); |
| 191 | 191 |
| 192 private: | 192 private: |
| 193 // Returns true if any of the |schemes| items matches our scheme. | 193 // Returns true if any of the |schemes| items matches our scheme. |
| 194 bool MatchesAnyScheme(const std::vector<std::string>& schemes) const; | 194 bool MatchesAnyScheme(const std::vector<std::string>& schemes) const; |
| 195 | 195 |
| 196 // Returns true if all of the |schemes| items matches our scheme. | 196 // Returns true if all of the |schemes| items matches our scheme. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // MatchPattern() function. | 234 // MatchPattern() function. |
| 235 std::string path_escaped_; | 235 std::string path_escaped_; |
| 236 | 236 |
| 237 // A string representing this URLPattern. | 237 // A string representing this URLPattern. |
| 238 mutable std::string spec_; | 238 mutable std::string spec_; |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 typedef std::vector<URLPattern> URLPatternList; | 241 typedef std::vector<URLPattern> URLPatternList; |
| 242 | 242 |
| 243 #endif // EXTENSIONS_COMMON_URL_PATTERN_H_ | 243 #endif // EXTENSIONS_COMMON_URL_PATTERN_H_ |
| OLD | NEW |