0003-disable-autofill-download-manager.patch 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. --- a/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.cc
  2. +++ b/components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_manager.cc
  3. @@ -760,95 +760,6 @@ std::tuple<GURL, std::string> AutofillCr
  4. }
  5. bool AutofillCrowdsourcingManager::StartRequest(FormRequestData request_data) {
  6. - // REQUEST_UPLOADs take no IsolationInfo because Password Manager uploads when
  7. - // RenderFrameHostImpl::DidCommitNavigation() is called, in which case
  8. - // AutofillDriver::IsolationInfo() may crash because there is no committing
  9. - // NavigationRequest. Not setting an IsolationInfo is safe because no
  10. - // information about the response is passed to the renderer, or is otherwise
  11. - // visible to a page. See crbug/1176635#c22.
  12. - DCHECK(
  13. - (request_data.request_type == AutofillCrowdsourcingManager::REQUEST_UPLOAD) ==
  14. - !request_data.isolation_info);
  15. -
  16. - // Get the URL and method to use for this request.
  17. - auto [request_url, method] = GetRequestURLAndMethod(request_data);
  18. -
  19. - // Track the URL length for GET queries because the URL length can be in the
  20. - // thousands when rich metadata is enabled.
  21. - if (request_data.request_type == AutofillCrowdsourcingManager::REQUEST_QUERY &&
  22. - method == "GET") {
  23. - base::UmaHistogramCounts100000(kUmaGetUrlLength,
  24. - request_url.spec().length());
  25. - }
  26. -
  27. - auto resource_request = std::make_unique<network::ResourceRequest>();
  28. - resource_request->url = request_url;
  29. - resource_request->credentials_mode = network::mojom::CredentialsMode::kOmit;
  30. - resource_request->method = method;
  31. -
  32. - // On iOS we have a single, shared URLLoaderFactory provided by BrowserState.
  33. - // As it is shared, it is not trusted and we cannot assign trusted_params
  34. - // to the network request.
  35. -#if !BUILDFLAG(IS_IOS)
  36. - if (request_data.isolation_info) {
  37. - resource_request->trusted_params =
  38. - network::ResourceRequest::TrustedParams();
  39. - resource_request->trusted_params->isolation_info =
  40. - *request_data.isolation_info;
  41. - }
  42. -#endif
  43. -
  44. - // Add Chrome experiment state to the request headers.
  45. - variations::AppendVariationsHeaderUnknownSignedIn(
  46. - request_url,
  47. - client_->IsOffTheRecord() ? variations::InIncognito::kYes
  48. - : variations::InIncognito::kNo,
  49. - resource_request.get());
  50. -
  51. - // Set headers specific to the API.
  52. - // Encode response serialized proto in base64 for safety.
  53. - resource_request->headers.SetHeader(kGoogEncodeResponseIfExecutable,
  54. - "base64");
  55. -
  56. - // Put API key in request's header if a key exists, and the endpoint is
  57. - // trusted by Google.
  58. - if (!api_key_.empty() && request_url.SchemeIs(url::kHttpsScheme) &&
  59. - google_util::IsGoogleAssociatedDomainUrl(request_url)) {
  60. - resource_request->headers.SetHeader(kGoogApiKey, api_key_);
  61. - }
  62. -
  63. - auto simple_loader = network::SimpleURLLoader::Create(
  64. - std::move(resource_request),
  65. - GetNetworkTrafficAnnotation(request_data.request_type));
  66. -
  67. - // This allows reading the error message within the API response when status
  68. - // is not 200 (e.g., 400). Otherwise, URL loader will not give any content in
  69. - // the response when there is a failure, which makes debugging hard.
  70. - simple_loader->SetAllowHttpErrorResults(true);
  71. -
  72. - if (method == "POST") {
  73. - static constexpr char content_type[] = "application/x-protobuf";
  74. - std::optional<std::string> payload = GetAPIBodyPayload(
  75. - std::move(request_data.payload), request_data.request_type);
  76. - if (!payload) {
  77. - return false;
  78. - }
  79. - // Attach payload data and add data format header.
  80. - simple_loader->AttachStringForUpload(std::move(payload).value(),
  81. - content_type);
  82. - }
  83. -
  84. - // Transfer ownership of the loader into url_loaders_. Temporarily hang
  85. - // onto the raw pointer to use it as a key and to kick off the request;
  86. - // transferring ownership (std::move) invalidates the `simple_loader`
  87. - // variable.
  88. - auto* raw_simple_loader = simple_loader.get();
  89. - url_loaders_.push_back(std::move(simple_loader));
  90. - raw_simple_loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
  91. - client_->GetURLLoaderFactory().get(),
  92. - base::BindOnce(&AutofillCrowdsourcingManager::OnSimpleLoaderComplete,
  93. - base::Unretained(this), std::move(--url_loaders_.end()),
  94. - std::move(request_data), AutofillTickClock::NowTicks()));
  95. return true;
  96. }