OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ | 4 #ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ |
5 #define CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ | 5 #define CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ |
6 #pragma once | 6 #pragma once |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // absolutely need the exact scheme. This is exposed for testing. | 184 // absolutely need the exact scheme. This is exposed for testing. |
185 const std::string& scheme() const { return scheme_; } | 185 const std::string& scheme() const { return scheme_; } |
186 | 186 |
187 // Returns true if the specified scheme can be used in this URL pattern, and | 187 // Returns true if the specified scheme can be used in this URL pattern, and |
188 // false otherwise. Uses valid_schemes_ to determine validity. | 188 // false otherwise. Uses valid_schemes_ to determine validity. |
189 bool IsValidScheme(const std::string& scheme) const; | 189 bool IsValidScheme(const std::string& scheme) const; |
190 | 190 |
191 // Returns true if this instance matches the specified URL. | 191 // Returns true if this instance matches the specified URL. |
192 bool MatchesURL(const GURL& test) const; | 192 bool MatchesURL(const GURL& test) const; |
193 | 193 |
| 194 // Returns true if this instance matches the specified security origin. |
| 195 bool MatchesSecurityOrigin(const GURL& test) const; |
| 196 |
194 // Returns true if |test| matches our scheme. | 197 // Returns true if |test| matches our scheme. |
195 bool MatchesScheme(const std::string& test) const; | 198 bool MatchesScheme(const std::string& test) const; |
196 | 199 |
197 // Returns true if |test| matches our host. | 200 // Returns true if |test| matches our host. |
198 bool MatchesHost(const std::string& test) const; | 201 bool MatchesHost(const std::string& test) const; |
199 bool MatchesHost(const GURL& test) const; | 202 bool MatchesHost(const GURL& test) const; |
200 | 203 |
201 // Returns true if |test| matches our path. | 204 // Returns true if |test| matches our path. |
202 bool MatchesPath(const std::string& test) const; | 205 bool MatchesPath(const std::string& test) const; |
203 | 206 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 }; | 239 }; |
237 }; | 240 }; |
238 | 241 |
239 // Get an error string for a ParseResult. | 242 // Get an error string for a ParseResult. |
240 static const char* GetParseResultString(URLPattern::ParseResult parse_result); | 243 static const char* GetParseResultString(URLPattern::ParseResult parse_result); |
241 | 244 |
242 private: | 245 private: |
243 // Returns true if any of the |schemes| items matches our scheme. | 246 // Returns true if any of the |schemes| items matches our scheme. |
244 bool MatchesAnyScheme(const std::vector<std::string>& schemes) const; | 247 bool MatchesAnyScheme(const std::vector<std::string>& schemes) const; |
245 | 248 |
| 249 bool MatchesSecurityOriginHelper(const GURL& test) const; |
| 250 |
246 // If the URLPattern contains a wildcard scheme, returns a list of | 251 // If the URLPattern contains a wildcard scheme, returns a list of |
247 // equivalent literal schemes, otherwise returns the current scheme. | 252 // equivalent literal schemes, otherwise returns the current scheme. |
248 std::vector<std::string> GetExplicitSchemes() const; | 253 std::vector<std::string> GetExplicitSchemes() const; |
249 | 254 |
250 // A bitmask containing the schemes which are considered valid for this | 255 // A bitmask containing the schemes which are considered valid for this |
251 // pattern. Parse() uses this to decide whether a pattern contains a valid | 256 // pattern. Parse() uses this to decide whether a pattern contains a valid |
252 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_ | 257 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_ |
253 // matches a given test scheme. | 258 // matches a given test scheme. |
254 int valid_schemes_; | 259 int valid_schemes_; |
255 | 260 |
(...skipping 22 matching lines...) Expand all Loading... |
278 // MatchPattern() function. | 283 // MatchPattern() function. |
279 std::string path_escaped_; | 284 std::string path_escaped_; |
280 | 285 |
281 // A string representing this URLPattern. | 286 // A string representing this URLPattern. |
282 mutable std::string spec_; | 287 mutable std::string spec_; |
283 }; | 288 }; |
284 | 289 |
285 typedef std::vector<URLPattern> URLPatternList; | 290 typedef std::vector<URLPattern> URLPatternList; |
286 | 291 |
287 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ | 292 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ |
OLD | NEW |