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 |
11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #import "base/mac/scoped_nsexception_enabler.h" | 14 #import "base/mac/scoped_nsexception_enabler.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
19 #include "components/autofill/core/browser/autofill_country.h" | 19 #include "components/autofill/core/browser/autofill_country.h" |
20 #include "components/autofill/core/browser/autofill_profile.h" | 20 #include "components/autofill/core/browser/autofill_profile.h" |
| 21 #include "components/autofill/core/browser/autofill_type.h" |
21 #include "components/autofill/core/browser/phone_number.h" | 22 #include "components/autofill/core/browser/phone_number.h" |
22 #include "grit/component_strings.h" | 23 #include "grit/component_strings.h" |
23 #include "ui/base/l10n/l10n_util_mac.h" | 24 #include "ui/base/l10n/l10n_util_mac.h" |
24 | 25 |
25 namespace autofill { | 26 namespace autofill { |
26 namespace { | 27 namespace { |
27 | 28 |
28 const char kAddressBookOrigin[] = "OS X Address Book"; | 29 const char kAddressBookOrigin[] = "OS X Address Book"; |
29 | 30 |
30 // This implementation makes use of the Address Book API. Profiles are | 31 // This implementation makes use of the Address Book API. Profiles are |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (NSString* city = [address objectForKey:kABAddressCityKey]) | 197 if (NSString* city = [address objectForKey:kABAddressCityKey]) |
197 profile->SetRawInfo(ADDRESS_HOME_CITY, base::SysNSStringToUTF16(city)); | 198 profile->SetRawInfo(ADDRESS_HOME_CITY, base::SysNSStringToUTF16(city)); |
198 | 199 |
199 if (NSString* state = [address objectForKey:kABAddressStateKey]) | 200 if (NSString* state = [address objectForKey:kABAddressStateKey]) |
200 profile->SetRawInfo(ADDRESS_HOME_STATE, base::SysNSStringToUTF16(state)); | 201 profile->SetRawInfo(ADDRESS_HOME_STATE, base::SysNSStringToUTF16(state)); |
201 | 202 |
202 if (NSString* zip = [address objectForKey:kABAddressZIPKey]) | 203 if (NSString* zip = [address objectForKey:kABAddressZIPKey]) |
203 profile->SetRawInfo(ADDRESS_HOME_ZIP, base::SysNSStringToUTF16(zip)); | 204 profile->SetRawInfo(ADDRESS_HOME_ZIP, base::SysNSStringToUTF16(zip)); |
204 | 205 |
205 if (NSString* country = [address objectForKey:kABAddressCountryKey]) { | 206 if (NSString* country = [address objectForKey:kABAddressCountryKey]) { |
206 profile->SetInfo(ADDRESS_HOME_COUNTRY, | 207 profile->SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), |
207 base::SysNSStringToUTF16(country), | 208 base::SysNSStringToUTF16(country), |
208 app_locale); | 209 app_locale); |
209 } | 210 } |
210 } | 211 } |
211 | 212 |
212 // Fills in email address matching current address label. Note that there may | 213 // Fills in email address matching current address label. Note that there may |
213 // be multiple matching email addresses for a given label. We take the | 214 // be multiple matching email addresses for a given label. We take the |
214 // first we find (topmost) as preferred. | 215 // first we find (topmost) as preferred. |
215 void AuxiliaryProfilesImpl::GetAddressBookEmail( | 216 void AuxiliaryProfilesImpl::GetAddressBookEmail( |
216 ABPerson* me, | 217 ABPerson* me, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 264 |
264 } // namespace | 265 } // namespace |
265 | 266 |
266 // Populate |auxiliary_profiles_| with the Address Book data. | 267 // Populate |auxiliary_profiles_| with the Address Book data. |
267 void PersonalDataManager::LoadAuxiliaryProfiles() { | 268 void PersonalDataManager::LoadAuxiliaryProfiles() { |
268 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); | 269 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); |
269 impl.GetAddressBookMeCard(app_locale_); | 270 impl.GetAddressBookMeCard(app_locale_); |
270 } | 271 } |
271 | 272 |
272 } // namespace autofill | 273 } // namespace autofill |
OLD | NEW |