| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/personal_data_manager.h" | 5 #include "components/autofill/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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 ABPerson* me, | 233 ABPerson* me, |
| 234 NSString* addressLabelRaw, | 234 NSString* addressLabelRaw, |
| 235 AutofillProfile* profile) { | 235 AutofillProfile* profile) { |
| 236 ABMultiValue* phoneNumbers = [me valueForProperty:kABPhoneProperty]; | 236 ABMultiValue* phoneNumbers = [me valueForProperty:kABPhoneProperty]; |
| 237 for (NSUInteger k = 0, phoneCount = [phoneNumbers count]; | 237 for (NSUInteger k = 0, phoneCount = [phoneNumbers count]; |
| 238 k < phoneCount; k++) { | 238 k < phoneCount; k++) { |
| 239 NSUInteger reverseK = phoneCount - k - 1; | 239 NSUInteger reverseK = phoneCount - k - 1; |
| 240 NSString* phoneLabelRaw = [phoneNumbers labelAtIndex:reverseK]; | 240 NSString* phoneLabelRaw = [phoneNumbers labelAtIndex:reverseK]; |
| 241 if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] && | 241 if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] && |
| 242 [phoneLabelRaw isEqualToString:kABPhoneHomeLabel]) { | 242 [phoneLabelRaw isEqualToString:kABPhoneHomeLabel]) { |
| 243 string16 homePhone = base::SysNSStringToUTF16( | 243 base::string16 homePhone = base::SysNSStringToUTF16( |
| 244 [phoneNumbers valueAtIndex:reverseK]); | 244 [phoneNumbers valueAtIndex:reverseK]); |
| 245 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, homePhone); | 245 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, homePhone); |
| 246 } else if ([addressLabelRaw isEqualToString:kABAddressWorkLabel] && | 246 } else if ([addressLabelRaw isEqualToString:kABAddressWorkLabel] && |
| 247 [phoneLabelRaw isEqualToString:kABPhoneWorkLabel]) { | 247 [phoneLabelRaw isEqualToString:kABPhoneWorkLabel]) { |
| 248 string16 workPhone = base::SysNSStringToUTF16( | 248 base::string16 workPhone = base::SysNSStringToUTF16( |
| 249 [phoneNumbers valueAtIndex:reverseK]); | 249 [phoneNumbers valueAtIndex:reverseK]); |
| 250 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, workPhone); | 250 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, workPhone); |
| 251 } else if ([phoneLabelRaw isEqualToString:kABPhoneMobileLabel] || | 251 } else if ([phoneLabelRaw isEqualToString:kABPhoneMobileLabel] || |
| 252 [phoneLabelRaw isEqualToString:kABPhoneMainLabel]) { | 252 [phoneLabelRaw isEqualToString:kABPhoneMainLabel]) { |
| 253 string16 phone = base::SysNSStringToUTF16( | 253 base::string16 phone = base::SysNSStringToUTF16( |
| 254 [phoneNumbers valueAtIndex:reverseK]); | 254 [phoneNumbers valueAtIndex:reverseK]); |
| 255 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, phone); | 255 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, phone); |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace | 260 } // namespace |
| 261 | 261 |
| 262 // Populate |auxiliary_profiles_| with the Address Book data. | 262 // Populate |auxiliary_profiles_| with the Address Book data. |
| 263 void PersonalDataManager::LoadAuxiliaryProfiles() { | 263 void PersonalDataManager::LoadAuxiliaryProfiles() { |
| 264 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); | 264 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); |
| 265 impl.GetAddressBookMeCard(app_locale_); | 265 impl.GetAddressBookMeCard(app_locale_); |
| 266 } | 266 } |
| OLD | NEW |