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

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: Address more comments from isherman. 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 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.
243
244 // If the pref is not its default value, then the migration has already been
245 // performed.
246 if (!pref->IsDefaultValue())
247 return;
248
249 // Whether Chrome has already tried to access the user's Address Book.
250 const PrefService::Preference* pref_accessed =
251 prefs->FindPreference(prefs::kAutofillMacAddressBookQueried);
252 // Whether the user wants to use the Address Book to populate Autofill.
253 const PrefService::Preference* pref_enabled =
254 prefs->FindPreference(prefs::kAutofillAuxiliaryProfilesEnabled);
255 DCHECK(pref_accessed);
256 DCHECK(pref_enabled);
257
258 // This is likely a new user. Reset the default value to prevent the migration
259 // 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!
260 if (pref_accessed->IsDefaultValue() && pref_enabled->IsDefaultValue()) {
261 prefs->SetBoolean(prefs::kAutofillUseMacAddressBook,
262 prefs->GetBoolean(prefs::kAutofillUseMacAddressBook));
263 return;
264 }
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.
265
266 bool accessed = pref_accessed->GetValue();
267 bool enabled = pref_enabled->GetValue();
268
269 prefs->SetBoolean(prefs::kAutofillUseMacAddressBook, accessed && enabled);
270 }
271 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
272
231 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) { 273 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) {
232 // TODO(jrg): consider passing delegate into the ctor. That won't 274 // TODO(jrg): consider passing delegate into the ctor. That won't
233 // work if the delegate has a pointer to the AutofillManager, but 275 // work if the delegate has a pointer to the AutofillManager, but
234 // future directions may not need such a pointer. 276 // future directions may not need such a pointer.
235 external_delegate_ = delegate; 277 external_delegate_ = delegate;
236 autocomplete_history_manager_->SetExternalDelegate(delegate); 278 autocomplete_history_manager_->SetExternalDelegate(delegate);
237 } 279 }
238 280
239 void AutofillManager::ShowAutofillSettings() { 281 void AutofillManager::ShowAutofillSettings() {
240 manager_delegate_->ShowAutofillSettings(); 282 manager_delegate_->ShowAutofillSettings();
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 return false; 1202 return false;
1161 1203
1162 // Disregard forms that we wouldn't ever autofill in the first place. 1204 // Disregard forms that we wouldn't ever autofill in the first place.
1163 if (!form.ShouldBeParsed(true)) 1205 if (!form.ShouldBeParsed(true))
1164 return false; 1206 return false;
1165 1207
1166 return true; 1208 return true;
1167 } 1209 }
1168 1210
1169 } // namespace autofill 1211 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698