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

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

Issue 301343002: mac: Clean up autofill integration with Address Book. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autofill_cleanup2_base
Patch Set: Address more comments from isherman. Created 6 years, 7 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_manager.cc
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index 8bceedd686b0bc8d9a61a4f6bee5dcdac12f4ca8..60783ebbd005180e90e77113d9d6ad688a05a204 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -214,7 +214,7 @@ void AutofillManager::RegisterProfilePrefs(
#endif // defined(OS_MACOSX) || defined(OS_ANDROID)
#if defined(OS_MACOSX)
registry->RegisterBooleanPref(
- prefs::kAutofillAuxiliaryProfilesQueried,
+ prefs::kAutofillMacAddressBookQueried,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif // defined(OS_MACOSX)
@@ -226,7 +226,49 @@ void AutofillManager::RegisterProfilePrefs(
prefs::kAutofillNegativeUploadRate,
kAutofillNegativeUploadRateDefaultValue,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ registry->RegisterBooleanPref(
+ prefs::kAutofillUseMacAddressBook,
+ false,
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+}
+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+void AutofillManager::MigrateUserPrefs(PrefService* prefs) {
+ const PrefService::Preference* pref =
+ prefs->FindPreference(prefs::kAutofillUseMacAddressBook);
+ DCHECK(pref);
Ilya Sherman 2014/06/04 22:46:41 nit: Since you use this variable immediately below
erikchen 2014/06/04 22:50:05 Good to know, thanks! Done.
+
+ // If the pref is not its default value, then the migration has already been
+ // performed.
+ if (!pref->IsDefaultValue())
+ return;
+
+ // Whether Chrome has already tried to access the user's Address Book.
+ const PrefService::Preference* pref_accessed =
+ prefs->FindPreference(prefs::kAutofillMacAddressBookQueried);
+ // Whether the user wants to use the Address Book to populate Autofill.
+ const PrefService::Preference* pref_enabled =
+ prefs->FindPreference(prefs::kAutofillAuxiliaryProfilesEnabled);
+ DCHECK(pref_accessed);
+ DCHECK(pref_enabled);
+
+ // This is likely a new user. Reset the default value to prevent the migration
+ // from happening again.
Ilya Sherman 2014/06/04 22:46:41 nit: Please move this comment into the if-stmt. G
erikchen 2014/06/04 22:50:05 Okay!
+ if (pref_accessed->IsDefaultValue() && pref_enabled->IsDefaultValue()) {
+ prefs->SetBoolean(prefs::kAutofillUseMacAddressBook,
+ prefs->GetBoolean(prefs::kAutofillUseMacAddressBook));
+ return;
+ }
Ilya Sherman 2014/06/04 20:46:09 Hmm, is this extra work necessary? The default va
erikchen 2014/06/04 21:13:03 I want to make sure that the migration code is cal
Ilya Sherman 2014/06/04 21:21:03 I'm not following what you mean -- line 269 would
Ilya Sherman 2014/06/04 22:21:45 ^^^
erikchen 2014/06/04 22:27:08 Ack, I misread your comment. Yes, I would like thi
Ilya Sherman 2014/06/04 22:46:41 Hrm, alright.
+
+ bool accessed = pref_accessed->GetValue();
+ bool enabled = pref_enabled->GetValue();
+
+ prefs->SetBoolean(prefs::kAutofillUseMacAddressBook, accessed && enabled);
}
+#endif // defined(OS_MACOSX) && !defined(OS_IOS)
void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) {
// TODO(jrg): consider passing delegate into the ctor. That won't

Powered by Google App Engine
This is Rietveld 408576698