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

Side by Side Diff: net/base/registry_controlled_domains/registry_controlled_domain.cc

Issue 1783813002: SameSite: Strict/Lax behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@strict-lax
Patch Set: Comment. Created 4 years, 9 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 // NB: Modelled after Mozilla's code (originally written by Pamela Greene, 5 // NB: Modelled after Mozilla's code (originally written by Pamela Greene,
6 // later modified by others), but almost entirely rewritten for Chrome. 6 // later modified by others), but almost entirely rewritten for Chrome.
7 // (netwerk/dns/src/nsEffectiveTLDService.cpp) 7 // (netwerk/dns/src/nsEffectiveTLDService.cpp)
8 /* ***** BEGIN LICENSE BLOCK ***** 8 /* ***** BEGIN LICENSE BLOCK *****
9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
10 * 10 *
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 46 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
47 47
48 #include "base/logging.h" 48 #include "base/logging.h"
49 #include "base/strings/string_util.h" 49 #include "base/strings/string_util.h"
50 #include "base/strings/utf_string_conversions.h" 50 #include "base/strings/utf_string_conversions.h"
51 #include "net/base/lookup_string_in_fixed_set.h" 51 #include "net/base/lookup_string_in_fixed_set.h"
52 #include "net/base/net_module.h" 52 #include "net/base/net_module.h"
53 #include "net/base/url_util.h" 53 #include "net/base/url_util.h"
54 #include "url/gurl.h" 54 #include "url/gurl.h"
55 #include "url/origin.h"
55 #include "url/third_party/mozilla/url_parse.h" 56 #include "url/third_party/mozilla/url_parse.h"
56 57
57 namespace net { 58 namespace net {
58 namespace registry_controlled_domains { 59 namespace registry_controlled_domains {
59 60
60 namespace { 61 namespace {
61 #include "net/base/registry_controlled_domains/effective_tld_names-inc.cc" 62 #include "net/base/registry_controlled_domains/effective_tld_names-inc.cc"
62 63
63 // See make_dafsa.py for documentation of the generated dafsa byte array. 64 // See make_dafsa.py for documentation of the generated dafsa byte array.
64 65
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // No domains. See if the hosts are identical. 209 // No domains. See if the hosts are identical.
209 const url::Component host1 = gurl1.parsed_for_possibly_invalid_spec().host; 210 const url::Component host1 = gurl1.parsed_for_possibly_invalid_spec().host;
210 const url::Component host2 = gurl2.parsed_for_possibly_invalid_spec().host; 211 const url::Component host2 = gurl2.parsed_for_possibly_invalid_spec().host;
211 if ((host1.len <= 0) || (host1.len != host2.len)) 212 if ((host1.len <= 0) || (host1.len != host2.len))
212 return false; 213 return false;
213 return !strncmp(gurl1.possibly_invalid_spec().data() + host1.begin, 214 return !strncmp(gurl1.possibly_invalid_spec().data() + host1.begin,
214 gurl2.possibly_invalid_spec().data() + host2.begin, 215 gurl2.possibly_invalid_spec().data() + host2.begin,
215 host1.len); 216 host1.len);
216 } 217 }
217 218
219 bool SameDomainOrHost(const url::Origin& origin1,
220 const url::Origin& origin2,
221 PrivateRegistryFilter filter) {
222 return SameDomainOrHost(GURL(origin1.Serialize()), GURL(origin2.Serialize()),
223 filter);
224 }
225
218 size_t GetRegistryLength( 226 size_t GetRegistryLength(
219 const GURL& gurl, 227 const GURL& gurl,
220 UnknownRegistryFilter unknown_filter, 228 UnknownRegistryFilter unknown_filter,
221 PrivateRegistryFilter private_filter) { 229 PrivateRegistryFilter private_filter) {
222 base::StringPiece host = gurl.host_piece(); 230 base::StringPiece host = gurl.host_piece();
223 if (host.empty()) 231 if (host.empty())
224 return std::string::npos; 232 return std::string::npos;
225 if (gurl.HostIsIPAddress()) 233 if (gurl.HostIsIPAddress())
226 return 0; 234 return 0;
227 return GetRegistryLengthImpl(host, unknown_filter, private_filter); 235 return GetRegistryLengthImpl(host, unknown_filter, private_filter);
(...skipping 18 matching lines...) Expand all
246 254
247 void SetFindDomainGraph(const unsigned char* domains, size_t length) { 255 void SetFindDomainGraph(const unsigned char* domains, size_t length) {
248 CHECK(domains); 256 CHECK(domains);
249 CHECK_NE(length, 0u); 257 CHECK_NE(length, 0u);
250 g_graph = domains; 258 g_graph = domains;
251 g_graph_length = length; 259 g_graph_length = length;
252 } 260 }
253 261
254 } // namespace registry_controlled_domains 262 } // namespace registry_controlled_domains
255 } // namespace net 263 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698