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

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

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Fixed static non-pod, removed default params, fixed formatting, fixed nits, simplified code Created 3 years, 10 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
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 EXTENSIONS_COMMON_URL_PATTERN_H_ 4 #ifndef EXTENSIONS_COMMON_URL_PATTERN_H_
5 #define EXTENSIONS_COMMON_URL_PATTERN_H_ 5 #define EXTENSIONS_COMMON_URL_PATTERN_H_
6 6
7 #include <functional> 7 #include <functional>
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 URLPattern(const URLPattern& other); 96 URLPattern(const URLPattern& other);
97 ~URLPattern(); 97 ~URLPattern();
98 98
99 bool operator<(const URLPattern& other) const; 99 bool operator<(const URLPattern& other) const;
100 bool operator>(const URLPattern& other) const; 100 bool operator>(const URLPattern& other) const;
101 bool operator==(const URLPattern& other) const; 101 bool operator==(const URLPattern& other) const;
102 102
103 // Initializes this instance by parsing the provided string. Returns 103 // Initializes this instance by parsing the provided string. Returns
104 // URLPattern::PARSE_SUCCESS on success, or an error code otherwise. On 104 // URLPattern::PARSE_SUCCESS on success, or an error code otherwise. On
105 // failure, this instance will have some intermediate values and is in an 105 // failure, this instance will have some intermediate values and is in an
106 // invalid state. 106 // invalid state. If you want to allow the match pattern to specify a wildcard
107 // for the effective TLD, make |allow_wildcard_effective_tld| true.
107 ParseResult Parse(const std::string& pattern_str); 108 ParseResult Parse(const std::string& pattern_str);
109 ParseResult Parse(const std::string& pattern_str,
110 const bool allow_wildcard_effective_tld);
dcheng 2017/02/06 07:05:29 Nit: it's preferable to have explicitly named enum
nrpeter 2017/02/06 22:53:15 Done.
108 111
109 // Gets the bitmask of valid schemes. 112 // Gets the bitmask of valid schemes.
110 int valid_schemes() const { return valid_schemes_; } 113 int valid_schemes() const { return valid_schemes_; }
111 void SetValidSchemes(int valid_schemes); 114 void SetValidSchemes(int valid_schemes);
112 115
113 // Gets the host the pattern matches. This can be an empty string if the 116 // Gets the host the pattern matches. This can be an empty string if the
114 // pattern matches all hosts (the input was <scheme>://*/<whatever>). 117 // pattern matches all hosts (the input was <scheme>://*/<whatever>).
115 const std::string& host() const { return host_; } 118 const std::string& host() const { return host_; }
116 void SetHost(const std::string& host); 119 void SetHost(const std::string& host);
117 120
118 // Gets whether to match subdomains of host(). 121 // Gets whether to match subdomains of host().
119 bool match_subdomains() const { return match_subdomains_; } 122 bool match_subdomains() const { return match_subdomains_; }
120 void SetMatchSubdomains(bool val); 123 void SetMatchSubdomains(bool val);
121 124
125 // Gets whether host() contains an effective TLD. If false, durring
126 // a match, the URL you're comparing must have its TLD removed
127 // prior to comparison.
128 // e.g. For the match pattern https://google.com/*
129 // If this is true: host() would be google.com
130 // If this is false host() would be google
131 bool match_effective_tld() const { return match_effective_tld_; }
132 void SetMatchEffectiveTld(bool val);
133
122 // Gets the path the pattern matches with the leading slash. This can have 134 // Gets the path the pattern matches with the leading slash. This can have
123 // embedded asterisks which are interpreted using glob rules. 135 // embedded asterisks which are interpreted using glob rules.
124 const std::string& path() const { return path_; } 136 const std::string& path() const { return path_; }
125 void SetPath(const std::string& path); 137 void SetPath(const std::string& path);
126 138
127 // Returns true if this pattern matches all urls. 139 // Returns true if this pattern matches all urls.
128 bool match_all_urls() const { return match_all_urls_; } 140 bool match_all_urls() const { return match_all_urls_; }
129 void SetMatchAllURLs(bool val); 141 void SetMatchAllURLs(bool val);
130 142
131 // Sets the scheme for pattern matches. This can be a single '*' if the 143 // Sets the scheme for pattern matches. This can be a single '*' if the
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // The scheme for the pattern. 248 // The scheme for the pattern.
237 std::string scheme_; 249 std::string scheme_;
238 250
239 // The host without any leading "*" components. 251 // The host without any leading "*" components.
240 std::string host_; 252 std::string host_;
241 253
242 // Whether we should match subdomains of the host. This is true if the first 254 // Whether we should match subdomains of the host. This is true if the first
243 // component of the pattern's host was "*". 255 // component of the pattern's host was "*".
244 bool match_subdomains_; 256 bool match_subdomains_;
245 257
258 // Whether we should match the effective TLD of the host. This is true by
259 // default and only false if the the pattern's host ends with ".*"
260 // (e.g. https://example.*/*).
261 bool match_effective_tld_;
262
246 // The port. 263 // The port.
247 std::string port_; 264 std::string port_;
248 265
249 // The path to match. This is everything after the host of the URL, or 266 // The path to match. This is everything after the host of the URL, or
250 // everything after the scheme in the case of file:// URLs. 267 // everything after the scheme in the case of file:// URLs.
251 std::string path_; 268 std::string path_;
252 269
253 // The path with "?" and "\" characters escaped for use with the 270 // The path with "?" and "\" characters escaped for use with the
254 // MatchPattern() function. 271 // MatchPattern() function.
255 std::string path_escaped_; 272 std::string path_escaped_;
256 273
257 // A string representing this URLPattern. 274 // A string representing this URLPattern.
258 mutable std::string spec_; 275 mutable std::string spec_;
259 }; 276 };
260 277
261 std::ostream& operator<<(std::ostream& out, const URLPattern& url_pattern); 278 std::ostream& operator<<(std::ostream& out, const URLPattern& url_pattern);
262 279
263 typedef std::vector<URLPattern> URLPatternList; 280 typedef std::vector<URLPattern> URLPatternList;
264 281
265 #endif // EXTENSIONS_COMMON_URL_PATTERN_H_ 282 #endif // EXTENSIONS_COMMON_URL_PATTERN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698