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

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: Autofill test failures on Android. Undo a change to autofill_test_utils.cc. Created 6 years, 6 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..85f377fe544071ed1d947c25e7aa111cf3cc4cfa 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,8 +226,51 @@ 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);
+
+ // 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);
+
+ if (pref_accessed->IsDefaultValue() && pref_enabled->IsDefaultValue()) {
+ // This is likely a new user. Reset the default value to prevent the
+ // migration from happening again.
+ prefs->SetBoolean(prefs::kAutofillUseMacAddressBook,
+ prefs->GetBoolean(prefs::kAutofillUseMacAddressBook));
+ return;
+ }
+
+ bool accessed;
+ bool enabled;
+ bool success = pref_accessed->GetValue()->GetAsBoolean(&accessed);
+ DCHECK(success);
+ success = pref_enabled->GetValue()->GetAsBoolean(&enabled);
+ DCHECK(success);
+
+ 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
// work if the delegate has a pointer to the AutofillManager, but
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698