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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 class EffectiveHostCompareFunctor { | 181 class EffectiveHostCompareFunctor { |
182 public: | 182 public: |
183 bool operator()(const URLPattern& a, const URLPattern& b) const { | 183 bool operator()(const URLPattern& a, const URLPattern& b) const { |
184 return EffectiveHostCompare(a, b); | 184 return EffectiveHostCompare(a, b); |
185 }; | 185 }; |
186 }; | 186 }; |
187 | 187 |
188 // Get an error string for a ParseResult. | 188 // Get an error string for a ParseResult. |
189 static const char* GetParseResultString(URLPattern::ParseResult parse_result); | 189 static const char* GetParseResultString(URLPattern::ParseResult parse_result); |
190 | 190 |
| 191 // Checks whether the bit is set for the given scheme in the given scheme mask |
| 192 static bool IsSchemeBitSet(const std::string& scheme, const int mask); |
| 193 |
191 private: | 194 private: |
192 // Returns true if any of the |schemes| items matches our scheme. | 195 // Returns true if any of the |schemes| items matches our scheme. |
193 bool MatchesAnyScheme(const std::vector<std::string>& schemes) const; | 196 bool MatchesAnyScheme(const std::vector<std::string>& schemes) const; |
194 | 197 |
195 // Returns true if all of the |schemes| items matches our scheme. | 198 // Returns true if all of the |schemes| items matches our scheme. |
196 bool MatchesAllSchemes(const std::vector<std::string>& schemes) const; | 199 bool MatchesAllSchemes(const std::vector<std::string>& schemes) const; |
197 | 200 |
198 bool MatchesSecurityOriginHelper(const GURL& test) const; | 201 bool MatchesSecurityOriginHelper(const GURL& test) const; |
199 | 202 |
200 // Returns true if our port matches the |port| pattern (it may be "*"). | 203 // Returns true if our port matches the |port| pattern (it may be "*"). |
201 bool MatchesPortPattern(const std::string& port) const; | 204 bool MatchesPortPattern(const std::string& port) const; |
202 | 205 |
203 // If the URLPattern contains a wildcard scheme, returns a list of | 206 // If the URLPattern contains a wildcard scheme, returns a list of |
204 // equivalent literal schemes, otherwise returns the current scheme. | 207 // equivalent literal schemes, otherwise returns the current scheme. |
205 std::vector<std::string> GetExplicitSchemes() const; | 208 std::vector<std::string> GetExplicitSchemes() const; |
206 | 209 |
207 // A bitmask containing the schemes which are considered valid for this | 210 // A bitmask containing the schemes which are considered valid for this |
208 // pattern. Parse() uses this to decide whether a pattern contains a valid | 211 // pattern. Parse() uses this to decide whether a pattern contains a valid |
209 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_ | 212 // scheme. |
210 // matches a given test scheme. | |
211 int valid_schemes_; | 213 int valid_schemes_; |
212 | 214 |
213 // True if this is a special-case "<all_urls>" pattern. | 215 // True if this is a special-case "<all_urls>" pattern. |
214 bool match_all_urls_; | 216 bool match_all_urls_; |
215 | 217 |
216 // The scheme for the pattern. | 218 // The scheme for the pattern. |
217 std::string scheme_; | 219 std::string scheme_; |
218 | 220 |
219 // The host without any leading "*" components. | 221 // The host without any leading "*" components. |
220 std::string host_; | 222 std::string host_; |
(...skipping 13 matching lines...) Expand all Loading... |
234 // MatchPattern() function. | 236 // MatchPattern() function. |
235 std::string path_escaped_; | 237 std::string path_escaped_; |
236 | 238 |
237 // A string representing this URLPattern. | 239 // A string representing this URLPattern. |
238 mutable std::string spec_; | 240 mutable std::string spec_; |
239 }; | 241 }; |
240 | 242 |
241 typedef std::vector<URLPattern> URLPatternList; | 243 typedef std::vector<URLPattern> URLPatternList; |
242 | 244 |
243 #endif // EXTENSIONS_COMMON_URL_PATTERN_H_ | 245 #endif // EXTENSIONS_COMMON_URL_PATTERN_H_ |
OLD | NEW |