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

Side by Side Diff: content/renderer/webpublicsuffixlist_impl.cc

Issue 2433583002: Reduce buggy usage of the registry controlled domain service. (Closed)
Patch Set: . Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/webpublicsuffixlist_impl.h" 5 #include "content/renderer/webpublicsuffixlist_impl.h"
6 6
7 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 7 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
8 #include "net/base/url_util.h"
9 #include "url/url_canon.h"
8 10
9 namespace content { 11 namespace content {
10 12
11 WebPublicSuffixListImpl::~WebPublicSuffixListImpl() { 13 WebPublicSuffixListImpl::~WebPublicSuffixListImpl() {
12 } 14 }
13 15
14 size_t WebPublicSuffixListImpl::getPublicSuffixLength( 16 size_t WebPublicSuffixListImpl::getPublicSuffixLength(
15 const blink::WebString& host) { 17 const blink::WebString& host) {
16 size_t result = net::registry_controlled_domains::GetRegistryLength( 18 #ifndef NDEBUG
17 host.utf8(), 19 // Blink should only be calling us with canonical URLs.
18 net::registry_controlled_domains::INCLUDE_UNKNOWN_REGISTRIES, 20 url::CanonHostInfo host_info;
19 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 21 DCHECK_EQ(net::CanonicalizeHost(host.utf8(), &host_info), host.utf8());
22 #endif
23 size_t result =
24 net::registry_controlled_domains::GetRegistryLengthForCanonicalHost(
25 host.utf8(),
26 net::registry_controlled_domains::INCLUDE_UNKNOWN_REGISTRIES,
27 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
20 return result ? result : host.length(); 28 return result ? result : host.length();
21 } 29 }
22 30
23 } // namespace content 31 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698