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

Side by Side Diff: components/content_settings/core/common/content_settings_pattern.h

Issue 2250713003: Add metrics for schemes of content setting exceptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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 4
5 // Patterns used in content setting rules. 5 // Patterns used in content setting rules.
6 6
7 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ 7 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_
8 #define COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ 8 #define COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // Pattern A and B have an intersection. But pattern A has a higher 46 // Pattern A and B have an intersection. But pattern A has a higher
47 // precedence than pattern B for URLs that are matched by both pattern. 47 // precedence than pattern B for URLs that are matched by both pattern.
48 enum Relation { 48 enum Relation {
49 DISJOINT_ORDER_POST = -2, 49 DISJOINT_ORDER_POST = -2,
50 SUCCESSOR = -1, 50 SUCCESSOR = -1,
51 IDENTITY = 0, 51 IDENTITY = 0,
52 PREDECESSOR = 1, 52 PREDECESSOR = 1,
53 DISJOINT_ORDER_PRE = 2, 53 DISJOINT_ORDER_PRE = 2,
54 }; 54 };
55 55
56 // This enum is used to back an UMA histogram, the order of existing values
57 // should not be changed. New values should only append before SCHEME_MAX.
58 // Also keep it consistent with kSchemeNames in content_settings_pattern.cc.
59 enum SchemeType {
60 SCHEME_WILDCARD,
61 SCHEME_OTHER,
62 SCHEME_HTTP,
63 SCHEME_HTTPS,
64 SCHEME_FILE,
65 SCHEME_CHROMEEXTENSION,
66 SCHEME_MAX,
67 };
68
56 struct PatternParts { 69 struct PatternParts {
57 PatternParts(); 70 PatternParts();
58 PatternParts(const PatternParts& other); 71 PatternParts(const PatternParts& other);
59 ~PatternParts(); 72 ~PatternParts();
60 73
61 // Lowercase string of the URL scheme to match. This string is empty if the 74 // Lowercase string of the URL scheme to match. This string is empty if the
62 // |is_scheme_wildcard| flag is set. 75 // |is_scheme_wildcard| flag is set.
63 std::string scheme; 76 std::string scheme;
64 77
65 // True if the scheme wildcard is set. 78 // True if the scheme wildcard is set.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 176
164 // True if |url| matches this pattern. 177 // True if |url| matches this pattern.
165 bool Matches(const GURL& url) const; 178 bool Matches(const GURL& url) const;
166 179
167 // True if this pattern matches all hosts (i.e. it has a host wildcard). 180 // True if this pattern matches all hosts (i.e. it has a host wildcard).
168 bool MatchesAllHosts() const; 181 bool MatchesAllHosts() const;
169 182
170 // Returns a std::string representation of this pattern. 183 // Returns a std::string representation of this pattern.
171 std::string ToString() const; 184 std::string ToString() const;
172 185
186 // Returns scheme type of pattern.
187 ContentSettingsPattern::SchemeType GetScheme() const;
188
173 // Compares the pattern with a given |other| pattern and returns the 189 // Compares the pattern with a given |other| pattern and returns the
174 // |Relation| of the two patterns. 190 // |Relation| of the two patterns.
175 Relation Compare(const ContentSettingsPattern& other) const; 191 Relation Compare(const ContentSettingsPattern& other) const;
176 192
177 // Returns true if the pattern and the |other| pattern are identical. 193 // Returns true if the pattern and the |other| pattern are identical.
178 bool operator==(const ContentSettingsPattern& other) const; 194 bool operator==(const ContentSettingsPattern& other) const;
179 195
180 // Returns true if the pattern and the |other| pattern are not identical. 196 // Returns true if the pattern and the |other| pattern are not identical.
181 bool operator!=(const ContentSettingsPattern& other) const; 197 bool operator!=(const ContentSettingsPattern& other) const;
182 198
(...skipping 27 matching lines...) Expand all
210 const ContentSettingsPattern::PatternParts& other_parts); 226 const ContentSettingsPattern::PatternParts& other_parts);
211 227
212 ContentSettingsPattern(const PatternParts& parts, bool valid); 228 ContentSettingsPattern(const PatternParts& parts, bool valid);
213 229
214 PatternParts parts_; 230 PatternParts parts_;
215 231
216 bool is_valid_; 232 bool is_valid_;
217 }; 233 };
218 234
219 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ 235 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698