disable-google-host-detection.patch 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. # Disables various detections of Google hosts and functionality specific to them
  2. --- a/chrome/common/google_url_loader_throttle.cc
  3. +++ b/chrome/common/google_url_loader_throttle.cc
  4. @@ -9,10 +9,6 @@
  5. #include "components/google/core/common/google_util.h"
  6. #include "services/network/public/mojom/url_response_head.mojom.h"
  7. -#if BUILDFLAG(ENABLE_EXTENSIONS)
  8. -#include "extensions/common/extension_urls.h"
  9. -#endif
  10. -
  11. namespace {
  12. #if defined(OS_ANDROID)
  13. @@ -40,37 +36,6 @@ void GoogleURLLoaderThrottle::DetachFrom
  14. void GoogleURLLoaderThrottle::WillStartRequest(
  15. network::ResourceRequest* request,
  16. bool* defer) {
  17. - if (dynamic_params_.force_safe_search) {
  18. - GURL new_url;
  19. - safe_search_util::ForceGoogleSafeSearch(request->url, &new_url);
  20. - if (!new_url.is_empty())
  21. - request->url = new_url;
  22. - }
  23. -
  24. - static_assert(safe_search_util::YOUTUBE_RESTRICT_OFF == 0,
  25. - "OFF must be first");
  26. - if (dynamic_params_.youtube_restrict >
  27. - safe_search_util::YOUTUBE_RESTRICT_OFF &&
  28. - dynamic_params_.youtube_restrict <
  29. - safe_search_util::YOUTUBE_RESTRICT_COUNT) {
  30. - safe_search_util::ForceYouTubeRestrict(
  31. - request->url, &request->headers,
  32. - static_cast<safe_search_util::YouTubeRestrictMode>(
  33. - dynamic_params_.youtube_restrict));
  34. - }
  35. -
  36. - if (!dynamic_params_.allowed_domains_for_apps.empty() &&
  37. - request->url.DomainIs("google.com")) {
  38. - request->headers.SetHeader(safe_search_util::kGoogleAppsAllowedDomains,
  39. - dynamic_params_.allowed_domains_for_apps);
  40. - }
  41. -
  42. -#if defined(OS_ANDROID)
  43. - if (!client_data_header_.empty() &&
  44. - google_util::IsGoogleAssociatedDomainUrl(request->url)) {
  45. - request->headers.SetHeader(kClientDataHeader, client_data_header_);
  46. - }
  47. -#endif
  48. }
  49. void GoogleURLLoaderThrottle::WillRedirectRequest(
  50. @@ -79,36 +44,6 @@ void GoogleURLLoaderThrottle::WillRedire
  51. bool* /* defer */,
  52. std::vector<std::string>* to_be_removed_headers,
  53. net::HttpRequestHeaders* modified_headers) {
  54. - // URLLoaderThrottles can only change the redirect URL when the network
  55. - // service is enabled. The non-network service path handles this in
  56. - // ChromeNetworkDelegate.
  57. - if (dynamic_params_.force_safe_search) {
  58. - safe_search_util::ForceGoogleSafeSearch(redirect_info->new_url,
  59. - &redirect_info->new_url);
  60. - }
  61. -
  62. - if (dynamic_params_.youtube_restrict >
  63. - safe_search_util::YOUTUBE_RESTRICT_OFF &&
  64. - dynamic_params_.youtube_restrict <
  65. - safe_search_util::YOUTUBE_RESTRICT_COUNT) {
  66. - safe_search_util::ForceYouTubeRestrict(
  67. - redirect_info->new_url, modified_headers,
  68. - static_cast<safe_search_util::YouTubeRestrictMode>(
  69. - dynamic_params_.youtube_restrict));
  70. - }
  71. -
  72. - if (!dynamic_params_.allowed_domains_for_apps.empty() &&
  73. - redirect_info->new_url.DomainIs("google.com")) {
  74. - modified_headers->SetHeader(safe_search_util::kGoogleAppsAllowedDomains,
  75. - dynamic_params_.allowed_domains_for_apps);
  76. - }
  77. -
  78. -#if defined(OS_ANDROID)
  79. - if (!client_data_header_.empty() &&
  80. - !google_util::IsGoogleAssociatedDomainUrl(redirect_info->new_url)) {
  81. - to_be_removed_headers->push_back(kClientDataHeader);
  82. - }
  83. -#endif
  84. }
  85. #if BUILDFLAG(ENABLE_EXTENSIONS)
  86. @@ -116,17 +51,5 @@ void GoogleURLLoaderThrottle::WillProces
  87. const GURL& response_url,
  88. network::mojom::URLResponseHead* response_head,
  89. bool* defer) {
  90. - // Built-in additional protection for the chrome web store origin.
  91. - GURL webstore_url(extension_urls::GetWebstoreLaunchURL());
  92. - if (response_url.SchemeIsHTTPOrHTTPS() &&
  93. - response_url.DomainIs(webstore_url.host_piece())) {
  94. - if (response_head && response_head->headers &&
  95. - !response_head->headers->HasHeaderValue("x-frame-options", "deny") &&
  96. - !response_head->headers->HasHeaderValue("x-frame-options",
  97. - "sameorigin")) {
  98. - response_head->headers->RemoveHeader("x-frame-options");
  99. - response_head->headers->AddHeader("x-frame-options: sameorigin");
  100. - }
  101. - }
  102. }
  103. #endif
  104. --- a/components/google/core/common/google_util.cc
  105. +++ b/components/google/core/common/google_util.cc
  106. @@ -46,107 +46,6 @@ namespace {
  107. bool gUseMockLinkDoctorBaseURLForTesting = false;
  108. bool g_ignore_port_numbers = false;
  109. -
  110. -bool IsPathHomePageBase(base::StringPiece path) {
  111. - return (path == "/") || (path == "/webhp");
  112. -}
  113. -
  114. -// Removes a single trailing dot if present in |host|.
  115. -void StripTrailingDot(base::StringPiece* host) {
  116. - if (host->ends_with("."))
  117. - host->remove_suffix(1);
  118. -}
  119. -
  120. -// True if the given canonical |host| is "[www.]<domain_in_lower_case>.<TLD>"
  121. -// with a valid TLD that appears in |allowed_tlds|. If |subdomain_permission| is
  122. -// ALLOW_SUBDOMAIN, we check against host "*.<domain_in_lower_case>.<TLD>"
  123. -// instead.
  124. -bool IsValidHostName(base::StringPiece host,
  125. - base::StringPiece domain_in_lower_case,
  126. - SubdomainPermission subdomain_permission,
  127. - const base::flat_set<base::StringPiece>& allowed_tlds) {
  128. - // Fast path to avoid searching the registry set.
  129. - if (host.find(domain_in_lower_case) == base::StringPiece::npos)
  130. - return false;
  131. -
  132. - size_t tld_length =
  133. - net::registry_controlled_domains::GetCanonicalHostRegistryLength(
  134. - host, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
  135. - net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
  136. - if ((tld_length == 0) || (tld_length == std::string::npos))
  137. - return false;
  138. -
  139. - // Removes the tld and the preceding dot.
  140. - base::StringPiece host_minus_tld =
  141. - host.substr(0, host.length() - tld_length - 1);
  142. -
  143. - base::StringPiece tld = host.substr(host.length() - tld_length);
  144. - // Remove the trailing dot from tld if present, as for Google domains it's the
  145. - // same page.
  146. - StripTrailingDot(&tld);
  147. - if (!allowed_tlds.contains(tld))
  148. - return false;
  149. -
  150. - if (base::LowerCaseEqualsASCII(host_minus_tld, domain_in_lower_case))
  151. - return true;
  152. -
  153. - if (subdomain_permission == ALLOW_SUBDOMAIN) {
  154. - std::string dot_domain = base::StrCat({".", domain_in_lower_case});
  155. - return base::EndsWith(host_minus_tld, dot_domain,
  156. - base::CompareCase::INSENSITIVE_ASCII);
  157. - }
  158. -
  159. - std::string www_domain = base::StrCat({"www.", domain_in_lower_case});
  160. - return base::LowerCaseEqualsASCII(host_minus_tld, www_domain);
  161. -}
  162. -
  163. -// True if |url| is a valid URL with HTTP or HTTPS scheme. If |port_permission|
  164. -// is DISALLOW_NON_STANDARD_PORTS, this also requires |url| to use the standard
  165. -// port for its scheme (80 for HTTP, 443 for HTTPS).
  166. -bool IsValidURL(const GURL& url, PortPermission port_permission) {
  167. - return url.is_valid() && url.SchemeIsHTTPOrHTTPS() &&
  168. - (url.port().empty() || g_ignore_port_numbers ||
  169. - (port_permission == ALLOW_NON_STANDARD_PORTS));
  170. -}
  171. -
  172. -bool IsCanonicalHostGoogleHostname(base::StringPiece canonical_host,
  173. - SubdomainPermission subdomain_permission) {
  174. - const GURL& base_url(CommandLineGoogleBaseURL());
  175. - if (base_url.is_valid() && (canonical_host == base_url.host_piece()))
  176. - return true;
  177. -
  178. - static const base::NoDestructor<base::flat_set<base::StringPiece>>
  179. - google_tlds(std::initializer_list<base::StringPiece>({GOOGLE_TLD_LIST}));
  180. - return IsValidHostName(canonical_host, "google", subdomain_permission,
  181. - *google_tlds);
  182. -}
  183. -
  184. -bool IsCanonicalHostYoutubeHostname(base::StringPiece canonical_host,
  185. - SubdomainPermission subdomain_permission) {
  186. - static const base::NoDestructor<base::flat_set<base::StringPiece>>
  187. - youtube_tlds(
  188. - std::initializer_list<base::StringPiece>({YOUTUBE_TLD_LIST}));
  189. - return IsValidHostName(canonical_host, "youtube", subdomain_permission,
  190. - *youtube_tlds);
  191. -}
  192. -
  193. -// True if |url| is a valid URL with a host that is in the static list of
  194. -// Google subdomains for google search, and an HTTP or HTTPS scheme. Requires
  195. -// |url| to use the standard port for its scheme (80 for HTTP, 443 for HTTPS).
  196. -bool IsGoogleSearchSubdomainUrl(const GURL& url) {
  197. - if (!IsValidURL(url, PortPermission::DISALLOW_NON_STANDARD_PORTS))
  198. - return false;
  199. -
  200. - base::StringPiece host(url.host_piece());
  201. - StripTrailingDot(&host);
  202. -
  203. - static const base::NoDestructor<base::flat_set<base::StringPiece>>
  204. - google_subdomains(std::initializer_list<base::StringPiece>(
  205. - {"ipv4.google.com", "ipv6.google.com"}));
  206. -
  207. - return google_subdomains->contains(host);
  208. -}
  209. -
  210. } // namespace
  211. // Global functions -----------------------------------------------------------
  212. @@ -154,19 +53,11 @@ bool IsGoogleSearchSubdomainUrl(const GU
  213. const char kGoogleHomepageURL[] = "https://www.google.com/";
  214. bool HasGoogleSearchQueryParam(base::StringPiece str) {
  215. - url::Component query(0, static_cast<int>(str.length())), key, value;
  216. - while (url::ExtractQueryKeyValue(str.data(), &query, &key, &value)) {
  217. - base::StringPiece key_str = str.substr(key.begin, key.len);
  218. - if (key_str == "q" || key_str == "as_q")
  219. - return true;
  220. - }
  221. return false;
  222. }
  223. GURL LinkDoctorBaseURL() {
  224. - if (gUseMockLinkDoctorBaseURLForTesting)
  225. - return GURL("http://mock.linkdoctor.url/for?testing");
  226. - return GURL(LINKDOCTOR_SERVER_REQUEST_URL);
  227. + return GURL();
  228. }
  229. void SetMockLinkDoctorBaseURLForTesting() {
  230. @@ -180,161 +71,53 @@ std::string GetGoogleLocale(const std::s
  231. GURL AppendGoogleLocaleParam(const GURL& url,
  232. const std::string& application_locale) {
  233. - return net::AppendQueryParameter(url, "hl",
  234. - GetGoogleLocale(application_locale));
  235. + return url;
  236. }
  237. std::string GetGoogleCountryCode(const GURL& google_homepage_url) {
  238. - base::StringPiece google_hostname = google_homepage_url.host_piece();
  239. - // TODO(igorcov): This needs a fix for case when the host has a trailing dot,
  240. - // like "google.com./". https://crbug.com/720295.
  241. - const size_t last_dot = google_hostname.find_last_of('.');
  242. - if (last_dot == std::string::npos)
  243. - return std::string();
  244. - base::StringPiece country_code = google_hostname.substr(last_dot + 1);
  245. - // Assume the com TLD implies the US.
  246. - if (country_code == "com")
  247. - return "us";
  248. - // Google uses the Unicode Common Locale Data Repository (CLDR), and the CLDR
  249. - // code for the UK is "gb".
  250. - if (country_code == "uk")
  251. - return "gb";
  252. - // Catalonia does not have a CLDR country code, since it's a region in Spain,
  253. - // so use Spain instead.
  254. - if (country_code == "cat")
  255. - return "es";
  256. - return country_code.as_string();
  257. + return "nolocale";
  258. }
  259. GURL GetGoogleSearchURL(const GURL& google_homepage_url) {
  260. - // To transform the homepage URL into the corresponding search URL, add the
  261. - // "search" and the "q=" query string.
  262. - GURL::Replacements replacements;
  263. - replacements.SetPathStr("search");
  264. - replacements.SetQueryStr("q=");
  265. - return google_homepage_url.ReplaceComponents(replacements);
  266. + return google_homepage_url;
  267. }
  268. const GURL& CommandLineGoogleBaseURL() {
  269. - // Unit tests may add command-line flags after the first call to this
  270. - // function, so we don't simply initialize a static |base_url| directly and
  271. - // then unconditionally return it.
  272. - static base::NoDestructor<std::string> switch_value;
  273. static base::NoDestructor<GURL> base_url;
  274. - std::string current_switch_value(
  275. - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
  276. - switches::kGoogleBaseURL));
  277. - if (current_switch_value != *switch_value) {
  278. - *switch_value = current_switch_value;
  279. - *base_url = url_formatter::FixupURL(*switch_value, std::string());
  280. - if (!base_url->is_valid() || base_url->has_query() || base_url->has_ref())
  281. - *base_url = GURL();
  282. - }
  283. + *base_url = GURL();
  284. return *base_url;
  285. }
  286. bool StartsWithCommandLineGoogleBaseURL(const GURL& url) {
  287. - const GURL& base_url(CommandLineGoogleBaseURL());
  288. - return base_url.is_valid() &&
  289. - base::StartsWith(url.possibly_invalid_spec(), base_url.spec(),
  290. - base::CompareCase::SENSITIVE);
  291. + return false;
  292. }
  293. bool IsGoogleHostname(base::StringPiece host,
  294. SubdomainPermission subdomain_permission) {
  295. - url::CanonHostInfo host_info;
  296. - return IsCanonicalHostGoogleHostname(net::CanonicalizeHost(host, &host_info),
  297. - subdomain_permission);
  298. + return false;
  299. }
  300. bool IsGoogleDomainUrl(const GURL& url,
  301. SubdomainPermission subdomain_permission,
  302. PortPermission port_permission) {
  303. - return IsValidURL(url, port_permission) &&
  304. - IsCanonicalHostGoogleHostname(url.host_piece(), subdomain_permission);
  305. + return false;
  306. }
  307. bool IsGoogleHomePageUrl(const GURL& url) {
  308. - // First check to see if this has a Google domain.
  309. - if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN,
  310. - DISALLOW_NON_STANDARD_PORTS) &&
  311. - !IsGoogleSearchSubdomainUrl(url)) {
  312. - return false;
  313. - }
  314. -
  315. - // Make sure the path is a known home page path.
  316. - base::StringPiece path(url.path_piece());
  317. - return IsPathHomePageBase(path) ||
  318. - base::StartsWith(path, "/ig", base::CompareCase::INSENSITIVE_ASCII);
  319. + return false;
  320. }
  321. bool IsGoogleSearchUrl(const GURL& url) {
  322. - // First check to see if this has a Google domain.
  323. - if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN,
  324. - DISALLOW_NON_STANDARD_PORTS) &&
  325. - !IsGoogleSearchSubdomainUrl(url)) {
  326. - return false;
  327. - }
  328. -
  329. - // Make sure the path is a known search path.
  330. - base::StringPiece path(url.path_piece());
  331. - bool is_home_page_base = IsPathHomePageBase(path);
  332. - if (!is_home_page_base && (path != "/search"))
  333. - return false;
  334. -
  335. - // Check for query parameter in URL parameter and hash fragment, depending on
  336. - // the path type.
  337. - return HasGoogleSearchQueryParam(url.ref_piece()) ||
  338. - (!is_home_page_base && HasGoogleSearchQueryParam(url.query_piece()));
  339. + return false;
  340. }
  341. bool IsYoutubeDomainUrl(const GURL& url,
  342. SubdomainPermission subdomain_permission,
  343. PortPermission port_permission) {
  344. - return IsValidURL(url, port_permission) &&
  345. - IsCanonicalHostYoutubeHostname(url.host_piece(), subdomain_permission);
  346. + return false;
  347. }
  348. bool IsGoogleAssociatedDomainUrl(const GURL& url) {
  349. - if (IsGoogleDomainUrl(url, ALLOW_SUBDOMAIN, ALLOW_NON_STANDARD_PORTS))
  350. - return true;
  351. -
  352. - if (IsYoutubeDomainUrl(url, ALLOW_SUBDOMAIN, ALLOW_NON_STANDARD_PORTS))
  353. - return true;
  354. -
  355. - // Some domains don't have international TLD extensions, so testing for them
  356. - // is very straightforward.
  357. - static const char* kSuffixesToSetHeadersFor[] = {
  358. - ".android.com",
  359. - ".doubleclick.com",
  360. - ".doubleclick.net",
  361. - ".ggpht.com",
  362. - ".googleadservices.com",
  363. - ".googleapis.com",
  364. - ".googlesyndication.com",
  365. - ".googleusercontent.com",
  366. - ".googlevideo.com",
  367. - ".gstatic.com",
  368. - ".litepages.googlezip.net",
  369. - ".ytimg.com",
  370. - };
  371. - const std::string host = url.host();
  372. - for (size_t i = 0; i < base::size(kSuffixesToSetHeadersFor); ++i) {
  373. - if (base::EndsWith(host, kSuffixesToSetHeadersFor[i],
  374. - base::CompareCase::INSENSITIVE_ASCII)) {
  375. - return true;
  376. - }
  377. - }
  378. -
  379. - // Exact hostnames in lowercase to set headers for.
  380. - static const char* kHostsToSetHeadersFor[] = {
  381. - "googleweblight.com",
  382. - };
  383. - for (size_t i = 0; i < base::size(kHostsToSetHeadersFor); ++i) {
  384. - if (base::LowerCaseEqualsASCII(host, kHostsToSetHeadersFor[i]))
  385. - return true;
  386. - }
  387. -
  388. return false;
  389. }
  390. --- a/components/page_load_metrics/browser/page_load_metrics_util.cc
  391. +++ b/components/page_load_metrics/browser/page_load_metrics_util.cc
  392. @@ -171,9 +171,7 @@ bool DidObserveLoadingBehaviorInAnyFrame
  393. }
  394. bool IsGoogleSearchHostname(const GURL& url) {
  395. - base::Optional<std::string> result =
  396. - page_load_metrics::GetGoogleHostnamePrefix(url);
  397. - return result && result.value() == "www";
  398. + return false;
  399. }
  400. bool IsGoogleSearchResultUrl(const GURL& url) {
  401. --- a/components/page_load_metrics/common/page_load_metrics_util.cc
  402. +++ b/components/page_load_metrics/common/page_load_metrics_util.cc
  403. @@ -12,38 +12,7 @@
  404. namespace page_load_metrics {
  405. base::Optional<std::string> GetGoogleHostnamePrefix(const GURL& url) {
  406. - const size_t registry_length =
  407. - net::registry_controlled_domains::GetRegistryLength(
  408. - url,
  409. -
  410. - // Do not include unknown registries (registries that don't have any
  411. - // matches in effective TLD names).
  412. - net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
  413. -
  414. - // Do not include private registries, such as appspot.com. We don't
  415. - // want to match URLs like www.google.appspot.com.
  416. - net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
  417. -
  418. - const base::StringPiece hostname = url.host_piece();
  419. - if (registry_length == 0 || registry_length == std::string::npos ||
  420. - registry_length >= hostname.length()) {
  421. - return base::Optional<std::string>();
  422. - }
  423. -
  424. - // Removes the tld and the preceding dot.
  425. - const base::StringPiece hostname_minus_registry =
  426. - hostname.substr(0, hostname.length() - (registry_length + 1));
  427. -
  428. - if (hostname_minus_registry == "google")
  429. - return std::string("");
  430. -
  431. - if (!base::EndsWith(hostname_minus_registry, ".google",
  432. - base::CompareCase::INSENSITIVE_ASCII)) {
  433. - return base::Optional<std::string>();
  434. - }
  435. -
  436. - return std::string(hostname_minus_registry.substr(
  437. - 0, hostname_minus_registry.length() - strlen(".google")));
  438. + return base::Optional<std::string>();
  439. }
  440. bool IsGoogleHostname(const GURL& url) {
  441. --- a/components/search_engines/template_url.cc
  442. +++ b/components/search_engines/template_url.cc
  443. @@ -507,11 +507,7 @@ base::string16 TemplateURLRef::SearchTer
  444. bool TemplateURLRef::HasGoogleBaseURLs(
  445. const SearchTermsData& search_terms_data) const {
  446. ParseIfNecessary(search_terms_data);
  447. - return std::any_of(replacements_.begin(), replacements_.end(),
  448. - [](const Replacement& replacement) {
  449. - return replacement.type == GOOGLE_BASE_URL ||
  450. - replacement.type == GOOGLE_BASE_SUGGEST_URL;
  451. - });
  452. + return false;
  453. }
  454. bool TemplateURLRef::ExtractSearchTermsFromURL(
  455. --- a/components/variations/net/variations_http_headers.cc
  456. +++ b/components/variations/net/variations_http_headers.cc
  457. @@ -29,10 +29,6 @@ namespace variations {
  458. namespace {
  459. -// The name string for the header for variations information.
  460. -// Note that prior to M33 this header was named X-Chrome-Variations.
  461. -const char kClientDataHeader[] = "X-Client-Data";
  462. -
  463. // The result of checking if a URL should have variations headers appended.
  464. // This enum is used to record UMA histogram values, and should not be
  465. // reordered.
  466. @@ -89,28 +85,7 @@ class VariationsHeaderHelper {
  467. }
  468. bool AppendHeaderIfNeeded(const GURL& url, InIncognito incognito) {
  469. - AppendOmniboxOnDeviceSuggestionsHeaderIfNeeded(url, resource_request_);
  470. -
  471. - // Note the criteria for attaching client experiment headers:
  472. - // 1. We only transmit to Google owned domains which can evaluate
  473. - // experiments.
  474. - // 1a. These include hosts which have a standard postfix such as:
  475. - // *.doubleclick.net or *.googlesyndication.com or
  476. - // exactly www.googleadservices.com or
  477. - // international TLD domains *.google.<TLD> or *.youtube.<TLD>.
  478. - // 2. Only transmit for non-Incognito profiles.
  479. - // 3. For the X-Client-Data header, only include non-empty variation IDs.
  480. - if ((incognito == InIncognito::kYes) || !ShouldAppendVariationsHeader(url))
  481. - return false;
  482. -
  483. - if (variations_header_.empty())
  484. - return false;
  485. -
  486. - // Set the variations header to cors_exempt_headers rather than headers
  487. - // to be exempted from CORS checks.
  488. - resource_request_->cors_exempt_headers.SetHeaderIfMissing(
  489. - kClientDataHeader, variations_header_);
  490. - return true;
  491. + return false;
  492. }
  493. private:
  494. @@ -153,8 +128,6 @@ void RemoveVariationsHeaderIfNeeded(
  495. const net::RedirectInfo& redirect_info,
  496. const network::mojom::URLResponseHead& response_head,
  497. std::vector<std::string>* to_be_removed_headers) {
  498. - if (!ShouldAppendVariationsHeader(redirect_info.new_url))
  499. - to_be_removed_headers->push_back(kClientDataHeader);
  500. }
  501. std::unique_ptr<network::SimpleURLLoader>
  502. @@ -184,14 +157,11 @@ CreateSimpleURLLoaderWithVariationsHeade
  503. }
  504. bool IsVariationsHeader(const std::string& header_name) {
  505. - return header_name == kClientDataHeader ||
  506. - header_name == kOmniboxOnDeviceSuggestionsHeader;
  507. + return false;
  508. }
  509. bool HasVariationsHeader(const network::ResourceRequest& request) {
  510. - // Note: kOmniboxOnDeviceSuggestionsHeader is not listed because this function
  511. - // is only used for testing.
  512. - return request.cors_exempt_headers.HasHeader(kClientDataHeader);
  513. + return false;
  514. }
  515. bool ShouldAppendVariationsHeaderForTesting(const GURL& url) {
  516. @@ -200,12 +170,6 @@ bool ShouldAppendVariationsHeaderForTest
  517. void UpdateCorsExemptHeaderForVariations(
  518. network::mojom::NetworkContextParams* params) {
  519. - params->cors_exempt_header_list.push_back(kClientDataHeader);
  520. -
  521. - if (base::FeatureList::IsEnabled(kReportOmniboxOnDeviceSuggestionsHeader)) {
  522. - params->cors_exempt_header_list.push_back(
  523. - kOmniboxOnDeviceSuggestionsHeader);
  524. - }
  525. }
  526. } // namespace variations
  527. --- a/net/base/url_util.cc
  528. +++ b/net/base/url_util.cc
  529. @@ -401,27 +401,6 @@ bool HasGoogleHost(const GURL& url) {
  530. }
  531. bool IsGoogleHost(base::StringPiece host) {
  532. - static const char* kGoogleHostSuffixes[] = {
  533. - ".google.com",
  534. - ".youtube.com",
  535. - ".gmail.com",
  536. - ".doubleclick.net",
  537. - ".gstatic.com",
  538. - ".googlevideo.com",
  539. - ".googleusercontent.com",
  540. - ".googlesyndication.com",
  541. - ".google-analytics.com",
  542. - ".googleadservices.com",
  543. - ".googleapis.com",
  544. - ".ytimg.com",
  545. - };
  546. - for (const char* suffix : kGoogleHostSuffixes) {
  547. - // Here it's possible to get away with faster case-sensitive comparisons
  548. - // because the list above is all lowercase, and a GURL's host name will
  549. - // always be canonicalized to lowercase as well.
  550. - if (base::EndsWith(host, suffix, base::CompareCase::SENSITIVE))
  551. - return true;
  552. - }
  553. return false;
  554. }