Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/common/extensions/url_pattern.h

Issue 10224011: Add transparent support for filesystem URLs in URLPatterns. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restrict inner_url handling to filesystem URLs. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
131 // Sets the scheme for pattern matches. This can be a single '*' if the 122 // Sets the scheme for pattern matches. This can be a single '*' if the
132 // pattern matches all valid schemes (as defined by the valid_schemes_ 123 // pattern matches all valid schemes (as defined by the valid_schemes_
133 // property). Returns false on failure (if the scheme is not valid). 124 // property). Returns false on failure (if the scheme is not valid).
134 bool SetScheme(const std::string& scheme); 125 bool SetScheme(const std::string& scheme);
135 // Note: You should use MatchesScheme() instead of this getter unless you 126 // Note: You should use MatchesScheme() instead of this getter unless you
136 // absolutely need the exact scheme. This is exposed for testing. 127 // absolutely need the exact scheme. This is exposed for testing.
137 const std::string& scheme() const { return scheme_; } 128 const std::string& scheme() const { return scheme_; }
138 129
139 // Returns true if the specified scheme can be used in this URL pattern, and 130 // Returns true if the specified scheme can be used in this URL pattern, and
140 // false otherwise. Uses valid_schemes_ to determine validity. 131 // false otherwise. Uses valid_schemes_ to determine validity.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 197
207 // A bitmask containing the schemes which are considered valid for this 198 // A bitmask containing the schemes which are considered valid for this
208 // pattern. Parse() uses this to decide whether a pattern contains a valid 199 // pattern. Parse() uses this to decide whether a pattern contains a valid
209 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_ 200 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_
210 // matches a given test scheme. 201 // matches a given test scheme.
211 int valid_schemes_; 202 int valid_schemes_;
212 203
213 // True if this is a special-case "<all_urls>" pattern. 204 // True if this is a special-case "<all_urls>" pattern.
214 bool match_all_urls_; 205 bool match_all_urls_;
215 206
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
221 // The scheme for the pattern. 207 // The scheme for the pattern.
222 std::string scheme_; 208 std::string scheme_;
223 209
224 // The host without any leading "*" components. 210 // The host without any leading "*" components.
225 std::string host_; 211 std::string host_;
226 212
227 // Whether we should match subdomains of the host. This is true if the first 213 // Whether we should match subdomains of the host. This is true if the first
228 // component of the pattern's host was "*". 214 // component of the pattern's host was "*".
229 bool match_subdomains_; 215 bool match_subdomains_;
230 216
231 // The port. 217 // The port.
232 std::string port_; 218 std::string port_;
233 219
234 // The path to match. This is everything after the host of the URL, or 220 // The path to match. This is everything after the host of the URL, or
235 // everything after the scheme in the case of file:// URLs. 221 // everything after the scheme in the case of file:// URLs.
236 std::string path_; 222 std::string path_;
237 223
238 // The path with "?" and "\" characters escaped for use with the 224 // The path with "?" and "\" characters escaped for use with the
239 // MatchPattern() function. 225 // MatchPattern() function.
240 std::string path_escaped_; 226 std::string path_escaped_;
241 227
242 // A string representing this URLPattern. 228 // A string representing this URLPattern.
243 mutable std::string spec_; 229 mutable std::string spec_;
244 }; 230 };
245 231
246 typedef std::vector<URLPattern> URLPatternList; 232 typedef std::vector<URLPattern> URLPatternList;
247 233
248 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ 234 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698