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

Side by Side 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: Move comment. Remove DCHECKs. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 true, 207 true,
208 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 208 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
209 #else // defined(OS_MACOSX) || defined(OS_ANDROID) 209 #else // defined(OS_MACOSX) || defined(OS_ANDROID)
210 registry->RegisterBooleanPref( 210 registry->RegisterBooleanPref(
211 prefs::kAutofillAuxiliaryProfilesEnabled, 211 prefs::kAutofillAuxiliaryProfilesEnabled,
212 false, 212 false,
213 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 213 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
214 #endif // defined(OS_MACOSX) || defined(OS_ANDROID) 214 #endif // defined(OS_MACOSX) || defined(OS_ANDROID)
215 #if defined(OS_MACOSX) 215 #if defined(OS_MACOSX)
216 registry->RegisterBooleanPref( 216 registry->RegisterBooleanPref(
217 prefs::kAutofillAuxiliaryProfilesQueried, 217 prefs::kAutofillMacAddressBookQueried,
218 false, 218 false,
219 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 219 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
220 #endif // defined(OS_MACOSX) 220 #endif // defined(OS_MACOSX)
221 registry->RegisterDoublePref( 221 registry->RegisterDoublePref(
222 prefs::kAutofillPositiveUploadRate, 222 prefs::kAutofillPositiveUploadRate,
223 kAutofillPositiveUploadRateDefaultValue, 223 kAutofillPositiveUploadRateDefaultValue,
224 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 224 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
225 registry->RegisterDoublePref( 225 registry->RegisterDoublePref(
226 prefs::kAutofillNegativeUploadRate, 226 prefs::kAutofillNegativeUploadRate,
227 kAutofillNegativeUploadRateDefaultValue, 227 kAutofillNegativeUploadRateDefaultValue,
228 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 228 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
229
230 #if defined(OS_MACOSX) && !defined(OS_IOS)
231 registry->RegisterBooleanPref(
232 prefs::kAutofillUseMacAddressBook,
233 false,
234 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
235 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
229 } 236 }
230 237
238 #if defined(OS_MACOSX) && !defined(OS_IOS)
239 void AutofillManager::MigrateUserPrefs(PrefService* prefs) {
240 const PrefService::Preference* pref =
241 prefs->FindPreference(prefs::kAutofillUseMacAddressBook);
242
243 // If the pref is not its default value, then the migration has already been
244 // performed.
245 if (!pref->IsDefaultValue())
246 return;
247
248 // Whether Chrome has already tried to access the user's Address Book.
249 const PrefService::Preference* pref_accessed =
250 prefs->FindPreference(prefs::kAutofillMacAddressBookQueried);
251 // Whether the user wants to use the Address Book to populate Autofill.
252 const PrefService::Preference* pref_enabled =
253 prefs->FindPreference(prefs::kAutofillAuxiliaryProfilesEnabled);
254
255 if (pref_accessed->IsDefaultValue() && pref_enabled->IsDefaultValue()) {
256 // This is likely a new user. Reset the default value to prevent the
257 // migration from happening again.
258 prefs->SetBoolean(prefs::kAutofillUseMacAddressBook,
259 prefs->GetBoolean(prefs::kAutofillUseMacAddressBook));
260 return;
261 }
262
263 bool accessed = pref_accessed->GetValue();
264 bool enabled = pref_enabled->GetValue();
265
266 prefs->SetBoolean(prefs::kAutofillUseMacAddressBook, accessed && enabled);
267 }
268 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
269
231 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) { 270 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) {
232 // TODO(jrg): consider passing delegate into the ctor. That won't 271 // TODO(jrg): consider passing delegate into the ctor. That won't
233 // work if the delegate has a pointer to the AutofillManager, but 272 // work if the delegate has a pointer to the AutofillManager, but
234 // future directions may not need such a pointer. 273 // future directions may not need such a pointer.
235 external_delegate_ = delegate; 274 external_delegate_ = delegate;
236 autocomplete_history_manager_->SetExternalDelegate(delegate); 275 autocomplete_history_manager_->SetExternalDelegate(delegate);
237 } 276 }
238 277
239 void AutofillManager::ShowAutofillSettings() { 278 void AutofillManager::ShowAutofillSettings() {
240 manager_delegate_->ShowAutofillSettings(); 279 manager_delegate_->ShowAutofillSettings();
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 return false; 1199 return false;
1161 1200
1162 // Disregard forms that we wouldn't ever autofill in the first place. 1201 // Disregard forms that we wouldn't ever autofill in the first place.
1163 if (!form.ShouldBeParsed(true)) 1202 if (!form.ShouldBeParsed(true))
1164 return false; 1203 return false;
1165 1204
1166 return true; 1205 return true;
1167 } 1206 }
1168 1207
1169 } // namespace autofill 1208 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698