OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #include "googleurl/src/gurl.h" | 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><path> | '<all_urls>' | 17 // <url-pattern> := <scheme>://<host><path> | '<all_urls>' |
18 // <scheme> := '*' | 'http' | 'https' | 'file' | 'ftp' | 'chrome' | 18 // <scheme> := '*' | 'http' | 'https' | 'file' | 'ftp' | 'chrome' |
19 // <host> := '*' | '*.' <anychar except '/' and '*'>+ | 19 // <host> := '*' | '*.' <anychar except '/' and '*'>+ |
20 // <path> := '/' <any chars> | 20 // <path> := '/' <any chars> |
21 // | 21 // |
22 // * Host is not used when the scheme is 'file'. | 22 // * Host is not used when the scheme is 'file'. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // Construct an URLPattern with the given set of allowable schemes. See | 91 // Construct an URLPattern with the given set of allowable schemes. See |
92 // valid_schemes_ for more info. | 92 // valid_schemes_ for more info. |
93 explicit URLPattern(int valid_schemes); | 93 explicit URLPattern(int valid_schemes); |
94 | 94 |
95 // Convenience to construct a URLPattern from a string. The string is expected | 95 // Convenience to construct a URLPattern from a string. The string is expected |
96 // to be a valid pattern. If the string is not known ahead of time, use | 96 // to be a valid pattern. If the string is not known ahead of time, use |
97 // Parse() instead, which returns success or failure. | 97 // Parse() instead, which returns success or failure. |
98 URLPattern(int valid_schemes, const std::string& pattern); | 98 URLPattern(int valid_schemes, const std::string& pattern); |
99 | 99 |
| 100 ~URLPattern(); |
| 101 |
100 // Gets the bitmask of valid schemes. | 102 // Gets the bitmask of valid schemes. |
101 int valid_schemes() const { return valid_schemes_; } | 103 int valid_schemes() const { return valid_schemes_; } |
102 void set_valid_schemes(int valid_schemes) { valid_schemes_ = valid_schemes; } | 104 void set_valid_schemes(int valid_schemes) { valid_schemes_ = valid_schemes; } |
103 | 105 |
104 // Gets the host the pattern matches. This can be an empty string if the | 106 // Gets the host the pattern matches. This can be an empty string if the |
105 // pattern matches all hosts (the input was <scheme>://*/<whatever>). | 107 // pattern matches all hosts (the input was <scheme>://*/<whatever>). |
106 const std::string& host() const { return host_; } | 108 const std::string& host() const { return host_; } |
107 void set_host(const std::string& host) { host_ = host; } | 109 void set_host(const std::string& host) { host_ = host; } |
108 | 110 |
109 // Gets whether to match subdomains of host(). | 111 // Gets whether to match subdomains of host(). |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // everything after the scheme in the case of file:// URLs. | 206 // everything after the scheme in the case of file:// URLs. |
205 std::string path_; | 207 std::string path_; |
206 | 208 |
207 // The path with "?" and "\" characters escaped for use with the | 209 // The path with "?" and "\" characters escaped for use with the |
208 // MatchPatternASCII() function. This is populated lazily, the first time it | 210 // MatchPatternASCII() function. This is populated lazily, the first time it |
209 // is needed. | 211 // is needed. |
210 mutable std::string path_escaped_; | 212 mutable std::string path_escaped_; |
211 }; | 213 }; |
212 | 214 |
213 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ | 215 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ |
OLD | NEW |