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..3c5ff636bb1edc3d0704ba331223f620489e3d87 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" |
@@ -480,12 +481,15 @@ bool AutofillProfile::IsSubsetOfForFieldSet( |
return true; |
} |
-void AutofillProfile::OverwriteName(const NameInfo& imported_name, |
+bool AutofillProfile::OverwriteName(const NameInfo& imported_name, |
const std::string& app_locale) { |
if (name_.ParsedNamesAreEqual(imported_name)) { |
- if (name_.GetRawInfo(NAME_FULL).empty()) |
+ if (name_.GetRawInfo(NAME_FULL).empty() && |
+ !imported_name.GetRawInfo(NAME_FULL).empty()) { |
name_.SetRawInfo(NAME_FULL, imported_name.GetRawInfo(NAME_FULL)); |
- return; |
+ return true; |
+ } |
+ return false; |
} |
l10n::CaseInsensitiveCompare compare; |
@@ -503,13 +507,14 @@ void AutofillProfile::OverwriteName(const NameInfo& imported_name, |
NameInfo heuristically_parsed_name; |
heuristically_parsed_name.SetInfo(type, full_name, app_locale); |
if (imported_name.ParsedNamesAreEqual(heuristically_parsed_name)) |
- return; |
+ return false; |
} |
name_ = imported_name; |
+ return true; |
} |
-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,19 +550,27 @@ 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(); |
// Special case names. |
if (group == NAME) { |
- OverwriteName(profile.name_, app_locale); |
+ if (OverwriteName(profile.name_, app_locale)) { |
+ did_overwrite = true; |
Evan Stade
2015/10/14 20:42:01
nit: did_overwrite = OverwriteName() || did_overwr
sebsg
2015/10/21 17:35:26
Done.
|
+ } |
continue; |
} |
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 +626,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; |
} |