| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_COMMON_CONTENT_SETTINGS_PATTERN_H_ | 7 #ifndef CHROME_COMMON_CONTENT_SETTINGS_PATTERN_H_ |
| 8 #define CHROME_COMMON_CONTENT_SETTINGS_PATTERN_H_ | 8 #define CHROME_COMMON_CONTENT_SETTINGS_PATTERN_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // |is_port_wildcard| flag is set. | 86 // |is_port_wildcard| flag is set. |
| 87 std::string port; | 87 std::string port; |
| 88 | 88 |
| 89 // True if the port wildcard is set. | 89 // True if the port wildcard is set. |
| 90 bool is_port_wildcard; | 90 bool is_port_wildcard; |
| 91 | 91 |
| 92 // TODO(markusheintz): Needed for legacy reasons. Remove. Path | 92 // TODO(markusheintz): Needed for legacy reasons. Remove. Path |
| 93 // specification. Only used for content settings pattern with a "file" | 93 // specification. Only used for content settings pattern with a "file" |
| 94 // scheme part. | 94 // scheme part. |
| 95 std::string path; | 95 std::string path; |
| 96 |
| 97 // True if the path wildcard is set. |
| 98 bool is_path_wildcard; |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 class BuilderInterface { | 101 class BuilderInterface { |
| 99 public: | 102 public: |
| 100 virtual ~BuilderInterface() {} | 103 virtual ~BuilderInterface() {} |
| 101 | 104 |
| 102 virtual BuilderInterface* WithPort(const std::string& port) = 0; | 105 virtual BuilderInterface* WithPort(const std::string& port) = 0; |
| 103 | 106 |
| 104 virtual BuilderInterface* WithPortWildcard() = 0; | 107 virtual BuilderInterface* WithPortWildcard() = 0; |
| 105 | 108 |
| 106 virtual BuilderInterface* WithHost(const std::string& host) = 0; | 109 virtual BuilderInterface* WithHost(const std::string& host) = 0; |
| 107 | 110 |
| 108 virtual BuilderInterface* WithDomainWildcard() = 0; | 111 virtual BuilderInterface* WithDomainWildcard() = 0; |
| 109 | 112 |
| 110 virtual BuilderInterface* WithScheme(const std::string& scheme) = 0; | 113 virtual BuilderInterface* WithScheme(const std::string& scheme) = 0; |
| 111 | 114 |
| 112 virtual BuilderInterface* WithSchemeWildcard() = 0; | 115 virtual BuilderInterface* WithSchemeWildcard() = 0; |
| 113 | 116 |
| 114 virtual BuilderInterface* WithPath(const std::string& path) = 0; | 117 virtual BuilderInterface* WithPath(const std::string& path) = 0; |
| 115 | 118 |
| 119 virtual BuilderInterface* WithPathWildcard() = 0; |
| 120 |
| 116 virtual BuilderInterface* Invalid() = 0; | 121 virtual BuilderInterface* Invalid() = 0; |
| 117 | 122 |
| 118 // Returns a content settings pattern according to the current configuration | 123 // Returns a content settings pattern according to the current configuration |
| 119 // of the builder. | 124 // of the builder. |
| 120 virtual ContentSettingsPattern Build() = 0; | 125 virtual ContentSettingsPattern Build() = 0; |
| 121 }; | 126 }; |
| 122 | 127 |
| 123 static BuilderInterface* CreateBuilder(bool use_legacy_validate); | 128 static BuilderInterface* CreateBuilder(bool use_legacy_validate); |
| 124 | 129 |
| 125 // The version of the pattern format implemented. | 130 // The version of the pattern format implemented. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 virtual BuilderInterface* WithHost(const std::string& host) OVERRIDE; | 212 virtual BuilderInterface* WithHost(const std::string& host) OVERRIDE; |
| 208 | 213 |
| 209 virtual BuilderInterface* WithDomainWildcard() OVERRIDE; | 214 virtual BuilderInterface* WithDomainWildcard() OVERRIDE; |
| 210 | 215 |
| 211 virtual BuilderInterface* WithScheme(const std::string& scheme) OVERRIDE; | 216 virtual BuilderInterface* WithScheme(const std::string& scheme) OVERRIDE; |
| 212 | 217 |
| 213 virtual BuilderInterface* WithSchemeWildcard() OVERRIDE; | 218 virtual BuilderInterface* WithSchemeWildcard() OVERRIDE; |
| 214 | 219 |
| 215 virtual BuilderInterface* WithPath(const std::string& path) OVERRIDE; | 220 virtual BuilderInterface* WithPath(const std::string& path) OVERRIDE; |
| 216 | 221 |
| 222 virtual BuilderInterface* WithPathWildcard() OVERRIDE; |
| 223 |
| 217 virtual BuilderInterface* Invalid() OVERRIDE; | 224 virtual BuilderInterface* Invalid() OVERRIDE; |
| 218 | 225 |
| 219 virtual ContentSettingsPattern Build() OVERRIDE; | 226 virtual ContentSettingsPattern Build() OVERRIDE; |
| 227 |
| 220 private: | 228 private: |
| 221 // Canonicalizes the pattern parts so that they are ASCII only, either | 229 // Canonicalizes the pattern parts so that they are ASCII only, either |
| 222 // in original (if it was already ASCII) or punycode form. Returns true if | 230 // in original (if it was already ASCII) or punycode form. Returns true if |
| 223 // the canonicalization was successful. | 231 // the canonicalization was successful. |
| 224 static bool Canonicalize(PatternParts* parts); | 232 static bool Canonicalize(PatternParts* parts); |
| 225 | 233 |
| 226 // Returns true when the pattern |parts| represent a valid pattern. | 234 // Returns true when the pattern |parts| represent a valid pattern. |
| 227 static bool Validate(const PatternParts& parts); | 235 static bool Validate(const PatternParts& parts); |
| 228 | 236 |
| 229 static bool LegacyValidate(const PatternParts& parts); | 237 static bool LegacyValidate(const PatternParts& parts); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 259 }; | 267 }; |
| 260 | 268 |
| 261 // Stream operator so ContentSettingsPattern can be used in assertion | 269 // Stream operator so ContentSettingsPattern can be used in assertion |
| 262 // statements. | 270 // statements. |
| 263 inline std::ostream& operator<<( | 271 inline std::ostream& operator<<( |
| 264 std::ostream& out, const ContentSettingsPattern& pattern) { | 272 std::ostream& out, const ContentSettingsPattern& pattern) { |
| 265 return out << pattern.ToString(); | 273 return out << pattern.ToString(); |
| 266 } | 274 } |
| 267 | 275 |
| 268 #endif // CHROME_COMMON_CONTENT_SETTINGS_PATTERN_H_ | 276 #endif // CHROME_COMMON_CONTENT_SETTINGS_PATTERN_H_ |
| OLD | NEW |