Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: chrome/browser/autofill/personal_data_manager_mac.mm

Issue 7892048: Autofill: Remove fax number completely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
94 // Fill in phone and fax number information. 94 // Fill in phone number information.
95 GetAddressBookPhoneNumbers(me, addressLabelRaw, profile.get()); 95 GetAddressBookPhoneNumbers(me, addressLabelRaw, profile.get());
96 96
97 profiles_.push_back(profile.release()); 97 profiles_.push_back(profile.release());
98 } 98 }
99 } 99 }
100 } 100 }
101 101
102 // Name and company information is stored once in the Address Book against 102 // Name and company information is stored once in the Address Book against
103 // multiple addresses. We replicate that information for each profile. 103 // multiple addresses. We replicate that information for each profile.
104 // We only propagate the company name to work profiles. 104 // We only propagate the company name to work profiles.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 NSString* emailAddressLabelRaw = [emailAddresses labelAtIndex:j]; 175 NSString* emailAddressLabelRaw = [emailAddresses labelAtIndex:j];
176 if ([emailAddressLabelRaw isEqualToString:addressLabelRaw]) { 176 if ([emailAddressLabelRaw isEqualToString:addressLabelRaw]) {
177 emailAddress = [emailAddresses valueAtIndex:j]; 177 emailAddress = [emailAddresses valueAtIndex:j];
178 break; 178 break;
179 } 179 }
180 } 180 }
181 profile->SetInfo(EMAIL_ADDRESS, base::SysNSStringToUTF16(emailAddress)); 181 profile->SetInfo(EMAIL_ADDRESS, base::SysNSStringToUTF16(emailAddress));
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 two cases: home/tel, work/tel.
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 ABMultiValue* phoneNumbers = [me valueForProperty:kABPhoneProperty]; 192 ABMultiValue* phoneNumbers = [me valueForProperty:kABPhoneProperty];
193 for (NSUInteger k = 0, phoneCount = [phoneNumbers count]; 193 for (NSUInteger k = 0, phoneCount = [phoneNumbers count];
194 k < phoneCount; k++) { 194 k < phoneCount; k++) {
195 NSUInteger reverseK = phoneCount - k - 1; 195 NSUInteger reverseK = phoneCount - k - 1;
196 NSString* phoneLabelRaw = [phoneNumbers labelAtIndex:reverseK]; 196 NSString* phoneLabelRaw = [phoneNumbers labelAtIndex:reverseK];
197 if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] && 197 if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] &&
198 [phoneLabelRaw isEqualToString:kABPhoneHomeLabel]) { 198 [phoneLabelRaw isEqualToString:kABPhoneHomeLabel]) {
199 string16 homePhone = base::SysNSStringToUTF16( 199 string16 homePhone = base::SysNSStringToUTF16(
200 [phoneNumbers valueAtIndex:reverseK]); 200 [phoneNumbers valueAtIndex:reverseK]);
201 profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, homePhone); 201 profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, homePhone);
202 } else if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] &&
203 [phoneLabelRaw isEqualToString:kABPhoneHomeFAXLabel]) {
204 string16 homeFax = base::SysNSStringToUTF16(
205 [phoneNumbers valueAtIndex:reverseK]);
206 profile->SetInfo(PHONE_FAX_WHOLE_NUMBER, homeFax);
207 } else if ([addressLabelRaw isEqualToString:kABAddressWorkLabel] && 202 } else if ([addressLabelRaw isEqualToString:kABAddressWorkLabel] &&
208 [phoneLabelRaw isEqualToString:kABPhoneWorkLabel]) { 203 [phoneLabelRaw isEqualToString:kABPhoneWorkLabel]) {
209 string16 workPhone = base::SysNSStringToUTF16( 204 string16 workPhone = base::SysNSStringToUTF16(
210 [phoneNumbers valueAtIndex:reverseK]); 205 [phoneNumbers valueAtIndex:reverseK]);
211 profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, workPhone); 206 profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, workPhone);
212 } else if ([addressLabelRaw isEqualToString:kABAddressWorkLabel] &&
213 [phoneLabelRaw isEqualToString:kABPhoneWorkFAXLabel]) {
214 string16 workFax = base::SysNSStringToUTF16(
215 [phoneNumbers valueAtIndex:reverseK]);
216 profile->SetInfo(PHONE_FAX_WHOLE_NUMBER, workFax);
217 } else if ([phoneLabelRaw isEqualToString:kABPhoneMobileLabel] || 207 } else if ([phoneLabelRaw isEqualToString:kABPhoneMobileLabel] ||
218 [phoneLabelRaw isEqualToString:kABPhoneMainLabel]) { 208 [phoneLabelRaw isEqualToString:kABPhoneMainLabel]) {
219 string16 phone = base::SysNSStringToUTF16( 209 string16 phone = base::SysNSStringToUTF16(
220 [phoneNumbers valueAtIndex:reverseK]); 210 [phoneNumbers valueAtIndex:reverseK]);
221 profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, phone); 211 profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, phone);
222 } 212 }
223 } 213 }
224 } 214 }
225 215
226 } // namespace 216 } // namespace
227 217
228 // Populate |auxiliary_profiles_| with the Address Book data. 218 // Populate |auxiliary_profiles_| with the Address Book data.
229 void PersonalDataManager::LoadAuxiliaryProfiles() const { 219 void PersonalDataManager::LoadAuxiliaryProfiles() const {
230 AuxiliaryProfilesImpl impl(&auxiliary_profiles_); 220 AuxiliaryProfilesImpl impl(&auxiliary_profiles_);
231 impl.GetAddressBookMeCard(); 221 impl.GetAddressBookMeCard();
232 } 222 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/personal_data_manager.cc ('k') | chrome/browser/autofill/personal_data_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698