Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: components/autofill/core/browser/autofill_profile.cc

Issue 1392623002: [Autofill] Add metric for profile action on form submitted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_profile.cc
diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc
index 06a3878689035c98781c432a71e356c2b53d272a..33ac00b341ac5d20377c2d2e6c2eff75ad352634 100644
--- a/components/autofill/core/browser/autofill_profile.cc
+++ b/components/autofill/core/browser/autofill_profile.cc
@@ -23,6 +23,7 @@
#include "components/autofill/core/browser/address_i18n.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
+#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/contact_info.h"
#include "components/autofill/core/browser/phone_number.h"
@@ -509,7 +510,7 @@ void AutofillProfile::OverwriteName(const NameInfo& imported_name,
name_ = imported_name;
}
-void AutofillProfile::OverwriteWith(const AutofillProfile& profile,
+bool AutofillProfile::OverwriteWith(const AutofillProfile& profile,
const std::string& app_locale) {
// Verified profiles should never be overwritten with unverified data.
DCHECK(!IsVerified() || profile.IsVerified());
@@ -545,6 +546,8 @@ void AutofillProfile::OverwriteWith(const AutofillProfile& profile,
field_types.erase(ADDRESS_HOME_LINE2);
}
+ bool did_overwrite = false;
+
for (ServerFieldTypeSet::const_iterator iter = field_types.begin();
iter != field_types.end(); ++iter) {
FieldTypeGroup group = AutofillType(*iter).group();
@@ -555,9 +558,13 @@ void AutofillProfile::OverwriteWith(const AutofillProfile& profile,
}
base::string16 new_value = profile.GetRawInfo(*iter);
- if (!compare.StringsEqual(GetRawInfo(*iter), new_value))
+ if (!compare.StringsEqual(GetRawInfo(*iter), new_value)) {
SetRawInfo(*iter, new_value);
+ did_overwrite = true;
+ }
}
+
+ return did_overwrite;
}
bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile,
@@ -613,8 +620,15 @@ bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile,
}
}
- if (!IsVerified() || profile.IsVerified())
- OverwriteWith(profile, app_locale);
+ if (!IsVerified() || profile.IsVerified()) {
+ if (OverwriteWith(profile, app_locale)) {
+ AutofillMetrics::LogProfileActionOnFormSubmitted(
+ AutofillMetrics::EXISTING_PROFILE_UPDATED);
+ } else {
+ AutofillMetrics::LogProfileActionOnFormSubmitted(
+ AutofillMetrics::EXISTING_PROFILE_USED);
+ }
+ }
return true;
}

Powered by Google App Engine
This is Rietveld 408576698