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> |
11 | 11 |
12 class GURL; | 12 class GURL; |
13 | 13 |
14 // A pattern that can be used to match URLs. A URLPattern is a very restricted | 14 // A pattern that can be used to match URLs. A URLPattern is a very restricted |
15 // subset of URL syntax: | 15 // subset of URL syntax: |
16 // | 16 // |
17 // <url-pattern> := <scheme>://<host><port><path> | '<all_urls>' | 17 // <url-pattern> := <scheme>://<host><port><path> | '<all_urls>' |
18 // <scheme> := '*' | 'http' | 'https' | 'file' | 'ftp' | 'chrome' | 18 // <scheme> := '*' | 'http' | 'https' | 'file' | 'ftp' | 'chrome' | |
| 19 // 'chrome-extension' | 'filesystem' |
19 // <host> := '*' | '*.' <anychar except '/' and '*'>+ | 20 // <host> := '*' | '*.' <anychar except '/' and '*'>+ |
20 // <port> := [':' ('*' | <port number between 0 and 65535>)] | 21 // <port> := [':' ('*' | <port number between 0 and 65535>)] |
21 // <path> := '/' <any chars> | 22 // <path> := '/' <any chars> |
22 // | 23 // |
23 // * Host is not used when the scheme is 'file'. | 24 // * Host is not used when the scheme is 'file'. |
24 // * The port is only used if the pattern is parsed with the USE_PORTS option. | 25 // * The port is only used if the pattern is parsed with the USE_PORTS option. |
25 // If the patterns is parsed with the ERROR_ON_PORTS option, the port is not | 26 // If the patterns is parsed with the ERROR_ON_PORTS option, the port is not |
26 // allowed, and the resulting pattern matches any port. If it is parsed with | 27 // allowed, and the resulting pattern matches any port. If it is parsed with |
27 // the IGNORE_PORTS option, the port (including colon) is kept as part of the | 28 // the IGNORE_PORTS option, the port (including colon) is kept as part of the |
28 // host to maintain backwards compatibility with previous versions, which | 29 // host to maintain backwards compatibility with previous versions, which |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 class URLPattern { | 84 class URLPattern { |
84 public: | 85 public: |
85 // A collection of scheme bitmasks for use with valid_schemes. | 86 // A collection of scheme bitmasks for use with valid_schemes. |
86 enum SchemeMasks { | 87 enum SchemeMasks { |
87 SCHEME_NONE = 0, | 88 SCHEME_NONE = 0, |
88 SCHEME_HTTP = 1 << 0, | 89 SCHEME_HTTP = 1 << 0, |
89 SCHEME_HTTPS = 1 << 1, | 90 SCHEME_HTTPS = 1 << 1, |
90 SCHEME_FILE = 1 << 2, | 91 SCHEME_FILE = 1 << 2, |
91 SCHEME_FTP = 1 << 3, | 92 SCHEME_FTP = 1 << 3, |
92 SCHEME_CHROMEUI = 1 << 4, | 93 SCHEME_CHROMEUI = 1 << 4, |
93 SCHEME_FILESYSTEM = 1 << 5, | 94 SCHEME_EXTENSION = 1 << 5, |
| 95 SCHEME_FILESYSTEM = 1 << 6, |
94 // SCHEME_ALL will match every scheme, including chrome://, chrome- | 96 // SCHEME_ALL will match every scheme, including chrome://, chrome- |
95 // extension://, about:, etc. Because this has lots of security | 97 // extension://, about:, etc. Because this has lots of security |
96 // implications, third-party extensions should never be able to get access | 98 // implications, third-party extensions should never be able to get access |
97 // to URL patterns initialized this way. It should only be used for internal | 99 // to URL patterns initialized this way. It should only be used for internal |
98 // Chrome code. | 100 // Chrome code. |
99 SCHEME_ALL = -1, | 101 SCHEME_ALL = -1, |
100 }; | 102 }; |
101 | 103 |
102 // Options for URLPattern::Parse(). | 104 // Options for URLPattern::Parse(). |
103 enum ParseOption { | 105 enum ParseOption { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // MatchPattern() function. | 285 // MatchPattern() function. |
284 std::string path_escaped_; | 286 std::string path_escaped_; |
285 | 287 |
286 // A string representing this URLPattern. | 288 // A string representing this URLPattern. |
287 mutable std::string spec_; | 289 mutable std::string spec_; |
288 }; | 290 }; |
289 | 291 |
290 typedef std::vector<URLPattern> URLPatternList; | 292 typedef std::vector<URLPattern> URLPatternList; |
291 | 293 |
292 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ | 294 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ |
OLD | NEW |