OLD | NEW |
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 #include "components/content_settings/core/common/content_settings_pattern.h" | 5 #include "components/content_settings/core/common/content_settings_pattern.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // //////////////////////////////////////////////////////////////////////////// | 83 // //////////////////////////////////////////////////////////////////////////// |
84 // ContentSettingsPattern::Builder | 84 // ContentSettingsPattern::Builder |
85 // | 85 // |
86 class ContentSettingsPattern::Builder : | 86 class ContentSettingsPattern::Builder : |
87 public ContentSettingsPattern::BuilderInterface { | 87 public ContentSettingsPattern::BuilderInterface { |
88 public: | 88 public: |
89 explicit Builder(bool use_legacy_validate); | 89 explicit Builder(bool use_legacy_validate); |
90 virtual ~Builder(); | 90 virtual ~Builder(); |
91 | 91 |
92 // BuilderInterface: | 92 // BuilderInterface: |
93 virtual BuilderInterface* WithPort(const std::string& port) OVERRIDE; | 93 virtual BuilderInterface* WithPort(const std::string& port) override; |
94 virtual BuilderInterface* WithPortWildcard() OVERRIDE; | 94 virtual BuilderInterface* WithPortWildcard() override; |
95 virtual BuilderInterface* WithHost(const std::string& host) OVERRIDE; | 95 virtual BuilderInterface* WithHost(const std::string& host) override; |
96 virtual BuilderInterface* WithDomainWildcard() OVERRIDE; | 96 virtual BuilderInterface* WithDomainWildcard() override; |
97 virtual BuilderInterface* WithScheme(const std::string& scheme) OVERRIDE; | 97 virtual BuilderInterface* WithScheme(const std::string& scheme) override; |
98 virtual BuilderInterface* WithSchemeWildcard() OVERRIDE; | 98 virtual BuilderInterface* WithSchemeWildcard() override; |
99 virtual BuilderInterface* WithPath(const std::string& path) OVERRIDE; | 99 virtual BuilderInterface* WithPath(const std::string& path) override; |
100 virtual BuilderInterface* WithPathWildcard() OVERRIDE; | 100 virtual BuilderInterface* WithPathWildcard() override; |
101 virtual BuilderInterface* Invalid() OVERRIDE; | 101 virtual BuilderInterface* Invalid() override; |
102 virtual ContentSettingsPattern Build() OVERRIDE; | 102 virtual ContentSettingsPattern Build() override; |
103 | 103 |
104 private: | 104 private: |
105 // Canonicalizes the pattern parts so that they are ASCII only, either | 105 // Canonicalizes the pattern parts so that they are ASCII only, either |
106 // in original (if it was already ASCII) or punycode form. Returns true if | 106 // in original (if it was already ASCII) or punycode form. Returns true if |
107 // the canonicalization was successful. | 107 // the canonicalization was successful. |
108 static bool Canonicalize(PatternParts* parts); | 108 static bool Canonicalize(PatternParts* parts); |
109 | 109 |
110 // Returns true when the pattern |parts| represent a valid pattern. | 110 // Returns true when the pattern |parts| represent a valid pattern. |
111 static bool Validate(const PatternParts& parts); | 111 static bool Validate(const PatternParts& parts); |
112 | 112 |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) | 702 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) |
703 return ContentSettingsPattern::PREDECESSOR; | 703 return ContentSettingsPattern::PREDECESSOR; |
704 | 704 |
705 int result = parts.port.compare(other_parts.port); | 705 int result = parts.port.compare(other_parts.port); |
706 if (result == 0) | 706 if (result == 0) |
707 return ContentSettingsPattern::IDENTITY; | 707 return ContentSettingsPattern::IDENTITY; |
708 if (result > 0) | 708 if (result > 0) |
709 return ContentSettingsPattern::DISJOINT_ORDER_PRE; | 709 return ContentSettingsPattern::DISJOINT_ORDER_PRE; |
710 return ContentSettingsPattern::DISJOINT_ORDER_POST; | 710 return ContentSettingsPattern::DISJOINT_ORDER_POST; |
711 } | 711 } |
OLD | NEW |