Commit 331d5842 authored by Dominic Battre's avatar Dominic Battre Committed by Commit Bot

Log Form/Field Signature hashes

This CL introduces the logging for form and field signature hashes as
they exist in UKMs to simplify detecting a specific form and field.

R=kolos@chromium.org

Bug: 928595
Change-Id: I5a5f3a9311896e8d9ec9b46d3862e0182dbb5aa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733546Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Auto-Submit: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685244}
parent 72854559
...@@ -82,18 +82,16 @@ std::string PreviousSaveCreditCardPromptUserDecisionToString( ...@@ -82,18 +82,16 @@ std::string PreviousSaveCreditCardPromptUserDecisionToString(
return previous_response; return previous_response;
} }
// Reduce FormSignature space (in UKM) to a small range for privacy reasons. } // namespace
int64_t HashFormSignature(autofill::FormSignature form_signature) { int64_t HashFormSignature(autofill::FormSignature form_signature) {
return static_cast<uint64_t>(form_signature) % 1021; return static_cast<uint64_t>(form_signature) % 1021;
} }
// Reduce FieldSignature space (in UKM) to a small range for privacy reasons.
int64_t HashFieldSignature(autofill::FieldSignature field_signature) { int64_t HashFieldSignature(autofill::FieldSignature field_signature) {
return static_cast<uint64_t>(field_signature) % 1021; return static_cast<uint64_t>(field_signature) % 1021;
} }
} // namespace
// First, translates |field_type| to the corresponding logical |group| from // First, translates |field_type| to the corresponding logical |group| from
// |FieldTypeGroupForMetrics|. Then, interpolates this with the given |metric|, // |FieldTypeGroupForMetrics|. Then, interpolates this with the given |metric|,
// which should be in the range [0, |num_possible_metrics|). // which should be in the range [0, |num_possible_metrics|).
......
...@@ -35,6 +35,12 @@ class CreditCard; ...@@ -35,6 +35,12 @@ class CreditCard;
// A given maximum is enforced to minimize the number of buckets generated. // A given maximum is enforced to minimize the number of buckets generated.
extern const int kMaxBucketsCount; extern const int kMaxBucketsCount;
// Reduce FormSignature space (in UKM) to a small range for privacy reasons.
int64_t HashFormSignature(autofill::FormSignature form_signature);
// Reduce FieldSignature space (in UKM) to a small range for privacy reasons.
int64_t HashFieldSignature(autofill::FieldSignature field_signature);
class AutofillMetrics { class AutofillMetrics {
public: public:
enum AutofillProfileAction { enum AutofillProfileAction {
......
...@@ -2188,7 +2188,10 @@ void FormStructure::RationalizeTypeRelationships() { ...@@ -2188,7 +2188,10 @@ void FormStructure::RationalizeTypeRelationships() {
LogBuffer& operator<<(LogBuffer& buffer, const FormStructure& form) { LogBuffer& operator<<(LogBuffer& buffer, const FormStructure& form) {
buffer << Tag{"div"} << Attrib{"class", "form"}; buffer << Tag{"div"} << Attrib{"class", "form"};
buffer << Tag{"table"}; buffer << Tag{"table"};
buffer << Tr{} << "Form signature:" << form.form_signature(); buffer << Tr{} << "Form signature:"
<< base::StrCat({base::NumberToString(form.form_signature()), " - ",
base::NumberToString(
HashFormSignature(form.form_signature()))});
buffer << Tr{} << "Form name:" << form.form_name(); buffer << Tr{} << "Form name:" << form.form_name();
buffer << Tr{} << "Target URL:" << form.target_url(); buffer << Tr{} << "Target URL:" << form.target_url();
for (size_t i = 0; i < form.field_count(); ++i) { for (size_t i = 0; i < form.field_count(); ++i) {
...@@ -2197,7 +2200,11 @@ LogBuffer& operator<<(LogBuffer& buffer, const FormStructure& form) { ...@@ -2197,7 +2200,11 @@ LogBuffer& operator<<(LogBuffer& buffer, const FormStructure& form) {
const AutofillField* field = form.field(i); const AutofillField* field = form.field(i);
buffer << Tag{"td"}; buffer << Tag{"td"};
buffer << Tag{"table"}; buffer << Tag{"table"};
buffer << Tr{} << "Signature:" << field->GetFieldSignature(); buffer << Tr{} << "Signature:"
<< base::StrCat(
{base::NumberToString(field->GetFieldSignature()), " - ",
base::NumberToString(
HashFieldSignature(field->GetFieldSignature()))});
buffer << Tr{} << "Name:" << field->parseable_name(); buffer << Tr{} << "Name:" << field->parseable_name();
auto type = field->Type().ToString(); auto type = field->Type().ToString();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment