diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-17 13:57:45 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-19 13:44:40 +0000 |
commit | 6ec7b8da05d21a3878bd21c691b41e675d74bb1c (patch) | |
tree | b87f250bc19413750b9bb9cdbf2da20ef5014820 /chromium/components/google | |
parent | ec02ee4181c49b61fce1c8fb99292dbb8139cc90 (diff) | |
download | qtwebengine-chromium-6ec7b8da05d21a3878bd21c691b41e675d74bb1c.tar.gz |
BASELINE: Update Chromium to 60.0.3112.70
Change-Id: I9911c2280a014d4632f254857876a395d4baed2d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/google')
4 files changed, 117 insertions, 69 deletions
diff --git a/chromium/components/google/core/browser/google_tld_list.h b/chromium/components/google/core/browser/google_tld_list.h index 6a246cf38ec..b6961828849 100644 --- a/chromium/components/google/core/browser/google_tld_list.h +++ b/chromium/components/google/core/browser/google_tld_list.h @@ -10,39 +10,34 @@ #define GOOGLE_TLD_LIST "ac", "ad", "ae", "af", "ag", "al", "am", "as", "at", \ "aw", "az", "ba", "be", "bf", "bg", "bi", "biz", "bj", "bm", "bn", "bo", "bs", \ -"bt", "by", "bz", "ca", "cat", "cc", "cd", "cf", "cg", "ch", "ci", "cl", "cm", \ -"cn", "co", "co.ao", "co.at", "co.ba", "co.bi", "co.bw", "co.ci", "co.ck", \ -"co.cr", "co.gg", "co.gl", "co.gy", "co.hu", "co.id", "co.il", "co.im", \ -"co.in", "co.it", "co.je", "co.jp", "co.ke", "co.kr", "co.ls", "co.ma", \ -"co.mu", "co.mw", "co.mz", "co.nz", "co.pn", "co.rs", "co.th", "co.tt", \ -"co.tz", "co.ua", "co.ug", "co.uk", "co.uz", "co.ve", "co.vi", "co.za", \ -"co.zm", "co.zw", "com", "com.af", "com.ag", "com.ai", "com.ar", "com.au", \ -"com.az", "com.bd", "com.bh", "com.bi", "com.bn", "com.bo", "com.br", \ -"com.bs", "com.by", "com.bz", "com.cn", "com.co", "com.cu", "com.cy", \ -"com.do", "com.dz", "com.ec", "com.eg", "com.er", "com.et", "com.fj", \ -"com.ge", "com.gh", "com.gi", "com.gl", "com.gp", "com.gr", "com.gt", \ -"com.gy", "com.hk", "com.hn", "com.hr", "com.ht", "com.iq", "com.jm", \ -"com.jo", "com.kg", "com.kh", "com.ki", "com.kw", "com.kz", "com.lb", \ -"com.lc", "com.lk", "com.lv", "com.ly", "com.mk", "com.mm", "com.mt", \ -"com.mu", "com.mw", "com.mx", "com.my", "com.na", "com.nc", "com.nf", \ -"com.ng", "com.ni", "com.np", "com.nr", "com.om", "com.pa", "com.pe", \ -"com.pg", "com.ph", "com.pk", "com.pl", "com.pr", "com.ps", "com.pt", \ -"com.py", "com.qa", "com.ru", "com.sa", "com.sb", "com.sc", "com.sg", \ -"com.sl", "com.sv", "com.tj", "com.tm", "com.tn", "com.tr", "com.tt", \ -"com.tw", "com.ua", "com.uy", "com.uz", "com.vc", "com.ve", "com.vi", \ -"com.vn", "com.ws", "cv", "cx", "cz", "de", "dj", "dk", "dm", "do", "dz", \ -"ec", "ee", "es", "eu", "fi", "fm", "fr", "ga", "gd", "ge", "gf", "gg", "gl", \ -"gm", "gp", "gr", "gw", "gy", "hk", "hn", "hr", "ht", "hu", "ie", "im", "in", \ -"in.rs", "info", "io", "iq", "is", "it", "it.ao", "je", "jo", "jobs", "jp", \ -"kg", "ki", "kids.us", "km", "kn", "kr", "kz", "la", "li", "lk", "lt", "lu", \ -"lv", "ma", "md", "me", "mg", "mh", "mk", "ml", "mn", "mobi", "mr", "ms", \ -"mu", "mv", "mw", "mx", "name", "ne", "ne.jp", "net", "net.in", "net.nz", \ -"nf", "ng", "nl", "no", "nom.es", "nr", "nu", "off.ai", "org", "org.af", \ -"org.es", "org.in", "org.nz", "org.uk", "pf", "ph", "pk", "pl", "pn", "pr", \ -"pro", "ps", "pt", "qa", "re", "ro", "rs", "ru", "rw", "sc", "se", "sg", "sh", \ -"si", "sk", "sl", "sm", "sn", "so", "sr", "st", "sz", "td", "tel", "tg", "tk", \ -"tl", "tm", "tn", "to", "tt", "tv", "tw", "ua", "ug", "us", "uz", "vc", "vg", \ -"vn", "vu", "ws", "yt" +"bt", "by", "ca", "cat", "cc", "cd", "cf", "cg", "ch", "ci", "cl", "cm", "cn", \ +"co", "co.ao", "co.at", "co.bw", "co.ck", "co.cr", "co.gg", "co.gy", "co.hu", \ +"co.id", "co.il", "co.im", "co.in", "co.je", "co.jp", "co.ke", "co.kr", \ +"co.ls", "co.ma", "co.mz", "co.nz", "co.rs", "co.th", "co.tz", "co.ua", \ +"co.ug", "co.uk", "co.uz", "co.ve", "co.vi", "co.za", "co.zm", "co.zw", "com", \ +"com.af", "com.ag", "com.ai", "com.ar", "com.au", "com.az", "com.bd", \ +"com.bh", "com.bi", "com.bn", "com.bo", "com.br", "com.by", "com.bz", \ +"com.cn", "com.co", "com.cu", "com.cy", "com.do", "com.dz", "com.ec", \ +"com.eg", "com.er", "com.et", "com.fj", "com.ge", "com.gh", "com.gi", \ +"com.gp", "com.gr", "com.gt", "com.gy", "com.hk", "com.ht", "com.iq", \ +"com.jm", "com.jo", "com.kh", "com.kw", "com.kz", "com.lb", "com.lv", \ +"com.ly", "com.mm", "com.mt", "com.mx", "com.my", "com.na", "com.nc", \ +"com.nf", "com.ng", "com.ni", "com.np", "com.nr", "com.om", "com.pa", \ +"com.pe", "com.pg", "com.ph", "com.pk", "com.pl", "com.pr", "com.ps", \ +"com.pt", "com.py", "com.qa", "com.ru", "com.sa", "com.sb", "com.sg", \ +"com.sl", "com.sv", "com.tj", "com.tm", "com.tn", "com.tr", "com.tw", \ +"com.ua", "com.uy", "com.vc", "com.ve", "com.vn", "cv", "cz", "de", "dj", \ +"dk", "dm", "do", "dz", "ec", "ee", "es", "eu", "fi", "fm", "fr", "ga", "gd", \ +"ge", "gf", "gg", "gl", "gm", "gp", "gr", "gw", "gy", "hk", "hn", "hr", "ht", \ +"hu", "ie", "im", "in", "info", "io", "iq", "is", "it", "it.ao", "je", "jo", \ +"jobs", "jp", "kg", "ki", "km", "kr", "kz", "la", "li", "lk", "lt", "lu", \ +"lv", "ma", "md", "me", "mg", "mh", "mk", "ml", "mn", "mr", "ms", "mu", "mv", \ +"mw", "mx", "name", "ne", "ne.jp", "net", "net.nz", "ng", "nl", "no", \ +"nom.es", "nr", "nu", "off.ai", "org", "org.es", "org.nz", "org.uk", "pf", \ +"ph", "pk", "pl", "pn", "pro", "ps", "pt", "qa", "re", "ro", "rs", "ru", "rw", \ +"sc", "se", "sg", "sh", "si", "sk", "sl", "sm", "sn", "so", "sr", "st", "sz", \ +"td", "tel", "tg", "tk", "tl", "tm", "tn", "to", "tt", "tv", "tw", "ua", "us", \ +"uz", "vg", "vn", "vu", "ws", "yt" #endif // COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_TLD_LIST_H_ diff --git a/chromium/components/google/core/browser/google_url_tracker.h b/chromium/components/google/core/browser/google_url_tracker.h index 5d0ba62a4e3..e98af1376e2 100644 --- a/chromium/components/google/core/browser/google_url_tracker.h +++ b/chromium/components/google/core/browser/google_url_tracker.h @@ -26,8 +26,7 @@ class PrefRegistrySyncable; // change. The current value is saved to prefs. // // Most consumers should only call google_url(). Consumers who need to be -// notified when things change should register a callback that provides the -// original and updated values via RegisterCallback(). +// notified when things change should use RegisterCallback(). // // To protect users' privacy and reduce server load, no updates will be // performed (ever) unless at least one consumer registers interest by calling @@ -37,8 +36,7 @@ class GoogleURLTracker public net::NetworkChangeNotifier::NetworkChangeObserver, public KeyedService { public: - // Callback that is called when the Google URL is updated. The arguments are - // the old and new URLs. + // Callback that is called when the Google URL is updated. typedef base::Callback<void()> OnGoogleURLUpdatedCallback; typedef base::CallbackList<void()> CallbackList; typedef CallbackList::Subscription Subscription; diff --git a/chromium/components/google/core/browser/google_util.cc b/chromium/components/google/core/browser/google_util.cc index a16d55eaafd..b8f8c1daa9e 100644 --- a/chromium/components/google/core/browser/google_util.cc +++ b/chromium/components/google/core/browser/google_util.cc @@ -45,6 +45,12 @@ bool IsPathHomePageBase(base::StringPiece path) { return (path == "/") || (path == "/webhp"); } +// Removes a single trailing dot if present in |host|. +void StripTrailingDot(base::StringPiece* host) { + if (host->ends_with(".")) + host->remove_suffix(1); +} + // True if the given canonical |host| is "[www.]<domain_in_lower_case>.<TLD>" // with a valid TLD. If |subdomain_permission| is ALLOW_SUBDOMAIN, we check // against host "*.<domain_in_lower_case>.<TLD>" instead. Will return the TLD @@ -104,11 +110,31 @@ bool IsCanonicalHostGoogleHostname(base::StringPiece canonical_host, if (!IsValidHostName(canonical_host, "google", subdomain_permission, &tld)) return false; + // Remove the trailing dot from tld if present, as for google domain it's the + // same page. + StripTrailingDot(&tld); + CR_DEFINE_STATIC_LOCAL(std::set<std::string>, google_tlds, ({GOOGLE_TLD_LIST})); return base::ContainsKey(google_tlds, tld.as_string()); } +// True if |url| is a valid URL with a host that is in the static list of +// Google subdomains for google search, and an HTTP or HTTPS scheme. Requires +// |url| to use the standard port for its scheme (80 for HTTP, 443 for HTTPS). +bool IsGoogleSearchSubdomainUrl(const GURL& url) { + if (!IsValidURL(url, PortPermission::DISALLOW_NON_STANDARD_PORTS)) + return false; + + base::StringPiece host(url.host_piece()); + StripTrailingDot(&host); + + CR_DEFINE_STATIC_LOCAL(std::set<std::string>, google_subdomains, + ({"ipv4.google.com", "ipv6.google.com"})); + + return base::ContainsKey(google_subdomains, host.as_string()); +} + } // namespace // Global functions ----------------------------------------------------------- @@ -148,10 +174,10 @@ GURL AppendGoogleLocaleParam(const GURL& url, std::string GetGoogleCountryCode(const GURL& google_homepage_url) { base::StringPiece google_hostname = google_homepage_url.host_piece(); + // TODO(igorcov): This needs a fix for case when the host has a trailing dot, + // like "google.com./". https://crbug.com/720295. const size_t last_dot = google_hostname.find_last_of('.'); - if (last_dot == std::string::npos) { - NOTREACHED(); - } + DCHECK_NE(std::string::npos, last_dot); base::StringPiece country_code = google_hostname.substr(last_dot + 1); // Assume the com TLD implies the US. if (country_code == "com") @@ -217,8 +243,11 @@ bool IsGoogleDomainUrl(const GURL& url, bool IsGoogleHomePageUrl(const GURL& url) { // First check to see if this has a Google domain. - if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, DISALLOW_NON_STANDARD_PORTS)) + if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, + DISALLOW_NON_STANDARD_PORTS) && + !IsGoogleSearchSubdomainUrl(url)) { return false; + } // Make sure the path is a known home page path. base::StringPiece path(url.path_piece()); @@ -228,8 +257,11 @@ bool IsGoogleHomePageUrl(const GURL& url) { bool IsGoogleSearchUrl(const GURL& url) { // First check to see if this has a Google domain. - if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, DISALLOW_NON_STANDARD_PORTS)) + if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, + DISALLOW_NON_STANDARD_PORTS) && + !IsGoogleSearchSubdomainUrl(url)) { return false; + } // Make sure the path is a known search path. base::StringPiece path(url.path_piece()); diff --git a/chromium/components/google/core/browser/google_util_unittest.cc b/chromium/components/google/core/browser/google_util_unittest.cc index d30d03b56a5..46072bf5703 100644 --- a/chromium/components/google/core/browser/google_util_unittest.cc +++ b/chromium/components/google/core/browser/google_util_unittest.cc @@ -64,6 +64,14 @@ TEST(GoogleUtilTest, GoodHomePagesNonSecure) { EXPECT_TRUE(IsHomePage("http://www.google.com/ig/foo")); EXPECT_TRUE(IsHomePage("http://www.google.com/ig?rlz=TEST")); EXPECT_TRUE(IsHomePage("http://www.google.com/ig/foo?rlz=TEST")); + + // Accepted subdomains. + EXPECT_TRUE(IsHomePage("http://ipv4.google.com/")); + EXPECT_TRUE(IsHomePage("http://ipv6.google.com/")); + + // Trailing dots. + EXPECT_TRUE(IsHomePage("http://ipv4.google.com./")); + EXPECT_TRUE(IsHomePage("http://google.com./")); } TEST(GoogleUtilTest, GoodHomePagesSecure) { @@ -121,37 +129,52 @@ TEST(GoogleUtilTest, BadHomePages) { // Path is case sensitive. EXPECT_FALSE(IsHomePage("https://www.google.com/WEBHP")); + + // Only .com subdomain and no www. + EXPECT_FALSE(IsHomePage("http://ipv4.google.co.uk")); + EXPECT_FALSE(IsHomePage("http://www.ipv4.google.com")); } TEST(GoogleUtilTest, GoodSearches) { const std::string patterns[] = { - // Queries with path "/search" need to have the query parameter in either - // the url parameter or the hash fragment. - "%s://www.google.com/search?%s=something", - "%s://www.google.com/search#%s=something", - "%s://www.google.com/search?name=bob&%s=something", - "%s://www.google.com/search?name=bob#%s=something", - "%s://www.google.com/search?name=bob#age=24&%s=thng", - "%s://www.google.co.uk/search?%s=something", - // It's actually valid for both to have the query parameter. - "%s://www.google.com/search?%s=something#q=other", - - // Queries with path "/webhp", "/" or "" need to have the query parameter in - // the hash fragment. - "%s://www.google.com/webhp#%s=something", - "%s://www.google.com/webhp#name=bob&%s=something", - "%s://www.google.com/webhp?name=bob#%s=something", - "%s://www.google.com/webhp?name=bob#age=24&%s=thing", - - "%s://www.google.com/#%s=something", - "%s://www.google.com/#name=bob&%s=something", - "%s://www.google.com/?name=bob#%s=something", - "%s://www.google.com/?name=bob#age=24&%s=something", - - "%s://www.google.com#%s=something", - "%s://www.google.com#name=bob&%s=something", - "%s://www.google.com?name=bob#%s=something", - "%s://www.google.com?name=bob#age=24&%s=something" + // Queries with path "/search" need to have the query parameter in either + // the url parameter or the hash fragment. + "%s://www.google.com/search?%s=something", + "%s://www.google.com/search#%s=something", + "%s://www.google.com/search?name=bob&%s=something", + "%s://www.google.com/search?name=bob#%s=something", + "%s://www.google.com/search?name=bob#age=24&%s=thng", + "%s://www.google.co.uk/search?%s=something", + // It's actually valid for both to have the query parameter. + "%s://www.google.com/search?%s=something#q=other", + + // Queries with path "/webhp", "/" or "" need to have the query parameter + // in the hash fragment. + "%s://www.google.com/webhp#%s=something", + "%s://www.google.com/webhp#name=bob&%s=something", + "%s://www.google.com/webhp?name=bob#%s=something", + "%s://www.google.com/webhp?name=bob#age=24&%s=thing", + + "%s://www.google.com/#%s=something", + "%s://www.google.com/#name=bob&%s=something", + "%s://www.google.com/?name=bob#%s=something", + "%s://www.google.com/?name=bob#age=24&%s=something", + + "%s://www.google.com#%s=something", + "%s://www.google.com#name=bob&%s=something", + "%s://www.google.com?name=bob#%s=something", + "%s://www.google.com?name=bob#age=24&%s=something", + + // Google subdomain queries. + "%s://ipv4.google.com/search?%s=something", + "%s://ipv4.google.com#name=bob&%s=something", + "%s://ipv6.google.com?name=bob#%s=something", + "%s://ipv6.google.com?name=bob#age=24&%s=something", + + // Trailing dots in the hosts. + "%s://www.google.com./#%s=something", "%s://www.google.de./#%s=something", + "%s://ipv4.google.com./#%s=something", + "%s://ipv6.google.com./#%s=something", }; for (const std::string& pattern : patterns) { |