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

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

Issue 1895993003: Add migration code to change existing domain scoped content settings to be origin scoped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 // The version of the pattern format implemented. 123 // The version of the pattern format implemented.
124 static const int kContentSettingsPatternVersion; 124 static const int kContentSettingsPatternVersion;
125 125
126 // Returns a wildcard content settings pattern that matches all possible valid 126 // Returns a wildcard content settings pattern that matches all possible valid
127 // origins. 127 // origins.
128 static ContentSettingsPattern Wildcard(); 128 static ContentSettingsPattern Wildcard();
129 129
130 // Returns a pattern that matches the scheme and host of this URL, as well as 130 // Returns a pattern that matches the scheme and host of this URL, as well as
131 // all subdomains and ports. 131 // all subdomains and ports.
132 // TODO(lshang): Remove this when crbug.com/604612 is done.
132 static ContentSettingsPattern FromURL(const GURL& url); 133 static ContentSettingsPattern FromURL(const GURL& url);
133 134
134 // Returns a pattern that matches exactly this URL. 135 // Returns a pattern that matches exactly this URL.
135 static ContentSettingsPattern FromURLNoWildcard(const GURL& url); 136 static ContentSettingsPattern FromURLNoWildcard(const GURL& url);
136 137
137 // Returns a pattern that matches the given pattern specification. 138 // Returns a pattern that matches the given pattern specification.
138 // Valid patterns specifications are: 139 // Valid patterns specifications are:
139 // - [*.]domain.tld (matches domain.tld and all sub-domains) 140 // - [*.]domain.tld (matches domain.tld and all sub-domains)
140 // - host (matches an exact hostname) 141 // - host (matches an exact hostname)
141 // - scheme://host:port (supported schemes: http,https) 142 // - scheme://host:port (supported schemes: http,https)
142 // - scheme://[*.]domain.tld:port (supported schemes: http,https) 143 // - scheme://[*.]domain.tld:port (supported schemes: http,https)
143 // - file://path (The path has to be an absolute path and start with a '/') 144 // - file://path (The path has to be an absolute path and start with a '/')
144 // - a.b.c.d (matches an exact IPv4 ip) 145 // - a.b.c.d (matches an exact IPv4 ip)
145 // - [a:b:c:d:e:f:g:h] (matches an exact IPv6 ip) 146 // - [a:b:c:d:e:f:g:h] (matches an exact IPv6 ip)
146 static ContentSettingsPattern FromString(const std::string& pattern_spec); 147 static ContentSettingsPattern FromString(const std::string& pattern_spec);
147 148
149 // Migrate domain scoped settings generated using FromURL() to be origin
150 // scoped. Return false if domain_pattern is not generated using FromURL().
151 // TODO(lshang): Remove this when migration is done. https://crbug.com/604612
152 static bool MigrateFromDomainToOrigin(
153 const ContentSettingsPattern& domain_pattern,
154 ContentSettingsPattern* origin_pattern);
155
148 // Sets the scheme that doesn't support domain wildcard and port. 156 // Sets the scheme that doesn't support domain wildcard and port.
149 // Needs to be called by the embedder before using ContentSettingsPattern. 157 // Needs to be called by the embedder before using ContentSettingsPattern.
150 // |scheme| can't be NULL, and the pointed string must remain alive until the 158 // |scheme| can't be NULL, and the pointed string must remain alive until the
151 // app terminates. 159 // app terminates.
152 static void SetNonWildcardDomainNonPortScheme(const char* scheme); 160 static void SetNonWildcardDomainNonPortScheme(const char* scheme);
153 161
154 // Compares |scheme| against the scheme set by the embedder. 162 // Compares |scheme| against the scheme set by the embedder.
155 static bool IsNonWildcardDomainNonPortScheme(const std::string& scheme); 163 static bool IsNonWildcardDomainNonPortScheme(const std::string& scheme);
156 164
157 // Constructs an empty pattern. Empty patterns are invalid patterns. Invalid 165 // Constructs an empty pattern. Empty patterns are invalid patterns. Invalid
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 const ContentSettingsPattern::PatternParts& other_parts); 218 const ContentSettingsPattern::PatternParts& other_parts);
211 219
212 ContentSettingsPattern(const PatternParts& parts, bool valid); 220 ContentSettingsPattern(const PatternParts& parts, bool valid);
213 221
214 PatternParts parts_; 222 PatternParts parts_;
215 223
216 bool is_valid_; 224 bool is_valid_;
217 }; 225 };
218 226
219 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ 227 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698