| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/autofill/personal_data_manager.h" | 5 #include "chrome/browser/autofill/personal_data_manager.h" |
| 6 | 6 |
| 7 #import <AddressBook/AddressBook.h> | 7 #import <AddressBook/AddressBook.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Fills in telephone numbers. Each of these are special cases. | 184 // Fills in telephone numbers. Each of these are special cases. |
| 185 // We match four cases: home/tel, home/fax, work/tel, work/fax. | 185 // We match four cases: home/tel, home/fax, work/tel, work/fax. |
| 186 // Note, we traverse in reverse order so that top values in address book | 186 // Note, we traverse in reverse order so that top values in address book |
| 187 // take priority. | 187 // take priority. |
| 188 void AuxiliaryProfilesImpl::GetAddressBookPhoneNumbers( | 188 void AuxiliaryProfilesImpl::GetAddressBookPhoneNumbers( |
| 189 ABPerson* me, | 189 ABPerson* me, |
| 190 NSString* addressLabelRaw, | 190 NSString* addressLabelRaw, |
| 191 AutofillProfile* profile) { | 191 AutofillProfile* profile) { |
| 192 /* |
| 192 string16 number; | 193 string16 number; |
| 193 string16 city_code; | 194 string16 city_code; |
| 194 string16 country_code; | 195 string16 country_code; |
| 195 | 196 |
| 196 ABMultiValue* phoneNumbers = [me valueForProperty:kABPhoneProperty]; | 197 ABMultiValue* phoneNumbers = [me valueForProperty:kABPhoneProperty]; |
| 197 for (NSUInteger k = 0, phoneCount = [phoneNumbers count]; | 198 for (NSUInteger k = 0, phoneCount = [phoneNumbers count]; |
| 198 k < phoneCount; k++) { | 199 k < phoneCount; k++) { |
| 199 NSUInteger reverseK = phoneCount - k - 1; | 200 NSUInteger reverseK = phoneCount - k - 1; |
| 200 NSString* phoneLabelRaw = [phoneNumbers labelAtIndex:reverseK]; | 201 NSString* phoneLabelRaw = [phoneNumbers labelAtIndex:reverseK]; |
| 201 if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] && | 202 if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] && |
| (...skipping 27 matching lines...) Expand all Loading... |
| 229 [phoneLabelRaw isEqualToString:kABPhoneWorkFAXLabel]) { | 230 [phoneLabelRaw isEqualToString:kABPhoneWorkFAXLabel]) { |
| 230 string16 workFax = base::SysNSStringToUTF16( | 231 string16 workFax = base::SysNSStringToUTF16( |
| 231 [phoneNumbers valueAtIndex:reverseK]); | 232 [phoneNumbers valueAtIndex:reverseK]); |
| 232 PhoneNumber::ParsePhoneNumber(workFax, | 233 PhoneNumber::ParsePhoneNumber(workFax, |
| 233 &number, &city_code, &country_code); | 234 &number, &city_code, &country_code); |
| 234 profile->SetInfo(PHONE_FAX_NUMBER, number); | 235 profile->SetInfo(PHONE_FAX_NUMBER, number); |
| 235 profile->SetInfo(PHONE_FAX_CITY_CODE, city_code); | 236 profile->SetInfo(PHONE_FAX_CITY_CODE, city_code); |
| 236 profile->SetInfo(PHONE_FAX_COUNTRY_CODE, country_code); | 237 profile->SetInfo(PHONE_FAX_COUNTRY_CODE, country_code); |
| 237 } | 238 } |
| 238 } | 239 } |
| 240 */ |
| 239 } | 241 } |
| 240 | 242 |
| 241 } // namespace | 243 } // namespace |
| 242 | 244 |
| 243 // Populate |auxiliary_profiles_| with the Address Book data. | 245 // Populate |auxiliary_profiles_| with the Address Book data. |
| 244 void PersonalDataManager::LoadAuxiliaryProfiles() const { | 246 void PersonalDataManager::LoadAuxiliaryProfiles() const { |
| 245 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); | 247 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); |
| 246 impl.GetAddressBookMeCard(); | 248 impl.GetAddressBookMeCard(); |
| 247 } | 249 } |
| OLD | NEW |