#include "components/autofill/core/browser/randomized_encoder.h"
#include <algorithm>
#include <limits>
#include <string_view>
#include "base/feature_list.h"
#include "base/format_macros.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/unguessable_token.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/signatures.h"
#include "components/prefs/pref_service.h"
#include "crypto/hkdf.h"
namespace autofill {
namespace {
const RandomizedEncoder::EncodingInfo kEncodingInfo[] = …;
constexpr size_t kBitsPerByte = …;
constexpr size_t kEncodedChunkLengthInBytes = …;
constexpr size_t kMaxChunks = …;
const RandomizedEncoder::EncodingInfo* GetEncodingInfo(
AutofillRandomizedValue_EncodingType encoding_type) { … }
inline uint8_t GetBit(std::string_view s, size_t i) { … }
inline void SetBit(size_t i, uint8_t bit_value, std::string* s) { … }
std::string GetPseudoRandomBits(std::string_view secret,
std::string_view purpose,
FormSignature form_signature,
FieldSignature field_signature,
std::string_view data_type,
int encoding_length_in_bytes) { … }
AutofillRandomizedValue_EncodingType GetEncodingType(const std::string& seed) { … }
std::string GetEncodingSeed(PrefService* pref_service) { … }
}
const char RandomizedEncoder::FORM_ID[] = …;
const char RandomizedEncoder::FORM_NAME[] = …;
const char RandomizedEncoder::FORM_ACTION[] = …;
const char RandomizedEncoder::FORM_URL[] = …;
const char RandomizedEncoder::FORM_CSS_CLASS[] = …;
const char RandomizedEncoder::FORM_BUTTON_TITLES[] = …;
const char RandomizedEncoder::FIELD_ID[] = …;
const char RandomizedEncoder::FIELD_NAME[] = …;
const char RandomizedEncoder::FIELD_CONTROL_TYPE[] = …;
const char RandomizedEncoder::FIELD_LABEL[] = …;
const char RandomizedEncoder::FIELD_ARIA_LABEL[] = …;
const char RandomizedEncoder::FIELD_ARIA_DESCRIPTION[] = …;
const char RandomizedEncoder::FIELD_CSS_CLASS[] = …;
const char RandomizedEncoder::FIELD_PLACEHOLDER[] = …;
const char RandomizedEncoder::FIELD_INITIAL_VALUE_HASH[] = …;
const char RandomizedEncoder::FIELD_AUTOCOMPLETE[] = …;
const char RandomizedEncoder::kUrlKeyedAnonymizedDataCollectionEnabled[] = …;
std::unique_ptr<RandomizedEncoder> RandomizedEncoder::Create(
PrefService* pref_service) { … }
RandomizedEncoder::RandomizedEncoder(
std::string seed,
AutofillRandomizedValue_EncodingType encoding_type,
bool anonymous_url_collection_is_enabled)
: … { … }
std::string RandomizedEncoder::Encode(FormSignature form_signature,
FieldSignature field_signature,
std::string_view data_type,
std::string_view data_value) const { … }
std::string RandomizedEncoder::EncodeForTesting(
FormSignature form_signature,
FieldSignature field_signature,
std::string_view data_type,
std::u16string_view data_value) const { … }
std::string RandomizedEncoder::GetCoins(FormSignature form_signature,
FieldSignature field_signature,
std::string_view data_type,
int encoding_length_in_bytes) const { … }
std::string RandomizedEncoder::GetNoise(FormSignature form_signature,
FieldSignature field_signature,
std::string_view data_type,
int encoding_length_in_bytes) const { … }
int RandomizedEncoder::GetChunkCount(std::string_view data_value,
std::string_view data_type) const { … }
}