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

Side by Side Diff: chrome/browser/google/google_util.cc

Issue 13979002: Add support for split PSL list distinctions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed chrome_frame compilation issue Created 7 years, 8 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 | Annotate | Revision Log
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 #include "chrome/browser/google/google_util.h" 5 #include "chrome/browser/google/google_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 std::string StringAppendGoogleLocaleParam(const std::string& url) { 86 std::string StringAppendGoogleLocaleParam(const std::string& url) {
87 GURL original_url(url); 87 GURL original_url(url);
88 DCHECK(original_url.is_valid()); 88 DCHECK(original_url.is_valid());
89 GURL localized_url = AppendGoogleLocaleParam(original_url); 89 GURL localized_url = AppendGoogleLocaleParam(original_url);
90 return localized_url.spec(); 90 return localized_url.spec();
91 } 91 }
92 92
93 GURL AppendGoogleTLDParam(Profile* profile, const GURL& url) { 93 GURL AppendGoogleTLDParam(Profile* profile, const GURL& url) {
94 const std::string google_domain( 94 const std::string google_domain(
95 net::RegistryControlledDomainService::GetDomainAndRegistry( 95 net::RegistryControlledDomainService::GetDomainAndRegistry(
96 GoogleURLTracker::GoogleURL(profile))); 96 GoogleURLTracker::GoogleURL(profile),
97 net::RCDS::EXCLUDE_PRIVATE_REGISTRIES));
97 const size_t first_dot = google_domain.find('.'); 98 const size_t first_dot = google_domain.find('.');
98 if (first_dot == std::string::npos) { 99 if (first_dot == std::string::npos) {
99 NOTREACHED(); 100 NOTREACHED();
100 return url; 101 return url;
101 } 102 }
102 return net::AppendQueryParameter(url, "sd", 103 return net::AppendQueryParameter(url, "sd",
103 google_domain.substr(first_dot + 1)); 104 google_domain.substr(first_dot + 1));
104 } 105 }
105 106
106 #if defined(OS_WIN) 107 #if defined(OS_WIN)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 172 }
172 173
173 return (original_url.port().empty() || 174 return (original_url.port().empty() ||
174 port_permission == ALLOW_NON_STANDARD_PORTS) && 175 port_permission == ALLOW_NON_STANDARD_PORTS) &&
175 google_util::IsGoogleHostname(original_url.host(), subdomain_permission); 176 google_util::IsGoogleHostname(original_url.host(), subdomain_permission);
176 } 177 }
177 178
178 bool IsGoogleHostname(const std::string& host, 179 bool IsGoogleHostname(const std::string& host,
179 SubdomainPermission subdomain_permission) { 180 SubdomainPermission subdomain_permission) {
180 size_t tld_length = 181 size_t tld_length =
181 net::RegistryControlledDomainService::GetRegistryLength(host, false); 182 net::RegistryControlledDomainService::GetRegistryLength(
183 host,
184 net::RCDS::EXCLUDE_UNKNOWN_REGISTRIES,
185 net::RCDS::EXCLUDE_PRIVATE_REGISTRIES);
182 if ((tld_length == 0) || (tld_length == std::string::npos)) 186 if ((tld_length == 0) || (tld_length == std::string::npos))
183 return false; 187 return false;
184 std::string host_minus_tld(host, 0, host.length() - tld_length); 188 std::string host_minus_tld(host, 0, host.length() - tld_length);
185 if (LowerCaseEqualsASCII(host_minus_tld, "google.")) 189 if (LowerCaseEqualsASCII(host_minus_tld, "google."))
186 return true; 190 return true;
187 if (subdomain_permission == ALLOW_SUBDOMAIN) 191 if (subdomain_permission == ALLOW_SUBDOMAIN)
188 return EndsWith(host_minus_tld, ".google.", false); 192 return EndsWith(host_minus_tld, ".google.", false);
189 return LowerCaseEqualsASCII(host_minus_tld, "www.google."); 193 return LowerCaseEqualsASCII(host_minus_tld, "www.google.");
190 } 194 }
191 195
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 const char* const kBrands[] = { 295 const char* const kBrands[] = {
292 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", 296 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE",
293 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", 297 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM",
294 }; 298 };
295 const char* const* end = &kBrands[arraysize(kBrands)]; 299 const char* const* end = &kBrands[arraysize(kBrands)];
296 const char* const* found = std::find(&kBrands[0], end, brand); 300 const char* const* found = std::find(&kBrands[0], end, brand);
297 return found != end; 301 return found != end;
298 } 302 }
299 303
300 } // namespace google_util 304 } // namespace google_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698