mirror of
https://codeberg.org/kiss-community/repo
synced 2024-08-23 14:26:18 +00:00
74 lines
3.1 KiB
Diff
74 lines
3.1 KiB
Diff
--- a/components/autofill/core/browser/autofill_download_manager.cc
|
|
+++ b/components/autofill/core/browser/autofill_download_manager.cc
|
|
@@ -703,70 +703,6 @@ AutofillDownloadManager::GetRequestURLAn
|
|
}
|
|
|
|
bool AutofillDownloadManager::StartRequest(FormRequestData request_data) {
|
|
- scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory =
|
|
- driver_->GetURLLoaderFactory();
|
|
- DCHECK(url_loader_factory);
|
|
-
|
|
- // Get the URL and method to use for this request.
|
|
- std::string method;
|
|
- GURL request_url;
|
|
- std::tie(request_url, method) =
|
|
- UseApi() ? GetRequestURLAndMethodForApi(request_data)
|
|
- : GetRequestURLAndMethod(request_data);
|
|
-
|
|
- auto resource_request = std::make_unique<network::ResourceRequest>();
|
|
- resource_request->url = request_url;
|
|
- resource_request->load_flags =
|
|
- net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES;
|
|
- resource_request->method = method;
|
|
-
|
|
- // Add Chrome experiment state to the request headers.
|
|
- variations::AppendVariationsHeaderUnknownSignedIn(
|
|
- request_url,
|
|
- driver_->IsIncognito() ? variations::InIncognito::kYes
|
|
- : variations::InIncognito::kNo,
|
|
- resource_request.get());
|
|
-
|
|
- // Set headers specific to the API if using it.
|
|
- if (UseApi())
|
|
- // Encode response serialized proto in base64 for safety.
|
|
- resource_request->headers.SetHeader(kGoogEncodeResponseIfExecutable,
|
|
- "base64");
|
|
-
|
|
- // Put API key in request's header if a key exists, and the endpoint is
|
|
- // trusted by Google.
|
|
- if (!api_key_.empty() && request_url.SchemeIs(url::kHttpsScheme) &&
|
|
- google_util::IsGoogleAssociatedDomainUrl(request_url)) {
|
|
- resource_request->headers.SetHeader(kGoogApiKey, api_key_);
|
|
- }
|
|
-
|
|
- auto simple_loader = network::SimpleURLLoader::Create(
|
|
- std::move(resource_request),
|
|
- GetNetworkTrafficAnnotation(request_data.request_type));
|
|
-
|
|
- // This allows reading the error message within the API response when status
|
|
- // is not 200 (e.g., 400). Otherwise, URL loader will not give any content in
|
|
- // the response when there is a failure, which makes debugging hard.
|
|
- simple_loader->SetAllowHttpErrorResults(true);
|
|
-
|
|
- if (method == "POST") {
|
|
- const std::string content_type =
|
|
- UseApi() ? "application/x-protobuf" : "text/proto";
|
|
- // Attach payload data and add data format header.
|
|
- simple_loader->AttachStringForUpload(request_data.payload, content_type);
|
|
- }
|
|
-
|
|
- // Transfer ownership of the loader into url_loaders_. Temporarily hang
|
|
- // onto the raw pointer to use it as a key and to kick off the request;
|
|
- // transferring ownership (std::move) invalidates the |simple_loader|
|
|
- // variable.
|
|
- auto* raw_simple_loader = simple_loader.get();
|
|
- url_loaders_.push_back(std::move(simple_loader));
|
|
- raw_simple_loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
|
|
- url_loader_factory.get(),
|
|
- base::BindOnce(&AutofillDownloadManager::OnSimpleLoaderComplete,
|
|
- base::Unretained(this), std::move(--url_loaders_.end()),
|
|
- std::move(request_data), base::TimeTicks::Now()));
|
|
return true;
|
|
}
|
|
|