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 #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/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
15 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
16 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
17 #include "chrome/browser/autofill/autofill_profile.h" | 18 #include "chrome/browser/autofill/autofill_profile.h" |
18 #include "chrome/browser/autofill/phone_number.h" | 19 #include "chrome/browser/autofill/phone_number.h" |
19 #include "chrome/common/guid.h" | |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "ui/base/l10n/l10n_util_mac.h" | 21 #include "ui/base/l10n/l10n_util_mac.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // This implementation makes use of the Address Book API. Profiles are | 25 // This implementation makes use of the Address Book API. Profiles are |
26 // generated that correspond to addresses in the "me" card that reside in the | 26 // generated that correspond to addresses in the "me" card that reside in the |
27 // user's Address Book. The caller passes a vector of profiles into the | 27 // user's Address Book. The caller passes a vector of profiles into the |
28 // the constructer and then initiate the fetch from the Mac Address Book "me" | 28 // the constructer and then initiate the fetch from the Mac Address Book "me" |
29 // card using the main |GetAddressBookMeCard()| method. This clears any | 29 // card using the main |GetAddressBookMeCard()| method. This clears any |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 [me valueForProperty:kABUIDProperty]).substr(0, kTrimmedGUIDLength); | 100 [me valueForProperty:kABUIDProperty]).substr(0, kTrimmedGUIDLength); |
101 | 101 |
102 // The format string to print |kNumAddressGUIDChars| hexadecimal characters, | 102 // The format string to print |kNumAddressGUIDChars| hexadecimal characters, |
103 // left-padded with 0's. | 103 // left-padded with 0's. |
104 const std::string kAddressGUIDFormat = | 104 const std::string kAddressGUIDFormat = |
105 base::StringPrintf("%%0%" PRIuS "X", kNumAddressGUIDChars); | 105 base::StringPrintf("%%0%" PRIuS "X", kNumAddressGUIDChars); |
106 guid += base::StringPrintf(kAddressGUIDFormat.c_str(), i); | 106 guid += base::StringPrintf(kAddressGUIDFormat.c_str(), i); |
107 DCHECK_EQ(kGUIDLength, guid.size()); | 107 DCHECK_EQ(kGUIDLength, guid.size()); |
108 | 108 |
109 scoped_ptr<AutofillProfile> profile(new AutofillProfile(guid)); | 109 scoped_ptr<AutofillProfile> profile(new AutofillProfile(guid)); |
110 DCHECK(guid::IsValidGUID(profile->guid())); | 110 DCHECK(base::IsValidGUID(profile->guid())); |
111 | 111 |
112 // Fill in name and company information. | 112 // Fill in name and company information. |
113 GetAddressBookNames(me, addressLabelRaw, profile.get()); | 113 GetAddressBookNames(me, addressLabelRaw, profile.get()); |
114 | 114 |
115 // Fill in address information. | 115 // Fill in address information. |
116 GetAddressBookAddresses(address, profile.get()); | 116 GetAddressBookAddresses(address, profile.get()); |
117 | 117 |
118 // Fill in email information. | 118 // Fill in email information. |
119 GetAddressBookEmail(me, addressLabelRaw, profile.get()); | 119 GetAddressBookEmail(me, addressLabelRaw, profile.get()); |
120 | 120 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 } // namespace | 241 } // namespace |
242 | 242 |
243 // Populate |auxiliary_profiles_| with the Address Book data. | 243 // Populate |auxiliary_profiles_| with the Address Book data. |
244 void PersonalDataManager::LoadAuxiliaryProfiles() const { | 244 void PersonalDataManager::LoadAuxiliaryProfiles() const { |
245 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); | 245 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); |
246 impl.GetAddressBookMeCard(); | 246 impl.GetAddressBookMeCard(); |
247 } | 247 } |
OLD | NEW |