summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/core/browser/autofill_download_manager.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-17 17:24:03 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-06-22 07:51:41 +0000
commit774f54339e5db91f785733232d3950366db65d07 (patch)
tree068e1b47bd1af94d77094ed12b604a6b83d9c22a /chromium/components/autofill/core/browser/autofill_download_manager.cc
parentf7eaed5286974984ba5f9e3189d8f49d03e99f81 (diff)
downloadqtwebengine-chromium-774f54339e5db91f785733232d3950366db65d07.tar.gz
BASELINE: Update Chromium to 102.0.5005.57
Change-Id: I885f714bb40ee724c28f94ca6bd8dbdb39915158 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/autofill/core/browser/autofill_download_manager.cc')
-rw-r--r--chromium/components/autofill/core/browser/autofill_download_manager.cc99
1 files changed, 49 insertions, 50 deletions
diff --git a/chromium/components/autofill/core/browser/autofill_download_manager.cc b/chromium/components/autofill/core/browser/autofill_download_manager.cc
index ee7d430c303..4539acbab75 100644
--- a/chromium/components/autofill/core/browser/autofill_download_manager.cc
+++ b/chromium/components/autofill/core/browser/autofill_download_manager.cc
@@ -168,11 +168,10 @@ base::TimeDelta GetThrottleResetPeriod() {
// Returns true if |id| is within |kAutofillExperimentRanges|.
bool IsAutofillExperimentId(int id) {
- for (const auto& range : kAutofillExperimentRanges) {
- if (range.first <= id && id <= range.second)
- return true;
- }
- return false;
+ return base::ranges::any_of(kAutofillExperimentRanges, [id](auto range) {
+ const auto& [low, high] = range;
+ return low <= id && id <= high;
+ });
}
// Helper to log the HTTP |response_code| and other data received for
@@ -707,57 +706,57 @@ bool AutofillDownloadManager::StartUploadRequest(
if (!needs_logging && !allow_upload)
return false;
- AutofillUploadContents upload;
- std::vector<FormSignature> form_signatures;
- if (!form.EncodeUploadRequest(available_field_types, form_was_autofilled,
- login_form_signature, observed_submission,
- is_raw_metadata_uploading_enabled_, &upload,
- &form_signatures)) {
- return false;
- }
+ auto Upload = [&](AutofillUploadContents upload) {
+ // If this upload was a candidate for throttling, tag it and make sure that
+ // any throttling sensitive features are enforced.
+ if (can_throttle_upload) {
+ upload.set_was_throttleable(true);
- // If this upload was a candidate for throttling, tag it and make sure that
- // any throttling sensitive features are enforced.
- if (can_throttle_upload) {
- upload.set_was_throttleable(true);
-
- // Don't send randomized metadata.
- upload.clear_randomized_form_metadata();
- for (auto& f : *upload.mutable_field()) {
- f.clear_randomized_field_metadata();
+ // Don't send randomized metadata.
+ upload.clear_randomized_form_metadata();
+ for (auto& f : *upload.mutable_field())
+ f.clear_randomized_field_metadata();
}
- }
- // Get the POST payload that contains upload data.
- std::string payload;
- bool is_payload = GetUploadPayloadForApi(upload, &payload);
- // Indicate that we could not serialize upload in the payload.
- if (!is_payload) {
- return false;
- }
+ // Get the POST payload that contains upload data.
+ std::string payload;
+ bool is_payload = GetUploadPayloadForApi(upload, &payload);
+ // Indicate that we could not serialize upload in the payload.
+ if (!is_payload) {
+ return false;
+ }
- if (form.upload_required() == UPLOAD_NOT_REQUIRED) {
// If we ever need notification that upload was skipped, add it here.
- return false;
- }
+ if (form.upload_required() == UPLOAD_NOT_REQUIRED) {
+ return false;
+ }
- FormRequestData request_data;
- request_data.form_signatures = std::move(form_signatures);
- request_data.request_type = AutofillDownloadManager::REQUEST_UPLOAD;
- request_data.payload = std::move(payload);
+ FormRequestData request_data;
+ request_data.form_signatures = {form.form_signature()};
+ request_data.request_type = AutofillDownloadManager::REQUEST_UPLOAD;
+ request_data.payload = std::move(payload);
+
+ DVLOG(1) << "Sending Autofill Upload Request:\n" << upload;
+ if (log_manager_) {
+ log_manager_->Log() << LoggingScope::kAutofillServer
+ << LogMessage::kSendAutofillUpload << Br{}
+ << "Allow upload?: " << allow_upload << Br{}
+ << "Data: " << Br{} << upload;
+ }
- DVLOG(1) << "Sending Autofill Upload Request:\n" << upload;
- if (log_manager_) {
- log_manager_->Log() << LoggingScope::kAutofillServer
- << LogMessage::kSendAutofillUpload << Br{}
- << "Allow upload?: " << allow_upload << Br{}
- << "Data: " << Br{} << upload;
- }
+ if (!allow_upload)
+ return false;
- if (!allow_upload)
- return false;
+ return StartRequest(std::move(request_data));
+ };
- return StartRequest(std::move(request_data));
+ std::vector<AutofillUploadContents> uploads = form.EncodeUploadRequest(
+ available_field_types, form_was_autofilled, login_form_signature,
+ observed_submission, is_raw_metadata_uploading_enabled_);
+ bool all_succeeded = !uploads.empty();
+ for (AutofillUploadContents& upload : uploads)
+ all_succeeded &= Upload(std::move(upload));
+ return all_succeeded;
}
void AutofillDownloadManager::ClearUploadHistory(PrefService* pref_service) {
@@ -914,10 +913,10 @@ void AutofillDownloadManager::CacheQueryRequest(
bool AutofillDownloadManager::CheckCacheForQueryRequest(
const std::vector<FormSignature>& forms_in_query,
std::string* query_data) const {
- for (const auto& it : cached_forms_) {
- if (it.first == forms_in_query) {
+ for (const auto& [signatures, cached_data] : cached_forms_) {
+ if (signatures == forms_in_query) {
// We hit the cache, fill the data and return.
- *query_data = it.second;
+ *query_data = cached_data;
return true;
}
}