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

Side by Side Diff: components/ssl_errors/error_classification.cc

Issue 2939423003: URL Formatter: Add StripSubdomain method that preserves eTLD + 1. (Closed)
Patch Set: Return std::string instead of base::StringPiece (which makes no sense) Created 3 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ssl_errors/error_classification.h" 5 #include "components/ssl_errors/error_classification.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 dns_name.length() == host_name.length() || 287 dns_name.length() == host_name.length() ||
288 !HostNameHasKnownTLD(dns_name)) { 288 !HostNameHasKnownTLD(dns_name)) {
289 continue; 289 continue;
290 } else if (dns_name.length() > host_name.length()) { 290 } else if (dns_name.length() > host_name.length()) {
291 if (url_formatter::StripWWW(base::ASCIIToUTF16(dns_name)) == 291 if (url_formatter::StripWWW(base::ASCIIToUTF16(dns_name)) ==
292 base::ASCIIToUTF16(host_name)) { 292 base::ASCIIToUTF16(host_name)) {
293 *www_match_host_name = dns_name; 293 *www_match_host_name = dns_name;
294 return true; 294 return true;
295 } 295 }
296 } else { 296 } else {
297 if (url_formatter::StripWWW(base::ASCIIToUTF16(host_name)) == 297 if (url_formatter::StripSubdomains(
298 base::ASCIIToUTF16(dns_name)) { 298 request_url, url_formatter::kStripWWW) == dns_name) {
299 *www_match_host_name = dns_name; 299 *www_match_host_name = dns_name;
300 return true; 300 return true;
301 } 301 }
302 } 302 }
303 } 303 }
304 } 304 }
305 return false; 305 return false;
306 } 306 }
307 307
308 bool NameUnderAnyNames(const HostnameTokens& child, 308 bool NameUnderAnyNames(const HostnameTokens& child,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 return std::find(dns_names_domain.begin(), dns_names_domain.end() - 1, 464 return std::find(dns_names_domain.begin(), dns_names_domain.end() - 1,
465 host_name_domain) != dns_names_domain.end() - 1; 465 host_name_domain) != dns_names_domain.end() - 1;
466 } 466 }
467 467
468 bool IsHostnameNonUniqueOrDotless(const std::string& hostname) { 468 bool IsHostnameNonUniqueOrDotless(const std::string& hostname) {
469 return net::IsHostnameNonUnique(hostname) || 469 return net::IsHostnameNonUnique(hostname) ||
470 hostname.find('.') == std::string::npos; 470 hostname.find('.') == std::string::npos;
471 } 471 }
472 472
473 } // namespace ssl_errors 473 } // namespace ssl_errors
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service_sync_unittest.cc ('k') | components/url_formatter/url_formatter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698