OLD | NEW |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
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::registry_controlled_domains::GetDomainAndRegistry( |
96 GoogleURLTracker::GoogleURL(profile))); | 96 GoogleURLTracker::GoogleURL(profile), |
| 97 net::registry_controlled_domains::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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return true; | 171 return true; |
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 = net::registry_controlled_domains::GetRegistryLength( |
181 net::RegistryControlledDomainService::GetRegistryLength(host, false); | 182 host, |
| 183 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| 184 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
182 if ((tld_length == 0) || (tld_length == std::string::npos)) | 185 if ((tld_length == 0) || (tld_length == std::string::npos)) |
183 return false; | 186 return false; |
184 std::string host_minus_tld(host, 0, host.length() - tld_length); | 187 std::string host_minus_tld(host, 0, host.length() - tld_length); |
185 if (LowerCaseEqualsASCII(host_minus_tld, "google.")) | 188 if (LowerCaseEqualsASCII(host_minus_tld, "google.")) |
186 return true; | 189 return true; |
187 if (subdomain_permission == ALLOW_SUBDOMAIN) | 190 if (subdomain_permission == ALLOW_SUBDOMAIN) |
188 return EndsWith(host_minus_tld, ".google.", false); | 191 return EndsWith(host_minus_tld, ".google.", false); |
189 return LowerCaseEqualsASCII(host_minus_tld, "www.google."); | 192 return LowerCaseEqualsASCII(host_minus_tld, "www.google."); |
190 } | 193 } |
191 | 194 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 const char* const kBrands[] = { | 294 const char* const kBrands[] = { |
292 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", | 295 "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", |
293 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", | 296 "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", |
294 }; | 297 }; |
295 const char* const* end = &kBrands[arraysize(kBrands)]; | 298 const char* const* end = &kBrands[arraysize(kBrands)]; |
296 const char* const* found = std::find(&kBrands[0], end, brand); | 299 const char* const* found = std::find(&kBrands[0], end, brand); |
297 return found != end; | 300 return found != end; |
298 } | 301 } |
299 | 302 |
300 } // namespace google_util | 303 } // namespace google_util |
OLD | NEW |