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

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: Merged out 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 nested URL paths.
123 // If false, a path match other than '*' will always fail on a nested URL.
124 // If true, a path match other than '*' will always fail on a non-nested URL.
Aaron Boodman 2012/03/21 23:51:57 Can we do something even more specific, just for t
ericu 2012/03/22 00:22:14 My goal was actually to support filesystem URLs tr
125 bool match_nested_url_path() const { return match_nested_url_path_; }
126 void SetMatchNestedURLPath(bool val);
127
122 // Sets the scheme for pattern matches. This can be a single '*' if the 128 // 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_ 129 // pattern matches all valid schemes (as defined by the valid_schemes_
124 // property). Returns false on failure (if the scheme is not valid). 130 // property). Returns false on failure (if the scheme is not valid).
125 bool SetScheme(const std::string& scheme); 131 bool SetScheme(const std::string& scheme);
126 // Note: You should use MatchesScheme() instead of this getter unless you 132 // Note: You should use MatchesScheme() instead of this getter unless you
127 // absolutely need the exact scheme. This is exposed for testing. 133 // absolutely need the exact scheme. This is exposed for testing.
128 const std::string& scheme() const { return scheme_; } 134 const std::string& scheme() const { return scheme_; }
129 135
130 // Returns true if the specified scheme can be used in this URL pattern, and 136 // Returns true if the specified scheme can be used in this URL pattern, and
131 // false otherwise. Uses valid_schemes_ to determine validity. 137 // false otherwise. Uses valid_schemes_ to determine validity.
132 bool IsValidScheme(const std::string& scheme) const; 138 bool IsValidScheme(const std::string& scheme) const;
133 139
134 // Returns true if this instance matches the specified URL. 140 // Returns true if this instance matches the specified URL.
135 bool MatchesURL(const GURL& test) const; 141 bool MatchesURL(const GURL& test) const;
136 142
137 // Returns true if this instance matches the specified security origin. 143 // Returns true if this instance matches the specified security origin.
138 bool MatchesSecurityOrigin(const GURL& test) const; 144 bool MatchesSecurityOrigin(const GURL& test) const;
139 145
140 // Returns true if |test| matches our scheme. 146 // Returns true if |test| matches our scheme.
141 bool MatchesScheme(const std::string& test) const; 147 bool MatchesScheme(const std::string& test) const;
142 148
143 // Returns true if |test| matches our host. 149 // Returns true if |test| matches our host.
144 bool MatchesHost(const std::string& test) const; 150 bool MatchesHost(const std::string& test) const;
145 bool MatchesHost(const GURL& test) const; 151 bool MatchesHost(const GURL& test) const;
146 152
147 // Returns true if |test| matches our path. 153 // Returns true if |test| matches our path.
148 bool MatchesPath(const std::string& test) const; 154 // Set nested_url to true if the test URL had an inner_url().
155 // See SetMatchNestedURLPath for behavior.
156 bool MatchesPath(const std::string& test, bool nested_url) const;
149 157
150 // Returns true if |port| matches our port. 158 // Returns true if |port| matches our port.
151 bool MatchesPort(int port) const; 159 bool MatchesPort(int port) const;
152 160
153 // Sets the port. Returns false if the port is invalid. 161 // Sets the port. Returns false if the port is invalid.
154 bool SetPort(const std::string& port); 162 bool SetPort(const std::string& port);
155 const std::string& port() const { return port_; } 163 const std::string& port() const { return port_; }
156 164
157 // Returns a string representing this instance. 165 // Returns a string representing this instance.
158 const std::string& GetAsString() const; 166 const std::string& GetAsString() const;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 205
198 // A bitmask containing the schemes which are considered valid for this 206 // A bitmask containing the schemes which are considered valid for this
199 // pattern. Parse() uses this to decide whether a pattern contains a valid 207 // pattern. Parse() uses this to decide whether a pattern contains a valid
200 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_ 208 // scheme. MatchesScheme uses this to decide whether a wildcard scheme_
201 // matches a given test scheme. 209 // matches a given test scheme.
202 int valid_schemes_; 210 int valid_schemes_;
203 211
204 // True if this is a special-case "<all_urls>" pattern. 212 // True if this is a special-case "<all_urls>" pattern.
205 bool match_all_urls_; 213 bool match_all_urls_;
206 214
215 // True if we match path_ against the full path of a nested URL, e.g.
216 // if given filesystem:http://a.com/temporary/foo.txt, use /temporary/foo.txt.
217 // Otherwise we match only against the path of a non-nested URL.
218 bool match_nested_url_path_;
219
207 // The scheme for the pattern. 220 // The scheme for the pattern.
208 std::string scheme_; 221 std::string scheme_;
209 222
210 // The host without any leading "*" components. 223 // The host without any leading "*" components.
211 std::string host_; 224 std::string host_;
212 225
213 // Whether we should match subdomains of the host. This is true if the first 226 // Whether we should match subdomains of the host. This is true if the first
214 // component of the pattern's host was "*". 227 // component of the pattern's host was "*".
215 bool match_subdomains_; 228 bool match_subdomains_;
216 229
217 // The port. 230 // The port.
218 std::string port_; 231 std::string port_;
219 232
220 // The path to match. This is everything after the host of the URL, or 233 // 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. 234 // everything after the scheme in the case of file:// URLs.
222 std::string path_; 235 std::string path_;
223 236
224 // The path with "?" and "\" characters escaped for use with the 237 // The path with "?" and "\" characters escaped for use with the
225 // MatchPattern() function. 238 // MatchPattern() function.
226 std::string path_escaped_; 239 std::string path_escaped_;
227 240
228 // A string representing this URLPattern. 241 // A string representing this URLPattern.
229 mutable std::string spec_; 242 mutable std::string spec_;
230 }; 243 };
231 244
232 typedef std::vector<URLPattern> URLPatternList; 245 typedef std::vector<URLPattern> URLPatternList;
233 246
234 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ 247 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698