OLD | NEW |
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/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #import <AddressBook/AddressBook.h> | 9 #import <AddressBook/AddressBook.h> |
10 | 10 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 } // namespace | 298 } // namespace |
299 | 299 |
300 // Populate |auxiliary_profiles_| with the Address Book data. | 300 // Populate |auxiliary_profiles_| with the Address Book data. |
301 void PersonalDataManager::LoadAuxiliaryProfiles() const { | 301 void PersonalDataManager::LoadAuxiliaryProfiles() const { |
302 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); | 302 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); |
303 impl.GetAddressBookMeCard(app_locale_, pref_service_); | 303 impl.GetAddressBookMeCard(app_locale_, pref_service_); |
304 } | 304 } |
305 | 305 |
306 bool PersonalDataManager::AccessAddressBook() { | 306 bool PersonalDataManager::AccessAddressBook() { |
307 if (!pref_service_->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)) | 307 // The user is attempting to give Chrome access to the user's Address Book. |
308 return false; | 308 // This implicitly acknowledges that the user wants to use auxiliary |
| 309 // profiles. |
| 310 pref_service_->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, true); |
309 | 311 |
310 if (HasPromptedForAccessToAddressBook(pref_service_)) | 312 if (HasPromptedForAccessToAddressBook(pref_service_)) |
311 return false; | 313 return false; |
312 | 314 |
313 // Request permissions. | 315 // Request permissions. |
314 GetAddressBook(pref_service_); | 316 GetAddressBook(pref_service_); |
315 return true; | 317 return true; |
316 } | 318 } |
317 | 319 |
318 bool PersonalDataManager::ShouldShowAccessAddressBookSuggestion( | 320 bool PersonalDataManager::ShouldShowAccessAddressBookSuggestion( |
319 AutofillType type) { | 321 AutofillType type) { |
320 if (!pref_service_->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)) | |
321 return false; | |
322 | |
323 if (HasPromptedForAccessToAddressBook(pref_service_)) | 322 if (HasPromptedForAccessToAddressBook(pref_service_)) |
324 return false; | 323 return false; |
325 | 324 |
326 switch (type.group()) { | 325 switch (type.group()) { |
327 case ADDRESS_BILLING: | 326 case ADDRESS_BILLING: |
328 case ADDRESS_HOME: | 327 case ADDRESS_HOME: |
329 case EMAIL: | 328 case EMAIL: |
330 case NAME: | 329 case NAME: |
331 case NAME_BILLING: | 330 case NAME_BILLING: |
332 case PHONE_BILLING: | 331 case PHONE_BILLING: |
333 case PHONE_HOME: | 332 case PHONE_HOME: |
334 return true; | 333 return true; |
335 case NO_GROUP: | 334 case NO_GROUP: |
336 case COMPANY: | 335 case COMPANY: |
337 case CREDIT_CARD: | 336 case CREDIT_CARD: |
338 case PASSWORD_FIELD: | 337 case PASSWORD_FIELD: |
339 return false; | 338 return false; |
340 } | 339 } |
341 | 340 |
342 return false; | 341 return false; |
343 } | 342 } |
344 | 343 |
345 } // namespace autofill | 344 } // namespace autofill |
OLD | NEW |