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 |
11 #include <ostream> | 11 #include <ostream> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/compiler_specific.h" |
15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
16 | 17 |
17 class GURL; | 18 class GURL; |
18 | 19 |
19 namespace content_settings { | 20 namespace content_settings { |
20 class PatternParser; | 21 class PatternParser; |
21 } | 22 } |
22 | 23 |
23 namespace IPC { | 24 namespace IPC { |
24 class Message; | 25 class Message; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 friend class content_settings::PatternParser; | 193 friend class content_settings::PatternParser; |
193 friend class Builder; | 194 friend class Builder; |
194 FRIEND_TEST_ALL_PREFIXES(ContentSettingsPatternParserTest, SerializePatterns); | 195 FRIEND_TEST_ALL_PREFIXES(ContentSettingsPatternParserTest, SerializePatterns); |
195 | 196 |
196 class Builder : public BuilderInterface { | 197 class Builder : public BuilderInterface { |
197 public: | 198 public: |
198 explicit Builder(bool use_legacy_validate); | 199 explicit Builder(bool use_legacy_validate); |
199 virtual ~Builder(); | 200 virtual ~Builder(); |
200 | 201 |
201 // Overrides BuilderInterface | 202 // Overrides BuilderInterface |
202 virtual BuilderInterface* WithPort(const std::string& port); | 203 virtual BuilderInterface* WithPort(const std::string& port) OVERRIDE; |
203 | 204 |
204 virtual BuilderInterface* WithPortWildcard(); | 205 virtual BuilderInterface* WithPortWildcard() OVERRIDE; |
205 | 206 |
206 virtual BuilderInterface* WithHost(const std::string& host); | 207 virtual BuilderInterface* WithHost(const std::string& host) OVERRIDE; |
207 | 208 |
208 virtual BuilderInterface* WithDomainWildcard(); | 209 virtual BuilderInterface* WithDomainWildcard() OVERRIDE; |
209 | 210 |
210 virtual BuilderInterface* WithScheme(const std::string& scheme); | 211 virtual BuilderInterface* WithScheme(const std::string& scheme) OVERRIDE; |
211 | 212 |
212 virtual BuilderInterface* WithSchemeWildcard(); | 213 virtual BuilderInterface* WithSchemeWildcard() OVERRIDE; |
213 | 214 |
214 virtual BuilderInterface* WithPath(const std::string& path); | 215 virtual BuilderInterface* WithPath(const std::string& path) OVERRIDE; |
215 | 216 |
216 virtual BuilderInterface* Invalid(); | 217 virtual BuilderInterface* Invalid() OVERRIDE; |
217 | 218 |
218 virtual ContentSettingsPattern Build(); | 219 virtual ContentSettingsPattern Build() OVERRIDE; |
219 private: | 220 private: |
220 // Canonicalizes the pattern parts so that they are ASCII only, either | 221 // Canonicalizes the pattern parts so that they are ASCII only, either |
221 // in original (if it was already ASCII) or punycode form. | 222 // in original (if it was already ASCII) or punycode form. |
222 static void Canonicalize(PatternParts* parts); | 223 static void Canonicalize(PatternParts* parts); |
223 | 224 |
224 // Returns true when the pattern |parts| represent a valid pattern. | 225 // Returns true when the pattern |parts| represent a valid pattern. |
225 static bool Validate(const PatternParts& parts); | 226 static bool Validate(const PatternParts& parts); |
226 | 227 |
227 static bool LegacyValidate(const PatternParts& parts); | 228 static bool LegacyValidate(const PatternParts& parts); |
228 | 229 |
(...skipping 28 matching lines...) Expand all Loading... |
257 }; | 258 }; |
258 | 259 |
259 // Stream operator so ContentSettingsPattern can be used in assertion | 260 // Stream operator so ContentSettingsPattern can be used in assertion |
260 // statements. | 261 // statements. |
261 inline std::ostream& operator<<( | 262 inline std::ostream& operator<<( |
262 std::ostream& out, const ContentSettingsPattern& pattern) { | 263 std::ostream& out, const ContentSettingsPattern& pattern) { |
263 return out << pattern.ToString(); | 264 return out << pattern.ToString(); |
264 } | 265 } |
265 | 266 |
266 #endif // CHROME_COMMON_CONTENT_SETTINGS_PATTERN_H_ | 267 #endif // CHROME_COMMON_CONTENT_SETTINGS_PATTERN_H_ |
OLD | NEW |