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. @@ -802,95 +802,6 @@ std::tuple<GURL, std::string> AutofillCr
  4. }
  5. bool AutofillCrowdsourcingManager::StartRequest(FormRequestData request_data) {
  6. - // kRequestUploads 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((request_data.request_type == RequestType::kRequestUpload) ==
  13. - !request_data.isolation_info);
  14. -
  15. - // Get the URL and method to use for this request.
  16. - auto [request_url, method] = GetRequestURLAndMethod(request_data);
  17. -
  18. - // Track the URL length for GET queries because the URL length can be in the
  19. - // thousands when rich metadata is enabled.
  20. - if (request_data.request_type == RequestType::kRequestQuery &&
  21. - method == "GET") {
  22. - base::UmaHistogramCounts100000(kUmaGetUrlLength,
  23. - request_url.spec().length());
  24. - }
  25. -
  26. - auto resource_request = std::make_unique<network::ResourceRequest>();
  27. - resource_request->url = request_url;
  28. - resource_request->credentials_mode = network::mojom::CredentialsMode::kOmit;
  29. - resource_request->method = method;
  30. -
  31. - // On iOS we have a single, shared URLLoaderFactory provided by BrowserState.
  32. - // As it is shared, it is not trusted and we cannot assign trusted_params
  33. - // to the network request.
  34. -#if !BUILDFLAG(IS_IOS)
  35. - if (request_data.isolation_info) {
  36. - resource_request->trusted_params =
  37. - network::ResourceRequest::TrustedParams();
  38. - resource_request->trusted_params->isolation_info =
  39. - *request_data.isolation_info;
  40. - }
  41. -#endif
  42. -
  43. - // Add Chrome experiment state to the request headers.
  44. - variations::AppendVariationsHeaderUnknownSignedIn(
  45. - request_url,
  46. - client_->IsOffTheRecord() ? variations::InIncognito::kYes
  47. - : variations::InIncognito::kNo,
  48. - resource_request.get());
  49. -
  50. - // Set headers specific to the API.
  51. - // Encode response serialized proto in base64 for safety.
  52. - resource_request->headers.SetHeader(kGoogEncodeResponseIfExecutable,
  53. - "base64");
  54. -
  55. - // Put API key in request's header if a key exists, and the endpoint is
  56. - // trusted by Google.
  57. - if (!api_key_.empty() && request_url.SchemeIs(url::kHttpsScheme) &&
  58. - google_util::IsGoogleAssociatedDomainUrl(request_url)) {
  59. - resource_request->headers.SetHeader(kGoogApiKey, api_key_);
  60. - }
  61. -
  62. - auto simple_loader = network::SimpleURLLoader::Create(
  63. - std::move(resource_request),
  64. - GetNetworkTrafficAnnotation(request_data.request_type));
  65. -
  66. - // This allows reading the error message within the API response when status
  67. - // is not 200 (e.g., 400). Otherwise, URL loader will not give any content in
  68. - // the response when there is a failure, which makes debugging hard.
  69. - simple_loader->SetAllowHttpErrorResults(true);
  70. -
  71. - if (method == "POST") {
  72. - static constexpr char content_type[] = "application/x-protobuf";
  73. - std::optional<std::string> payload =
  74. - GetAPIBodyPayload(request_data.payload, request_data.request_type);
  75. - if (!payload) {
  76. - return false;
  77. - }
  78. - // Attach payload data and add data format header.
  79. - simple_loader->AttachStringForUpload(std::move(payload).value(),
  80. - content_type);
  81. - }
  82. -
  83. - // Transfer ownership of the loader into url_loaders_. Temporarily hang
  84. - // onto the raw pointer to use it as a key and to kick off the request;
  85. - // transferring ownership (std::move) invalidates the `simple_loader`
  86. - // variable.
  87. - auto* raw_simple_loader = simple_loader.get();
  88. - url_loaders_.push_back(std::move(simple_loader));
  89. - raw_simple_loader->SetTimeoutDuration(kFetchTimeout);
  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), base::TimeTicks::Now()));
  95. return true;
  96. }