summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-09 17:39:44 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-09 17:39:44 +0000
commit6842a3f8c00867e7964f5e66fb50d9a1875f7e55 (patch)
treef3bec4efb8d4a69b0855230956a4554e53323cb2
parent539ad94fbc9ccd48bbc30d53db332eb31623821d (diff)
downloadchromium_src-6842a3f8c00867e7964f5e66fb50d9a1875f7e55.zip
chromium_src-6842a3f8c00867e7964f5e66fb50d9a1875f7e55.tar.gz
chromium_src-6842a3f8c00867e7964f5e66fb50d9a1875f7e55.tar.bz2
AutoFill Mac Address Book "me" card data translation.
Implements Mac Address Book "me" card integration with AutoFill feature. When the kAutoFillAuxiliaryProfilesEnabled preference is enabled, via the AutoFill preferences dialog, the active user's designated "me" card becomes available to AutoFill. That is, forms become aware of any name, address, email, and telephone number information residing in the user's "me" card. Small change to AutoFillDialog.xib to resize the preference check-box label width to accommodate new string. BUG=36496 TEST=PersonalDataManagerTest Review URL: http://codereview.chromium.org/668247 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41041 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd5
-rw-r--r--chrome/app/nibs/AutoFillDialog.xib2
-rw-r--r--chrome/browser/autofill/autofill_manager.cc2
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc46
-rw-r--r--chrome/browser/autofill/personal_data_manager.h24
-rw-r--r--chrome/browser/autofill/personal_data_manager_mac.mm252
-rw-r--r--chrome/browser/autofill/personal_data_manager_unittest.cc7
-rw-r--r--chrome/browser/cocoa/preferences_window_controller.mm3
-rwxr-xr-xchrome/chrome_browser.gypi2
9 files changed, 326 insertions, 17 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index f0aa259..a413ce4 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5162,7 +5162,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
AutoFill Profiles
</message>
<message name="IDS_AUTOFILL_USE_MAC_ADDRESS_BOOK" desc="Checkbox label to enable Address Book on Mac.">
- Use my Address Book card
+ Include addresses from my Address Book card
</message>
<message name="IDS_AUTOFILL_ADDRESSES_GROUP_NAME" desc="The name of the Addresses group of the AutoFill dialog.">
Addresses
@@ -5182,6 +5182,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_AUTOFILL_NEW_ADDRESS" desc="The profile label of a new address.">
New address
</message>
+ <message name="IDS_AUTOFILL_MAC_ADDRESS_LINE_SEPARATOR" desc="The separator character used to join multi-line addresses on the Mac.">
+ , '''
+ </message>
<message name="IDS_AUTOFILL_DIALOG_ADDRESS_SUMMARY_SEPARATOR" desc="The separator character used in the summary of an address.">
, '''
</message>
diff --git a/chrome/app/nibs/AutoFillDialog.xib b/chrome/app/nibs/AutoFillDialog.xib
index 7dc6cc4..ec4d709 100644
--- a/chrome/app/nibs/AutoFillDialog.xib
+++ b/chrome/app/nibs/AutoFillDialog.xib
@@ -122,7 +122,7 @@
<object class="NSButton" id="1017685297">
<reference key="NSNextResponder" ref="872997946"/>
<int key="NSvFlags">268</int>
- <string key="NSFrame">{{22, 329}, {200, 18}}</string>
+ <string key="NSFrame">{{22, 329}, {380, 18}}</string>
<reference key="NSSuperview" ref="872997946"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="116049943">
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index fe1e64c..57b0d77 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -232,7 +232,7 @@ void AutoFillManager::OnPersonalDataLoaded() {
ShowAutoFillDialog(
this,
- personal_data_->profiles(),
+ personal_data_->web_profiles(),
personal_data_->credit_cards(),
tab_contents_->profile()->GetOriginalProfile());
}
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index 1e9ca9a..637933b 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -14,6 +14,8 @@
#include "chrome/browser/autofill/phone_number.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/webdata/web_data_service.h"
+#include "chrome/browser/pref_service.h"
+#include "chrome/common/pref_names.h"
// The minimum number of fields that must contain user data and have known types
// before autofill will attempt to import the data into a profile.
@@ -222,7 +224,7 @@ void PersonalDataManager::SetProfiles(std::vector<AutoFillProfile>* profiles) {
}
// Clear the unique IDs. The set of unique IDs is updated for each profile
- // added to |profiles_| below.
+ // added to |web_profiles_| below.
unique_profile_ids_.clear();
// Update the web database with the existing profiles. We need to handle
@@ -249,10 +251,10 @@ void PersonalDataManager::SetProfiles(std::vector<AutoFillProfile>* profiles) {
}
}
- profiles_.reset();
+ web_profiles_.reset();
for (std::vector<AutoFillProfile>::iterator iter = profiles->begin();
iter != profiles->end(); ++iter) {
- profiles_.push_back(new AutoFillProfile(*iter));
+ web_profiles_.push_back(new AutoFillProfile(*iter));
}
}
@@ -326,8 +328,8 @@ void PersonalDataManager::GetPossibleFieldTypes(const string16& text,
return;
}
- for (ScopedVector<AutoFillProfile>::iterator iter = profiles_.begin();
- iter != profiles_.end(); ++iter) {
+ for (ScopedVector<AutoFillProfile>::iterator iter = web_profiles_.begin();
+ iter != web_profiles_.end(); ++iter) {
const FormGroup* profile = *iter;
if (!profile) {
DLOG(ERROR) << "NULL information in profiles list";
@@ -355,6 +357,29 @@ bool PersonalDataManager::HasPassword() {
return !password_hash_.empty();
}
+const std::vector<AutoFillProfile*>& PersonalDataManager::profiles() {
+ bool auxiliary_profiles_enabled = profile_->GetPrefs()->GetBoolean(
+ prefs::kAutoFillAuxiliaryProfilesEnabled);
+ if (auxiliary_profiles_enabled) {
+ profiles_.clear();
+
+ // Populates |auxiliary_profiles_|.
+ LoadAuxiliaryProfiles();
+
+ profiles_.insert(profiles_.end(),
+ web_profiles_.begin(), web_profiles_.end());
+ profiles_.insert(profiles_.end(),
+ auxiliary_profiles_.begin(), auxiliary_profiles_.end());
+ return profiles_;
+ } else {
+ return web_profiles_.get();
+ }
+}
+
+const std::vector<AutoFillProfile*>& PersonalDataManager::web_profiles() {
+ return web_profiles_.get();
+}
+
PersonalDataManager::PersonalDataManager(Profile* profile)
: profile_(profile),
is_initialized_(false),
@@ -396,6 +421,13 @@ void PersonalDataManager::LoadProfiles() {
pending_profiles_query_ = web_data_service->GetAutoFillProfiles(this);
}
+// Win and Linux implementations do nothing. Mac implementation fills in the
+// contents of |auxiliary_profiles_|.
+#if !defined(OS_MACOSX)
+void PersonalDataManager::LoadAuxiliaryProfiles() {
+}
+#endif
+
void PersonalDataManager::LoadCreditCards() {
WebDataService* web_data_service =
profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
@@ -415,7 +447,7 @@ void PersonalDataManager::ReceiveLoadedProfiles(WebDataService::Handle h,
pending_profiles_query_ = 0;
unique_profile_ids_.clear();
- profiles_.reset();
+ web_profiles_.reset();
const WDResult<std::vector<AutoFillProfile*> >* r =
static_cast<const WDResult<std::vector<AutoFillProfile*> >*>(result);
@@ -424,7 +456,7 @@ void PersonalDataManager::ReceiveLoadedProfiles(WebDataService::Handle h,
for (std::vector<AutoFillProfile*>::iterator iter = profiles.begin();
iter != profiles.end(); ++iter) {
unique_profile_ids_.insert((*iter)->unique_id());
- profiles_.push_back(*iter);
+ web_profiles_.push_back(*iter);
}
}
diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h
index f5e6a977..3384323 100644
--- a/chrome/browser/autofill/personal_data_manager.h
+++ b/chrome/browser/autofill/personal_data_manager.h
@@ -63,8 +63,8 @@ class PersonalDataManager : public WebDataServiceConsumer,
bool ImportFormData(const std::vector<FormStructure*>& form_structures,
AutoFillManager* autofill_manager);
- // Sets |profiles_| to the contents of |profiles| and updates the web database
- // by adding, updating and removing profiles. Sets the unique ID of
+ // Sets |web_profiles_| to the contents of |profiles| and updates the web
+ // database by adding, updating and removing profiles. Sets the unique ID of
// newly-added profiles.
void SetProfiles(std::vector<AutoFillProfile>* profiles);
@@ -86,8 +86,10 @@ class PersonalDataManager : public WebDataServiceConsumer,
// This PersonalDataManager owns these profiles and credit cards. Their
// lifetime is until the web database is updated with new profile and credit
- // card information, respectively.
- const std::vector<AutoFillProfile*>& profiles() { return profiles_.get(); }
+ // card information, respectively. |profiles()| returns both web and
+ // auxiliary profiles. |web_profiles()| returns only web profiles.
+ const std::vector<AutoFillProfile*>& profiles();
+ const std::vector<AutoFillProfile*>& web_profiles();
const std::vector<CreditCard*>& credit_cards() { return credit_cards_.get(); }
private:
@@ -112,6 +114,9 @@ class PersonalDataManager : public WebDataServiceConsumer,
// Loads the saved profiles from the web database.
void LoadProfiles();
+ // Loads the auxiliary profiles. Currently Mac only.
+ void LoadAuxiliaryProfiles();
+
// Loads the saved credit cards from the web database.
void LoadCreditCards();
@@ -146,8 +151,15 @@ class PersonalDataManager : public WebDataServiceConsumer,
// unique credit card ID.
std::set<int> unique_creditcard_ids_;
- // The loaded profiles.
- ScopedVector<AutoFillProfile> profiles_;
+ // The loaded web profiles.
+ ScopedVector<AutoFillProfile> web_profiles_;
+
+ // Auxiliary profiles.
+ ScopedVector<AutoFillProfile> auxiliary_profiles_;
+
+ // Storage for combined web and auxiliary profiles. Contents are weak
+ // references. Lifetime managed by |web_profiles_| and |auxiliary_profiles_|.
+ std::vector<AutoFillProfile*> profiles_;
// The loaded credit cards.
ScopedVector<CreditCard> credit_cards_;
diff --git a/chrome/browser/autofill/personal_data_manager_mac.mm b/chrome/browser/autofill/personal_data_manager_mac.mm
new file mode 100644
index 0000000..8387431
--- /dev/null
+++ b/chrome/browser/autofill/personal_data_manager_mac.mm
@@ -0,0 +1,252 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autofill/personal_data_manager.h"
+
+#import <AddressBook/AddressBook.h>
+
+#include "app/l10n_util_mac.h"
+#include "base/scoped_ptr.h"
+#include "base/scoped_vector.h"
+#include "base/sys_string_conversions.h"
+#include "chrome/browser/autofill/autofill_profile.h"
+#include "chrome/browser/autofill/phone_number.h"
+#include "grit/generated_resources.h"
+
+namespace {
+
+// This implementation makes use of the Address Book API. Profiles are
+// generated that correspond to addresses in the "me" card that reside in the
+// user's Address Book. The caller passes a vector of profiles into the
+// the constructer and then initiate the fetch from the Mac Address Book "me"
+// card using the main |GetAddressBookMeCard()| method. This clears any
+// existing addresses and populates new addresses derived from the data found
+// in the "me" card.
+class AuxiliaryProfilesImpl {
+ public:
+ // Constructor takes a reference to the |profiles| that will be filled in
+ // by the subsequent call to |GetAddressBookMeCard()|. |profiles| may not
+ // be NULL.
+ explicit AuxiliaryProfilesImpl(ScopedVector<AutoFillProfile>* profiles)
+ : profiles_(*profiles) {
+ }
+ virtual ~AuxiliaryProfilesImpl() {}
+
+ // Import the "me" card from the Mac Address Book and fill in |profiles_|.
+ void GetAddressBookMeCard();
+
+ private:
+ void GetAddressBookNames(ABPerson* me,
+ NSString* addressLabelRaw,
+ AutoFillProfile* profile);
+ void GetAddressBookAddresses(NSDictionary* address, AutoFillProfile* profile);
+ void GetAddressBookEmail(ABPerson* me,
+ NSString* addressLabelRaw,
+ AutoFillProfile* profile);
+ void GetAddressBookPhoneNumbers(ABPerson* me,
+ NSString* addressLabelRaw,
+ AutoFillProfile* profile);
+
+ private:
+ // A reference to the profiles this class populates.
+ ScopedVector<AutoFillProfile>& profiles_;
+
+ DISALLOW_COPY_AND_ASSIGN(AuxiliaryProfilesImpl);
+};
+
+// This method uses the |ABAddressBook| system service to fetch the "me" card
+// from the active user's address book. It looks for the user address
+// information and translates it to the internal list of |AutoFillProfile| data
+// structures.
+void AuxiliaryProfilesImpl::GetAddressBookMeCard() {
+ profiles_.reset();
+
+ ABAddressBook* addressBook = [ABAddressBook sharedAddressBook];
+ ABPerson* me = [addressBook me];
+ if (me) {
+ ABMultiValue* addresses = [me valueForProperty:kABAddressProperty];
+ for (NSUInteger i = 0, count = [addresses count]; i < count; i++) {
+ NSDictionary* address = [addresses valueAtIndex:i];
+ NSString* addressLabelRaw = [addresses labelAtIndex:i];
+ NSString* addressLabel = ABLocalizedPropertyOrLabel(addressLabelRaw);
+
+ // Create a new profile where the label is set to the localized label
+ // from the "me" address.
+ scoped_ptr<AutoFillProfile> profile(
+ new AutoFillProfile(base::SysNSStringToUTF16(addressLabel), 0));
+
+ // Fill in name and company information.
+ GetAddressBookNames(me, addressLabelRaw, profile.get());
+
+ // Fill in address information.
+ GetAddressBookAddresses(address, profile.get());
+
+ // Fill in email information.
+ GetAddressBookEmail(me, addressLabelRaw, profile.get());
+
+ // Fill in phone and fax number information.
+ GetAddressBookPhoneNumbers(me, addressLabelRaw, profile.get());
+
+ profiles_.push_back(profile.release());
+ }
+ }
+}
+
+// Name and company information is stored once in the Address Book against
+// multiple addresses. We replicate that information for each profile.
+// We only propagate the company name to work profiles.
+void AuxiliaryProfilesImpl::GetAddressBookNames(
+ ABPerson* me,
+ NSString* addressLabelRaw,
+ AutoFillProfile* profile) {
+ NSString* firstName = [me valueForProperty:kABFirstNameProperty];
+ NSString* middleName = [me valueForProperty:kABMiddleNameProperty];
+ NSString* lastName = [me valueForProperty:kABLastNameProperty];
+ NSString* companyName = [me valueForProperty:kABOrganizationProperty];
+
+ profile->SetInfo(AutoFillType(NAME_FIRST),
+ base::SysNSStringToUTF16(firstName));
+ profile->SetInfo(AutoFillType(NAME_MIDDLE),
+ base::SysNSStringToUTF16(middleName));
+ profile->SetInfo(AutoFillType(NAME_LAST),
+ base::SysNSStringToUTF16(lastName));
+ if ([addressLabelRaw isEqualToString:kABAddressWorkLabel]) {
+ profile->SetInfo(AutoFillType(COMPANY_NAME),
+ base::SysNSStringToUTF16(companyName));
+ }
+}
+
+// Addresss information from the Address Book may span multiple lines.
+// If it does then we represent the address with two lines in the profile. The
+// second line we join with commas.
+// 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".
+void AuxiliaryProfilesImpl::GetAddressBookAddresses(
+ NSDictionary* address,
+ AutoFillProfile* profile) {
+ NSString* addressField;
+ addressField = [address objectForKey:kABAddressStreetKey];
+
+ // If there are newlines in the address, split into two lines.
+ if ([addressField rangeOfCharacterFromSet:
+ [NSCharacterSet newlineCharacterSet]].location != NSNotFound) {
+ NSArray *chunks = [addressField componentsSeparatedByCharactersInSet:
+ [NSCharacterSet newlineCharacterSet]];
+ DCHECK([chunks count] > 1);
+
+ NSString* separator = l10n_util::GetNSString(
+ IDS_AUTOFILL_MAC_ADDRESS_LINE_SEPARATOR);
+
+ NSString* addressField1 = [chunks objectAtIndex:0];
+ NSString* addressField2 =
+ [[chunks subarrayWithRange:NSMakeRange(1, [chunks count] - 1)]
+ componentsJoinedByString:separator];
+ profile->SetInfo(AutoFillType(ADDRESS_HOME_LINE1),
+ base::SysNSStringToUTF16(addressField1));
+ profile->SetInfo(AutoFillType(ADDRESS_HOME_LINE2),
+ base::SysNSStringToUTF16(addressField2));
+ } else {
+ profile->SetInfo(AutoFillType(ADDRESS_HOME_LINE1),
+ base::SysNSStringToUTF16(addressField));
+ }
+
+ addressField = [address objectForKey:kABAddressCityKey];
+ profile->SetInfo(AutoFillType(ADDRESS_HOME_CITY),
+ base::SysNSStringToUTF16(addressField));
+ addressField = [address objectForKey:kABAddressStateKey];
+ profile->SetInfo(AutoFillType(ADDRESS_HOME_STATE),
+ base::SysNSStringToUTF16(addressField));
+ addressField = [address objectForKey:kABAddressZIPKey];
+ profile->SetInfo(AutoFillType(ADDRESS_HOME_ZIP),
+ base::SysNSStringToUTF16(addressField));
+ addressField = [address objectForKey:kABAddressCountryKey];
+ profile->SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY),
+ base::SysNSStringToUTF16(addressField));
+}
+
+// Fills in email address matching current address label. Note that there may
+// be multiple matching email addresses for a given label. We take the
+// first we find (topmost) as preferred.
+void AuxiliaryProfilesImpl::GetAddressBookEmail(
+ ABPerson* me,
+ NSString* addressLabelRaw,
+ AutoFillProfile* profile) {
+ ABMultiValue* emailAddresses = [me valueForProperty:kABEmailProperty];
+ NSString* emailAddress = nil;
+ for (NSUInteger j = 0, emailCount = [emailAddresses count];
+ j < emailCount; j++) {
+ NSString* emailAddressLabelRaw = [emailAddresses labelAtIndex:j];
+ if ([emailAddressLabelRaw isEqualToString:addressLabelRaw]) {
+ emailAddress = [emailAddresses valueAtIndex:j];
+ break;
+ }
+ }
+ profile->SetInfo(AutoFillType(EMAIL_ADDRESS),
+ base::SysNSStringToUTF16(emailAddress));
+}
+
+// Fills in telephone numbers. Each of these are special cases.
+// We match four cases: home/tel, home/fax, work/tel, work/fax.
+// Note, we traverse in reverse order so that top values in address book
+// take priority.
+void AuxiliaryProfilesImpl::GetAddressBookPhoneNumbers(
+ ABPerson* me,
+ NSString* addressLabelRaw,
+ AutoFillProfile* profile) {
+ string16 number;
+ string16 city_code;
+ string16 country_code;
+
+ ABMultiValue* phoneNumbers = [me valueForProperty:kABPhoneProperty];
+ for (NSUInteger k = 0, phoneCount = [phoneNumbers count];
+ k < phoneCount; k++) {
+ NSUInteger reverseK = phoneCount - k - 1;
+ NSString* phoneLabelRaw = [phoneNumbers labelAtIndex:reverseK];
+ if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] &&
+ [phoneLabelRaw isEqualToString:kABPhoneHomeLabel]) {
+ string16 homePhone = base::SysNSStringToUTF16(
+ [phoneNumbers valueAtIndex:reverseK]);
+ PhoneNumber::ParsePhoneNumber(
+ homePhone, &number, &city_code, &country_code);
+ profile->SetInfo(AutoFillType(PHONE_HOME_NUMBER), number);
+ profile->SetInfo(AutoFillType(PHONE_HOME_CITY_CODE), city_code);
+ profile->SetInfo(AutoFillType(PHONE_HOME_COUNTRY_CODE), country_code);
+ } else if ([addressLabelRaw isEqualToString:kABAddressHomeLabel] &&
+ [phoneLabelRaw isEqualToString:kABPhoneHomeFAXLabel]) {
+ string16 homeFax = base::SysNSStringToUTF16(
+ [phoneNumbers valueAtIndex:reverseK]);
+ PhoneNumber::ParsePhoneNumber(homeFax,
+ &number, &city_code, &country_code);
+ profile->SetInfo(AutoFillType(PHONE_FAX_NUMBER), number);
+ profile->SetInfo(AutoFillType(PHONE_FAX_CITY_CODE), city_code);
+ profile->SetInfo(AutoFillType(PHONE_FAX_COUNTRY_CODE), country_code);
+ } else if ([addressLabelRaw isEqualToString:kABAddressWorkLabel] &&
+ [phoneLabelRaw isEqualToString:kABPhoneWorkLabel]) {
+ string16 workPhone = base::SysNSStringToUTF16(
+ [phoneNumbers valueAtIndex:reverseK]);
+ PhoneNumber::ParsePhoneNumber(workPhone,
+ &number, &city_code, &country_code);
+ profile->SetInfo(AutoFillType(PHONE_HOME_NUMBER), number);
+ profile->SetInfo(AutoFillType(PHONE_HOME_CITY_CODE), city_code);
+ profile->SetInfo(AutoFillType(PHONE_HOME_COUNTRY_CODE), country_code);
+ } else if ([addressLabelRaw isEqualToString:kABAddressWorkLabel] &&
+ [phoneLabelRaw isEqualToString:kABPhoneWorkFAXLabel]) {
+ string16 workFax = base::SysNSStringToUTF16(
+ [phoneNumbers valueAtIndex:reverseK]);
+ PhoneNumber::ParsePhoneNumber(workFax,
+ &number, &city_code, &country_code);
+ profile->SetInfo(AutoFillType(PHONE_FAX_NUMBER), number);
+ profile->SetInfo(AutoFillType(PHONE_FAX_CITY_CODE), city_code);
+ profile->SetInfo(AutoFillType(PHONE_FAX_COUNTRY_CODE), country_code);
+ }
+ }
+}
+
+} // namespace
+
+// Populate |auxiliary_profiles_| with the Address Book data.
+void PersonalDataManager::LoadAuxiliaryProfiles() {
+ AuxiliaryProfilesImpl impl(&auxiliary_profiles_);
+ impl.GetAddressBookMeCard();
+}
diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc
index 11940ef..986f11f 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -9,11 +9,13 @@
#include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/pref_service.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_observer_mock.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/testing_profile.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -59,6 +61,11 @@ class PersonalDataManagerTest : public testing::Test {
void ResetPersonalDataManager() {
personal_data_.reset(new PersonalDataManager(profile_.get()));
personal_data_->SetObserver(&personal_data_observer_);
+
+ // Disable auxiliary profiles for unit testing. These reach out to system
+ // services on the Mac.
+ profile_->GetPrefs()->SetBoolean(
+ prefs::kAutoFillAuxiliaryProfilesEnabled, false);
}
MessageLoopForUI message_loop_;
diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm
index 5cce358..345d7dd 100644
--- a/chrome/browser/cocoa/preferences_window_controller.mm
+++ b/chrome/browser/cocoa/preferences_window_controller.mm
@@ -494,7 +494,8 @@ void PersonalDataManagerObserver::ShowAutoFillDialog(
if (!personal_data_manager)
return;
- std::vector<AutoFillProfile*> profiles = personal_data_manager->profiles();
+ std::vector<AutoFillProfile*> profiles =
+ personal_data_manager->web_profiles();
AutoFillProfile autofill_profile(ASCIIToUTF16(""), 0);
if (profiles.size() == 0) {
string16 new_profile_name =
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index dceec65..8b4231a 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -149,6 +149,7 @@
'browser/autofill/name_field.h',
'browser/autofill/personal_data_manager.cc',
'browser/autofill/personal_data_manager.h',
+ 'browser/autofill/personal_data_manager_mac.mm',
'browser/autofill/phone_field.cc',
'browser/autofill/phone_field.h',
'browser/autofill/phone_number.cc',
@@ -2426,6 +2427,7 @@
],
'link_settings': {
'libraries': [
+ '$(SDKROOT)/System/Library/Frameworks/AddressBook.framework',
'$(SDKROOT)/System/Library/Frameworks/SecurityInterface.framework',
'$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
'$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',