Commit 6dc54b22 authored by isherman@chromium.org's avatar isherman@chromium.org

[Autofill] Canonicalize country names loaded from the Mac OS X Address Book,...

[Autofill] Canonicalize country names loaded from the Mac OS X Address Book, according to the user's locale.

BUG=100845


Review URL: https://chromiumcodereview.appspot.com/11783043

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175761 0039d316-1c4b-4281-b951-d872f2087c98
parent 7dd4f68e
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "base/sys_string_conversions.h" #include "base/sys_string_conversions.h"
#include "chrome/browser/autofill/autofill_country.h"
#include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/autofill/phone_number.h" #include "chrome/browser/autofill/phone_number.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
...@@ -47,7 +48,7 @@ class AuxiliaryProfilesImpl { ...@@ -47,7 +48,7 @@ class AuxiliaryProfilesImpl {
void GetAddressBookNames(ABPerson* me, void GetAddressBookNames(ABPerson* me,
NSString* addressLabelRaw, NSString* addressLabelRaw,
AutofillProfile* profile); AutofillProfile* profile);
void GetAddressBookAddresses(NSDictionary* address, AutofillProfile* profile); void GetAddressBookAddress(NSDictionary* address, AutofillProfile* profile);
void GetAddressBookEmail(ABPerson* me, void GetAddressBookEmail(ABPerson* me,
NSString* addressLabelRaw, NSString* addressLabelRaw,
AutofillProfile* profile); AutofillProfile* profile);
...@@ -120,7 +121,7 @@ void AuxiliaryProfilesImpl::GetAddressBookMeCard() { ...@@ -120,7 +121,7 @@ void AuxiliaryProfilesImpl::GetAddressBookMeCard() {
GetAddressBookNames(me, addressLabelRaw, profile.get()); GetAddressBookNames(me, addressLabelRaw, profile.get());
// Fill in address information. // Fill in address information.
GetAddressBookAddresses(address, profile.get()); GetAddressBookAddress(address, profile.get());
// Fill in email information. // Fill in email information.
GetAddressBookEmail(me, addressLabelRaw, profile.get()); GetAddressBookEmail(me, addressLabelRaw, profile.get());
...@@ -156,8 +157,8 @@ void AuxiliaryProfilesImpl::GetAddressBookNames( ...@@ -156,8 +157,8 @@ void AuxiliaryProfilesImpl::GetAddressBookNames(
// second line we join with commas. // second line we join with commas.
// For example: "c/o John Doe\n1122 Other Avenue\nApt #7" translates to // For example: "c/o John Doe\n1122 Other Avenue\nApt #7" translates to
// line 1: "c/o John Doe", line 2: "1122 Other Avenue, Apt #7". // line 1: "c/o John Doe", line 2: "1122 Other Avenue, Apt #7".
void AuxiliaryProfilesImpl::GetAddressBookAddresses(NSDictionary* address, void AuxiliaryProfilesImpl::GetAddressBookAddress(NSDictionary* address,
AutofillProfile* profile) { AutofillProfile* profile) {
if (NSString* addressField = [address objectForKey:kABAddressStreetKey]) { if (NSString* addressField = [address objectForKey:kABAddressStreetKey]) {
// If there are newlines in the address, split into two lines. // If there are newlines in the address, split into two lines.
if ([addressField rangeOfCharacterFromSet: if ([addressField rangeOfCharacterFromSet:
...@@ -193,8 +194,9 @@ void AuxiliaryProfilesImpl::GetAddressBookAddresses(NSDictionary* address, ...@@ -193,8 +194,9 @@ void AuxiliaryProfilesImpl::GetAddressBookAddresses(NSDictionary* address,
profile->SetRawInfo(ADDRESS_HOME_ZIP, base::SysNSStringToUTF16(zip)); profile->SetRawInfo(ADDRESS_HOME_ZIP, base::SysNSStringToUTF16(zip));
if (NSString* country = [address objectForKey:kABAddressCountryKey]) { if (NSString* country = [address objectForKey:kABAddressCountryKey]) {
profile->SetRawInfo(ADDRESS_HOME_COUNTRY, profile->SetInfo(ADDRESS_HOME_COUNTRY,
base::SysNSStringToUTF16(country)); base::SysNSStringToUTF16(country),
AutofillCountry::ApplicationLocale());
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment