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

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