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

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

Issue 2582203003: Convert SetContentSettingRules to use mojo, part 1/2. (Closed)
Patch Set: Convert SetContentSettingRules to use mojo, part 1/2. Created 3 years, 11 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>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "mojo/public/cpp/bindings/struct_traits.h"
13 14
14 class GURL; 15 class GURL;
15 16
16 namespace content_settings { 17 namespace content_settings {
17 class PatternParser; 18 class PatternParser;
19
20 namespace mojom {
21 class ContentSettingsPatternDataView;
22 }
18 } 23 }
19 24
20 // A pattern used in content setting rules. See |IsValid| for a description of 25 // A pattern used in content setting rules. See |IsValid| for a description of
21 // possible patterns. 26 // possible patterns.
22 class ContentSettingsPattern { 27 class ContentSettingsPattern {
23 public: 28 public:
24 // Each content settings pattern describes a set of origins. Patterns, and the 29 // Each content settings pattern describes a set of origins. Patterns, and the
25 // sets they describe, have specific relations. |Relation| describes the 30 // sets they describe, have specific relations. |Relation| describes the
26 // relation of two patterns A and B. When pattern A is compared with pattern B 31 // relation of two patterns A and B. When pattern A is compared with pattern B
27 // (A compare B) interesting relations are: 32 // (A compare B) interesting relations are:
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 215
211 // Returns true if the pattern has a lower priority than the |other| pattern. 216 // Returns true if the pattern has a lower priority than the |other| pattern.
212 bool operator<(const ContentSettingsPattern& other) const; 217 bool operator<(const ContentSettingsPattern& other) const;
213 218
214 // Returns true if the pattern has a higher priority than the |other| pattern. 219 // Returns true if the pattern has a higher priority than the |other| pattern.
215 bool operator>(const ContentSettingsPattern& other) const; 220 bool operator>(const ContentSettingsPattern& other) const;
216 221
217 private: 222 private:
218 friend class content_settings::PatternParser; 223 friend class content_settings::PatternParser;
219 friend class ContentSettingsPatternSerializer; 224 friend class ContentSettingsPatternSerializer;
225 friend struct mojo::StructTraits<
226 content_settings::mojom::ContentSettingsPatternDataView,
227 ContentSettingsPattern>;
220 FRIEND_TEST_ALL_PREFIXES(ContentSettingsPatternParserTest, SerializePatterns); 228 FRIEND_TEST_ALL_PREFIXES(ContentSettingsPatternParserTest, SerializePatterns);
221 229
222 class Builder; 230 class Builder;
223 231
224 static Relation CompareScheme( 232 static Relation CompareScheme(
225 const ContentSettingsPattern::PatternParts& parts, 233 const ContentSettingsPattern::PatternParts& parts,
226 const ContentSettingsPattern::PatternParts& other_parts); 234 const ContentSettingsPattern::PatternParts& other_parts);
227 235
228 static Relation CompareHost( 236 static Relation CompareHost(
229 const ContentSettingsPattern::PatternParts& parts, 237 const ContentSettingsPattern::PatternParts& parts,
230 const ContentSettingsPattern::PatternParts& other_parts); 238 const ContentSettingsPattern::PatternParts& other_parts);
231 239
232 static Relation ComparePort( 240 static Relation ComparePort(
233 const ContentSettingsPattern::PatternParts& parts, 241 const ContentSettingsPattern::PatternParts& parts,
234 const ContentSettingsPattern::PatternParts& other_parts); 242 const ContentSettingsPattern::PatternParts& other_parts);
235 243
236 static Relation ComparePath( 244 static Relation ComparePath(
237 const ContentSettingsPattern::PatternParts& parts, 245 const ContentSettingsPattern::PatternParts& parts,
238 const ContentSettingsPattern::PatternParts& other_parts); 246 const ContentSettingsPattern::PatternParts& other_parts);
239 247
240 ContentSettingsPattern(const PatternParts& parts, bool valid); 248 ContentSettingsPattern(const PatternParts& parts, bool valid);
241 249
242 PatternParts parts_; 250 PatternParts parts_;
243 251
244 bool is_valid_; 252 bool is_valid_;
245 }; 253 };
246 254
247 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ 255 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698