Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/google/core/browser/google_util.h" | 5 #include "components/google/core/browser/google_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "components/google/core/browser/google_switches.h" | 20 #include "components/google/core/browser/google_switches.h" |
| 20 #include "components/google/core/browser/google_tld_list.h" | 21 #include "components/google/core/browser/google_tld_list.h" |
| 21 #include "components/google/core/browser/google_url_tracker.h" | 22 #include "components/google/core/browser/google_url_tracker.h" |
| 22 #include "components/url_formatter/url_fixer.h" | 23 #include "components/url_formatter/url_fixer.h" |
| 23 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 24 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 24 #include "net/base/url_util.h" | 25 #include "net/base/url_util.h" |
| 25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 26 | 27 |
| 27 // Only use Link Doctor on official builds. It uses an API key, too, but | 28 // Only use Link Doctor on official builds. It uses an API key, too, but |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 } | 277 } |
| 277 | 278 |
| 278 bool IsYoutubeDomainUrl(const GURL& url, | 279 bool IsYoutubeDomainUrl(const GURL& url, |
| 279 SubdomainPermission subdomain_permission, | 280 SubdomainPermission subdomain_permission, |
| 280 PortPermission port_permission) { | 281 PortPermission port_permission) { |
| 281 return IsValidURL(url, port_permission) && | 282 return IsValidURL(url, port_permission) && |
| 282 IsValidHostName(url.host_piece(), "youtube", subdomain_permission, | 283 IsValidHostName(url.host_piece(), "youtube", subdomain_permission, |
| 283 nullptr); | 284 nullptr); |
| 284 } | 285 } |
| 285 | 286 |
| 287 const std::vector<std::string>& GetGoogleRegisterableDomains() { | |
| 288 CR_DEFINE_STATIC_LOCAL(std::vector<std::string>, kGoogleRegisterableDomains, | |
| 289 ()); | |
| 290 | |
| 291 // Initialize the list. | |
| 292 if (kGoogleRegisterableDomains.empty()) { | |
| 293 std::vector<std::string> tlds({GOOGLE_TLD_LIST}); | |
|
Peter Kasting
2017/07/10 19:26:05
Nit: Are () necessary here?
msramek
2017/07/13 14:19:47
Done. No, and I actually didn't know this was poss
| |
| 294 for (const std::string& tld : tlds) { | |
| 295 std::string domain = base::StringPrintf("google.%s", tld.c_str()); | |
|
Peter Kasting
2017/07/10 19:26:05
Nit: Easier to read, doesn't require an #include,
msramek
2017/07/13 14:19:47
Done.
| |
| 296 | |
| 297 // Our list of domains may be slightly out of date. | |
|
Peter Kasting
2017/07/10 19:26:05
I kinda don't think you should do this check. It'
msramek
2017/07/13 14:19:47
Sorry, the comment was unhelpful, because I wrote
| |
| 298 if (GetDomainAndRegistry( | |
| 299 domain, | |
| 300 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES) != | |
| 301 domain) { | |
| 302 continue; | |
| 303 } | |
| 304 | |
| 305 kGoogleRegisterableDomains.push_back(domain); | |
| 306 } | |
| 307 } | |
| 308 | |
| 309 return kGoogleRegisterableDomains; | |
| 310 } | |
| 311 | |
| 286 } // namespace google_util | 312 } // namespace google_util |
| OLD | NEW |