OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
| 10 #include "base/guid.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
12 #include "base/scoped_vector.h" | 13 #include "base/scoped_vector.h" |
13 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
14 #include "chrome/browser/autofill/autofill_profile.h" | 15 #include "chrome/browser/autofill/autofill_profile.h" |
15 #include "chrome/browser/autofill/phone_number.h" | 16 #include "chrome/browser/autofill/phone_number.h" |
16 #include "chrome/browser/guid.h" | |
17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // This implementation makes use of the Address Book API. Profiles are | 21 // This implementation makes use of the Address Book API. Profiles are |
22 // generated that correspond to addresses in the "me" card that reside in the | 22 // generated that correspond to addresses in the "me" card that reside in the |
23 // user's Address Book. The caller passes a vector of profiles into the | 23 // user's Address Book. The caller passes a vector of profiles into the |
24 // the constructer and then initiate the fetch from the Mac Address Book "me" | 24 // the constructer and then initiate the fetch from the Mac Address Book "me" |
25 // card using the main |GetAddressBookMeCard()| method. This clears any | 25 // card using the main |GetAddressBookMeCard()| method. This clears any |
26 // existing addresses and populates new addresses derived from the data found | 26 // existing addresses and populates new addresses derived from the data found |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 NSString* addressLabelRaw = [addresses labelAtIndex:i]; | 73 NSString* addressLabelRaw = [addresses labelAtIndex:i]; |
74 | 74 |
75 // Create a new profile where the guid is set to the guid portion of the | 75 // Create a new profile where the guid is set to the guid portion of the |
76 // |kABUIDProperty| taken from from the "me" address. The format of | 76 // |kABUIDProperty| taken from from the "me" address. The format of |
77 // the |kABUIDProperty| is "<guid>:ABPerson", so we're stripping off the | 77 // the |kABUIDProperty| is "<guid>:ABPerson", so we're stripping off the |
78 // raw guid here and using it directly. | 78 // raw guid here and using it directly. |
79 const size_t kGUIDLength = 36U; | 79 const size_t kGUIDLength = 36U; |
80 std::string guid = base::SysNSStringToUTF8( | 80 std::string guid = base::SysNSStringToUTF8( |
81 [me valueForProperty:kABUIDProperty]).substr(0, kGUIDLength); | 81 [me valueForProperty:kABUIDProperty]).substr(0, kGUIDLength); |
82 scoped_ptr<AutoFillProfile> profile(new AutoFillProfile(guid)); | 82 scoped_ptr<AutoFillProfile> profile(new AutoFillProfile(guid)); |
83 DCHECK(guid::IsValidGUID(profile->guid())); | 83 DCHECK(base::IsValidGUID(profile->guid())); |
84 | 84 |
85 // Fill in name and company information. | 85 // Fill in name and company information. |
86 GetAddressBookNames(me, addressLabelRaw, profile.get()); | 86 GetAddressBookNames(me, addressLabelRaw, profile.get()); |
87 | 87 |
88 // Fill in address information. | 88 // Fill in address information. |
89 GetAddressBookAddresses(address, profile.get()); | 89 GetAddressBookAddresses(address, profile.get()); |
90 | 90 |
91 // Fill in email information. | 91 // Fill in email information. |
92 GetAddressBookEmail(me, addressLabelRaw, profile.get()); | 92 GetAddressBookEmail(me, addressLabelRaw, profile.get()); |
93 | 93 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 } // namespace | 255 } // namespace |
256 | 256 |
257 // Populate |auxiliary_profiles_| with the Address Book data. | 257 // Populate |auxiliary_profiles_| with the Address Book data. |
258 void PersonalDataManager::LoadAuxiliaryProfiles() { | 258 void PersonalDataManager::LoadAuxiliaryProfiles() { |
259 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); | 259 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); |
260 impl.GetAddressBookMeCard(); | 260 impl.GetAddressBookMeCard(); |
261 } | 261 } |
OLD | NEW |