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

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: Fix a cross-platform problem. 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 // static 197 // static
198 void AutofillManager::RegisterProfilePrefs( 198 void AutofillManager::RegisterProfilePrefs(
199 user_prefs::PrefRegistrySyncable* registry) { 199 user_prefs::PrefRegistrySyncable* registry) {
200 registry->RegisterBooleanPref( 200 registry->RegisterBooleanPref(
201 prefs::kAutofillEnabled, 201 prefs::kAutofillEnabled,
202 true, 202 true,
203 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 203 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
204 #if defined(OS_MACOSX) || defined(OS_ANDROID) 204 #if defined(OS_MACOSX) || defined(OS_ANDROID)
205 registry->RegisterBooleanPref( 205 registry->RegisterBooleanPref(
206 prefs::kAutofillAuxiliaryProfilesEnabled, 206 prefs::kAutofillAndroidAuxiliaryProfilesEnabled,
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::kAutofillAndroidAuxiliaryProfilesEnabled,
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 registry->RegisterBooleanPref(
236 prefs::kAutofillHasMigratedUseMacAddressBookPref,
237 false,
238 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
239 #endif
229 } 240 }
230 241
242 #if defined(OS_MACOSX) && !defined(OS_IOS)
243 void AutofillManager::MigrateUserPrefs(PrefService* prefs) {
244 if (prefs->GetBoolean(prefs::kAutofillHasMigratedUseMacAddressBookPref))
Ilya Sherman 2014/06/03 23:48:59 It looks like the PrefService exports a method nam
erikchen 2014/06/04 01:51:25 Yes. I've done so.
245 return;
246
247 // Whether Chrome has already tried to access the user's Address Book.
248 bool accessed = prefs->GetBoolean(prefs::kAutofillMacAddressBookQueried);
249 // Whether the user wants to use the Address Book to populate Autofill.
250 bool enabled =
251 prefs->GetBoolean(prefs::kAutofillAndroidAuxiliaryProfilesEnabled);
Ilya Sherman 2014/06/03 23:48:59 Hmm, this looks really odd. It makes me think tha
erikchen 2014/06/04 01:51:25 I reverted to the previous name.
252
253 prefs->SetBoolean(prefs::kAutofillUseMacAddressBook, accessed && enabled);
254 prefs->SetBoolean(prefs::kAutofillHasMigratedUseMacAddressBookPref, true);
255 }
256 #endif
257
231 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) { 258 void AutofillManager::SetExternalDelegate(AutofillExternalDelegate* delegate) {
232 // TODO(jrg): consider passing delegate into the ctor. That won't 259 // TODO(jrg): consider passing delegate into the ctor. That won't
233 // work if the delegate has a pointer to the AutofillManager, but 260 // work if the delegate has a pointer to the AutofillManager, but
234 // future directions may not need such a pointer. 261 // future directions may not need such a pointer.
235 external_delegate_ = delegate; 262 external_delegate_ = delegate;
236 autocomplete_history_manager_->SetExternalDelegate(delegate); 263 autocomplete_history_manager_->SetExternalDelegate(delegate);
237 } 264 }
238 265
239 void AutofillManager::ShowAutofillSettings() { 266 void AutofillManager::ShowAutofillSettings() {
240 manager_delegate_->ShowAutofillSettings(); 267 manager_delegate_->ShowAutofillSettings();
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 return false; 1187 return false;
1161 1188
1162 // Disregard forms that we wouldn't ever autofill in the first place. 1189 // Disregard forms that we wouldn't ever autofill in the first place.
1163 if (!form.ShouldBeParsed(true)) 1190 if (!form.ShouldBeParsed(true))
1164 return false; 1191 return false;
1165 1192
1166 return true; 1193 return true;
1167 } 1194 }
1168 1195
1169 } // namespace autofill 1196 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698