OLD | NEW |
1 // Copyright (c) 2011 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 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 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 // Gets the path the pattern matches with the leading slash. This can have | 113 // Gets the path the pattern matches with the leading slash. This can have |
114 // embedded asterisks which are interpreted using glob rules. | 114 // embedded asterisks which are interpreted using glob rules. |
115 const std::string& path() const { return path_; } | 115 const std::string& path() const { return path_; } |
116 void SetPath(const std::string& path); | 116 void SetPath(const std::string& path); |
117 | 117 |
118 // Returns true if this pattern matches all urls. | 118 // Returns true if this pattern matches all urls. |
119 bool match_all_urls() const { return match_all_urls_; } | 119 bool match_all_urls() const { return match_all_urls_; } |
120 void SetMatchAllURLs(bool val); | 120 void SetMatchAllURLs(bool val); |
121 | 121 |
| 122 // Returns true if this pattern matches inner URLs of filesystem: URLs only. |
| 123 // Returns false if this pattern matches only non-filesystem URLs. |
| 124 bool partial_filesystem_support_hack() const { |
| 125 return partial_filesystem_support_hack_; |
| 126 } |
| 127 void set_partial_filesystem_support_hack(bool val) { |
| 128 partial_filesystem_support_hack_ = val; |
| 129 } |
| 130 |
122 // Sets the scheme for pattern matches. This can be a single '*' if the | 131 // Sets the scheme for pattern matches. This can be a single '*' if the |
123 // pattern matches all valid schemes (as defined by the valid_schemes_ | 132 // pattern matches all valid schemes (as defined by the valid_schemes_ |
124 // property). Returns false on failure (if the scheme is not valid). | 133 // property). Returns false on failure (if the scheme is not valid). |
125 bool SetScheme(const std::string& scheme); | 134 bool SetScheme(const std::string& scheme); |
126 // Note: You should use MatchesScheme() instead of this getter unless you | 135 // Note: You should use MatchesScheme() instead of this getter unless you |
127 // absolutely need the exact scheme. This is exposed for testing. | 136 // absolutely need the exact scheme. This is exposed for testing. |
128 const std::string& scheme() const { return scheme_; } | 137 const std::string& scheme() const { return scheme_; } |
129 | 138 |
130 // Returns true if the specified scheme can be used in this URL pattern, and | 139 // Returns true if the specified scheme can be used in this URL pattern, and |
131 // false otherwise. Uses valid_schemes_ to determine validity. | 140 // false otherwise. Uses valid_schemes_ to determine validity. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 206 |
198 // A bitmask containing the schemes which are considered valid for this | 207 // A bitmask containing the schemes which are considered valid for this |
199 // pattern. Parse() uses this to decide whether a pattern contains a valid | 208 // pattern. Parse() uses this to decide whether a pattern contains a valid |
200 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_ | 209 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_ |
201 // matches a given test scheme. | 210 // matches a given test scheme. |
202 int valid_schemes_; | 211 int valid_schemes_; |
203 | 212 |
204 // True if this is a special-case "<all_urls>" pattern. | 213 // True if this is a special-case "<all_urls>" pattern. |
205 bool match_all_urls_; | 214 bool match_all_urls_; |
206 | 215 |
| 216 // True if we're trying to match against the inner URL of a filesystem URL; |
| 217 // this is a temporary hack so as not to break ChromeOS as we work on full |
| 218 // support. |
| 219 bool partial_filesystem_support_hack_; |
| 220 |
207 // The scheme for the pattern. | 221 // The scheme for the pattern. |
208 std::string scheme_; | 222 std::string scheme_; |
209 | 223 |
210 // The host without any leading "*" components. | 224 // The host without any leading "*" components. |
211 std::string host_; | 225 std::string host_; |
212 | 226 |
213 // Whether we should match subdomains of the host. This is true if the first | 227 // Whether we should match subdomains of the host. This is true if the first |
214 // component of the pattern's host was "*". | 228 // component of the pattern's host was "*". |
215 bool match_subdomains_; | 229 bool match_subdomains_; |
216 | 230 |
217 // The port. | 231 // The port. |
218 std::string port_; | 232 std::string port_; |
219 | 233 |
220 // The path to match. This is everything after the host of the URL, or | 234 // The path to match. This is everything after the host of the URL, or |
221 // everything after the scheme in the case of file:// URLs. | 235 // everything after the scheme in the case of file:// URLs. |
222 std::string path_; | 236 std::string path_; |
223 | 237 |
224 // The path with "?" and "\" characters escaped for use with the | 238 // The path with "?" and "\" characters escaped for use with the |
225 // MatchPattern() function. | 239 // MatchPattern() function. |
226 std::string path_escaped_; | 240 std::string path_escaped_; |
227 | 241 |
228 // A string representing this URLPattern. | 242 // A string representing this URLPattern. |
229 mutable std::string spec_; | 243 mutable std::string spec_; |
230 }; | 244 }; |
231 | 245 |
232 typedef std::vector<URLPattern> URLPatternList; | 246 typedef std::vector<URLPattern> URLPatternList; |
233 | 247 |
234 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ | 248 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ |
OLD | NEW |