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

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

Issue 7811006: Add full support for filesystem URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fixes, removed duplicate set of var Created 8 years, 9 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) 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
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
122 // Sets the scheme for pattern matches. This can be a single '*' if the 129 // 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_ 130 // pattern matches all valid schemes (as defined by the valid_schemes_
124 // property). Returns false on failure (if the scheme is not valid). 131 // property). Returns false on failure (if the scheme is not valid).
125 bool SetScheme(const std::string& scheme); 132 bool SetScheme(const std::string& scheme);
126 // Note: You should use MatchesScheme() instead of this getter unless you 133 // Note: You should use MatchesScheme() instead of this getter unless you
127 // absolutely need the exact scheme. This is exposed for testing. 134 // absolutely need the exact scheme. This is exposed for testing.
128 const std::string& scheme() const { return scheme_; } 135 const std::string& scheme() const { return scheme_; }
129 136
130 // Returns true if the specified scheme can be used in this URL pattern, and 137 // Returns true if the specified scheme can be used in this URL pattern, and
131 // false otherwise. Uses valid_schemes_ to determine validity. 138 // false otherwise. Uses valid_schemes_ to determine validity.
132 bool IsValidScheme(const std::string& scheme) const; 139 bool IsValidScheme(const std::string& scheme) const;
133 140
134 // Returns true if this instance matches the specified URL. 141 // Returns true if this instance matches the specified URL.
135 bool MatchesURL(const GURL& test) const; 142 bool MatchesURL(const GURL& test) const;
136 143
137 // Returns true if this instance matches the specified security origin. 144 // Returns true if this instance matches the specified security origin.
138 bool MatchesSecurityOrigin(const GURL& test) const; 145 bool MatchesSecurityOrigin(const GURL& test) const;
139 146
140 // Returns true if |test| matches our scheme. 147 // Returns true if |test| matches our scheme.
141 bool MatchesScheme(const std::string& test) const; 148 bool MatchesScheme(const std::string& test) const;
142 149
143 // Returns true if |test| matches our host. 150 // Returns true if |test| matches our host.
144 bool MatchesHost(const std::string& test) const; 151 bool MatchesHost(const std::string& test) const;
145 bool MatchesHost(const GURL& test) const; 152 bool MatchesHost(const GURL& test) const;
146 153
147 // Returns true if |test| matches our path. 154 // Returns true if |test| matches our path.
148 bool MatchesPath(const std::string& test) const; 155 // Set filesystem_url to true if the path comes from a filesystem URL.
156 // See set_partial_filesystem_support_hack for behavior.
157 bool MatchesPath(const std::string& test, bool filesystem_url) const;
149 158
150 // Returns true if |port| matches our port. 159 // Returns true if |port| matches our port.
151 bool MatchesPort(int port) const; 160 bool MatchesPort(int port) const;
152 161
153 // Sets the port. Returns false if the port is invalid. 162 // Sets the port. Returns false if the port is invalid.
154 bool SetPort(const std::string& port); 163 bool SetPort(const std::string& port);
155 const std::string& port() const { return port_; } 164 const std::string& port() const { return port_; }
156 165
157 // Returns a string representing this instance. 166 // Returns a string representing this instance.
158 const std::string& GetAsString() const; 167 const std::string& GetAsString() const;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698