#include "components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_encoding.h"
#include <algorithm>
#include <deque>
#include <string>
#include <string_view>
#include <vector>
#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "base/types/optional_ref.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure_rationalizer.h"
#include "components/autofill/core/browser/form_structure_sectioning_util.h"
#include "components/autofill/core/browser/metrics/log_event.h"
#include "components/autofill/core/browser/randomized_encoder.h"
#include "components/autofill/core/browser/server_prediction_overrides.h"
#include "components/autofill/core/browser/validation.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_internals/log_message.h"
#include "components/autofill/core/common/autofill_internals/logging_scope.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/logging/log_buffer.h"
#include "components/version_info/version_info.h"
namespace autofill {
namespace {
std::ostream& operator<<(std::ostream& out,
const AutofillQueryResponse& response) { … }
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
std::deque<FieldSuggestion> MergeManualAndServerOverrides(
std::deque<FieldSuggestion> manual_overrides,
std::deque<FieldSuggestion> server_overrides) { … }
void InsertParsedOverrides(
base::expected<ServerPredictionOverrides, std::string> parsed_overrides,
std::map<std::pair<FormSignature, FieldSignature>,
std::deque<FieldSuggestion>>& field_types) { … }
#endif
std::string EncodeFieldTypes(const FieldTypeSet& available_field_types) { … }
FieldType FirstNonCapturedType(const FormStructure& form,
const FieldTypeSet& contained_types) { … }
bool IsMalformed(const FormStructure& form) { … }
void EncodeRandomizedValue(const RandomizedEncoder& encoder,
FormSignature form_signature,
FieldSignature field_signature,
std::string_view data_type,
std::string_view data_value,
bool include_checksum,
AutofillRandomizedValue* output) { … }
void EncodeRandomizedValue(const RandomizedEncoder& encoder,
FormSignature form_signature,
FieldSignature field_signature,
std::string_view data_type,
std::u16string_view data_value,
bool include_checksum,
AutofillRandomizedValue* output) { … }
void PopulateRandomizedFormMetadata(const RandomizedEncoder& encoder,
const FormStructure& form,
AutofillRandomizedFormMetadata* metadata) { … }
void PopulateRandomizedFieldMetadata(
const RandomizedEncoder& encoder,
const FormStructure& form,
const AutofillField& field,
AutofillRandomizedFieldMetadata* metadata) { … }
void EncodeFormFieldsForUpload(const FormStructure& form,
base::span<AutofillField*> upload_fields,
AutofillUploadContents* upload) { … }
void EncodeFormForQuery(const autofill::FormStructure& form,
AutofillPageQueryRequest& query,
std::vector<FormSignature>& queried_form_signatures,
std::set<FormSignature>& processed_forms) { … }
bool HasPasswordManagerPrediction(const FieldSuggestion& field_suggestion) { … }
void MergePasswordManagerPredictions(
const FieldSuggestion& merge_from_predictions,
FieldSuggestion& merge_to_predictions) { … }
std::optional<FieldSuggestion> GetFieldSuggestion(
const FormStructure& form,
const AutofillField& field,
std::map<std::pair<FormSignature, FieldSignature>,
std::deque<FieldSuggestion>>& fields_suggestions) { … }
std::map<std::pair<FormSignature, FieldSignature>, std::deque<FieldSuggestion>>
GetSuggestionsMapFromResponse(
const AutofillQueryResponse& response,
const std::vector<FormSignature>& queried_form_signatures) { … }
}
std::vector<AutofillUploadContents> EncodeUploadRequest(
const FormStructure& form,
const FieldTypeSet& available_field_types,
std::string_view login_form_signature,
bool observed_submission) { … }
std::pair<AutofillPageQueryRequest, std::vector<FormSignature>>
EncodeAutofillPageQueryRequest(
const std::vector<raw_ptr<FormStructure, VectorExperimental>>& forms) { … }
void ParseServerPredictionsQueryResponse(
std::string_view payload,
const std::vector<raw_ptr<FormStructure, VectorExperimental>>& forms,
const std::vector<FormSignature>& queried_form_signatures,
AutofillMetrics::FormInteractionsUkmLogger* form_interactions_ukm_logger,
LogManager* log_manager) { … }
void ProcessServerPredictionsQueryResponse(
const AutofillQueryResponse& response,
const std::vector<raw_ptr<FormStructure, VectorExperimental>>& forms,
const std::vector<FormSignature>& queried_form_signatures,
AutofillMetrics::FormInteractionsUkmLogger* form_interactions_ukm_logger,
LogManager* log_manager) { … }
}