From 0b2f513b8e24956466fcb04fad1d912ff8cfe65b Mon Sep 17 00:00:00 2001
From: "jam@chromium.org"
 <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Fri, 5 Apr 2013 20:13:23 +0000
Subject: Remove application locale cache in autofill code
 (AutofillCountry::ApplicationLOcale).

This is in preparation for removing content::GetContentClient calls outside of content.

BUG=227047
Review URL: https://codereview.chromium.org/13488009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192622 0039d316-1c4b-4281-b951-d872f2087c98
---
 .../autofill/browser/autocheckout_manager.cc       | 11 ++-
 .../autocomplete_history_manager_unittest.cc       |  2 +-
 components/autofill/browser/autofill_country.cc    | 31 --------
 components/autofill/browser/autofill_country.h     |  6 --
 .../browser/autofill_ie_toolbar_import_win.cc      | 23 +++---
 .../autofill_ie_toolbar_import_win_unittest.cc     |  7 +-
 components/autofill/browser/autofill_manager.cc    | 17 +++--
 components/autofill/browser/autofill_manager.h     | 10 ++-
 .../autofill/browser/autofill_manager_unittest.cc  |  2 +-
 .../autofill/browser/autofill_merge_unittest.cc    |  5 +-
 .../autofill/browser/autofill_metrics_unittest.cc  |  4 +-
 components/autofill/browser/autofill_profile.cc    | 56 ++++++++------
 components/autofill/browser/autofill_profile.h     | 14 +++-
 .../autofill/browser/autofill_profile_unittest.cc  | 20 ++---
 components/autofill/browser/credit_card.cc         | 10 +--
 components/autofill/browser/credit_card.h          |  3 +-
 .../autofill/browser/credit_card_unittest.cc       | 18 ++---
 components/autofill/browser/form_group.cc          | 10 ++-
 components/autofill/browser/form_group.h           |  5 +-
 .../autofill/browser/personal_data_manager.cc      | 85 +++++++++++-----------
 .../autofill/browser/personal_data_manager.h       |  9 ++-
 .../autofill/browser/personal_data_manager_mac.mm  | 18 +++--
 .../browser/personal_data_manager_unittest.cc      |  2 +-
 components/autofill/browser/phone_number_i18n.cc   | 28 ++++---
 components/autofill/browser/phone_number_i18n.h    |  6 +-
 .../autofill/browser/phone_number_i18n_unittest.cc | 30 +++++---
 .../autofill/browser/wallet/wallet_address.cc      |  6 +-
 .../autofill/browser/wallet/wallet_address.h       |  3 +-
 components/autofill/browser/wallet/wallet_items.cc |  6 +-
 components/autofill/browser/wallet/wallet_items.h  |  3 +-
 components/webdata/autofill/autofill_table.cc      |  8 +-
 components/webdata/autofill/autofill_table.h       |  2 +-
 .../webdata/autofill/autofill_table_unittest.cc    |  2 +-
 .../webdata/autofill/web_data_service_unittest.cc  |  2 +-
 .../autofill/web_database_migration_unittest.cc    |  2 +-
 35 files changed, 253 insertions(+), 213 deletions(-)

(limited to 'components')

diff --git a/components/autofill/browser/autocheckout_manager.cc b/components/autofill/browser/autocheckout_manager.cc
index 46fcb95..a66f9d1 100644
--- a/components/autofill/browser/autocheckout_manager.cc
+++ b/components/autofill/browser/autocheckout_manager.cc
@@ -354,10 +354,13 @@ void AutocheckoutManager::SetValue(const AutofillField& field,
 
   // TODO(ramankk): Handle variants in a better fashion, need to distinguish
   // between shipping and billing address.
-  if (AutofillType(type).group() == AutofillType::CREDIT_CARD)
-    credit_card_->FillFormField(field, 0, field_to_fill);
-  else
-    profile_->FillFormField(field, 0, field_to_fill);
+  if (AutofillType(type).group() == AutofillType::CREDIT_CARD) {
+    credit_card_->FillFormField(
+        field, 0, autofill_manager_->app_locale(), field_to_fill);
+  } else {
+    profile_->FillFormField(
+        field, 0, autofill_manager_->app_locale(), field_to_fill);
+  }
 }
 
 void AutocheckoutManager::SendAutocheckoutStatus(AutocheckoutStatus status) {
diff --git a/components/autofill/browser/autocomplete_history_manager_unittest.cc b/components/autofill/browser/autocomplete_history_manager_unittest.cc
index fcee54d..3b4bc38 100644
--- a/components/autofill/browser/autocomplete_history_manager_unittest.cc
+++ b/components/autofill/browser/autocomplete_history_manager_unittest.cc
@@ -250,7 +250,7 @@ TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) {
       web_contents());
 
   AutofillManager::CreateForWebContentsAndDelegate(
-      web_contents(), &manager_delegate);
+      web_contents(), &manager_delegate, "en-US");
 
   MockAutofillExternalDelegate external_delegate(web_contents());
   autocomplete_history_manager.SetExternalDelegate(&external_delegate);
diff --git a/components/autofill/browser/autofill_country.cc b/components/autofill/browser/autofill_country.cc
index f38ba09..9018d6a 100644
--- a/components/autofill/browser/autofill_country.cc
+++ b/components/autofill/browser/autofill_country.cc
@@ -16,8 +16,6 @@
 #include "base/string_util.h"
 #include "base/threading/thread_checker.h"
 #include "base/utf_string_conversions.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/content_browser_client.h"
 #include "grit/generated_resources.h"
 #include "third_party/icu/public/common/unicode/locid.h"
 #include "third_party/icu/public/common/unicode/uloc.h"
@@ -28,8 +26,6 @@
 #include "third_party/icu/public/i18n/unicode/ucol.h"
 #include "ui/base/l10n/l10n_util.h"
 
-using content::BrowserThread;
-
 namespace {
 
 // The maximum capacity needed to store a locale up to the country code.
@@ -845,9 +841,6 @@ class CountryNames {
  public:
   static CountryNames* GetInstance();
 
-  // Returns the application locale.
-  const std::string ApplicationLocale();
-
   // Returns the country code corresponding to |country|, which should be a
   // country code or country name localized to |locale|.
   const std::string GetCountryCode(const string16& country,
@@ -899,9 +892,6 @@ class CountryNames {
   // Verifies thread-safety of accesses to the application locale.
   base::ThreadChecker thread_checker_;
 
-  // Caches the application locale, for thread-safe access.
-  std::string application_locale_;
-
   DISALLOW_COPY_AND_ASSIGN(CountryNames);
 };
 
@@ -910,22 +900,6 @@ CountryNames* CountryNames::GetInstance() {
   return Singleton<CountryNames>::get();
 }
 
-const std::string CountryNames::ApplicationLocale() {
-  if (application_locale_.empty()) {
-    // In production code, this class is always constructed on the UI thread, so
-    // the two conditions in the below DCHECK are identical.  In test code,
-    // sometimes there is a UI thread, and sometimes there is just the unnamed
-    // main thread.  Since this class is a singleton, it needs to support both
-    // cases.  Hence, the somewhat strange looking DCHECK below.
-    DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
-           thread_checker_.CalledOnValidThread());
-    application_locale_ =
-        content::GetContentClient()->browser()->GetApplicationLocale();
-  }
-
-  return application_locale_;
-}
-
 CountryNames::CountryNames() {
   // Add 2- and 3-letter ISO country codes.
   for (CountryDataMap::Iterator it = CountryDataMap::Begin();
@@ -1126,11 +1100,6 @@ const std::string AutofillCountry::GetCountryCode(const string16& country,
   return CountryNames::GetInstance()->GetCountryCode(country, locale);
 }
 
-// static
-const std::string AutofillCountry::ApplicationLocale() {
-  return CountryNames::GetInstance()->ApplicationLocale();
-}
-
 AutofillCountry::AutofillCountry(const std::string& country_code,
                                  const string16& name,
                                  const string16& postal_code_label,
diff --git a/components/autofill/browser/autofill_country.h b/components/autofill/browser/autofill_country.h
index 72f0a8c..4c5ed38 100644
--- a/components/autofill/browser/autofill_country.h
+++ b/components/autofill/browser/autofill_country.h
@@ -59,12 +59,6 @@ class AutofillCountry {
   static const std::string GetCountryCode(const string16& country,
                                           const std::string& locale);
 
-  // Returns the application locale.
-  // The first time this is called, it should be called from the UI thread.
-  // Once [ http://crbug.com/100845 ] is fixed, this method should *only* be
-  // called from the UI thread.
-  static const std::string ApplicationLocale();
-
   const std::string country_code() const { return country_code_; }
   const string16 name() const { return name_; }
   const string16 postal_code_label() const { return postal_code_label_; }
diff --git a/components/autofill/browser/autofill_ie_toolbar_import_win.cc b/components/autofill/browser/autofill_ie_toolbar_import_win.cc
index 29ba67b..6a30103 100644
--- a/components/autofill/browser/autofill_ie_toolbar_import_win.cc
+++ b/components/autofill/browser/autofill_ie_toolbar_import_win.cc
@@ -30,7 +30,8 @@ using base::win::RegKey;
 
 // Forward declaration. This function is not in unnamed namespace as it
 // is referenced in the unittest.
-bool ImportCurrentUserProfiles(std::vector<AutofillProfile>* profiles,
+bool ImportCurrentUserProfiles(const std::string& app_locale,
+                               std::vector<AutofillProfile>* profiles,
                                std::vector<CreditCard>* credit_cards);
 namespace {
 
@@ -130,6 +131,7 @@ typedef std::map<std::wstring, AutofillFieldType> RegToFieldMap;
 // Returns true if any fields were set, false otherwise.
 bool ImportSingleFormGroup(const RegKey& key,
                            const RegToFieldMap& reg_to_field,
+                           const std::string& app_locale,
                            FormGroup* form_group,
                            PhoneNumber::PhoneCombineHelper* phone) {
   if (!key.Valid())
@@ -137,7 +139,6 @@ bool ImportSingleFormGroup(const RegKey& key,
 
   bool has_non_empty_fields = false;
 
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
   for (uint32 i = 0; i < key.GetValueCount(); ++i) {
     std::wstring value_name;
     if (key.GetValueNameAt(i, &value_name) != ERROR_SUCCESS)
@@ -167,16 +168,16 @@ bool ImportSingleFormGroup(const RegKey& key,
 // Imports address data from the given registry |key| into the given |profile|,
 // with the help of |reg_to_field|.  Returns true if any fields were set, false
 // otherwise.
-bool ImportSingleProfile(const RegKey& key,
+bool ImportSingleProfile(const std::string& app_locale,
+                         const RegKey& key,
                          const RegToFieldMap& reg_to_field,
                          AutofillProfile* profile) {
   PhoneNumber::PhoneCombineHelper phone;
   bool has_non_empty_fields =
-      ImportSingleFormGroup(key, reg_to_field, profile, &phone);
+      ImportSingleFormGroup(key, reg_to_field, app_locale, profile, &phone);
 
   // Now re-construct the phones if needed.
   string16 constructed_number;
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
   if (phone.ParseNumber(*profile, app_locale, &constructed_number)) {
     has_non_empty_fields = true;
     profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number);
@@ -195,7 +196,9 @@ class AutofillImporter : public PersonalDataManagerObserver {
   }
 
   bool ImportProfiles() {
-    if (!ImportCurrentUserProfiles(&profiles_, &credit_cards_)) {
+    if (!ImportCurrentUserProfiles(personal_data_manager_->app_locale(),
+                                   &profiles_,
+                                   &credit_cards_)) {
       delete this;
       return false;
     }
@@ -232,7 +235,8 @@ class AutofillImporter : public PersonalDataManagerObserver {
 // Imports Autofill profiles and credit cards from IE Toolbar if present and not
 // password protected. Returns true if data is successfully retrieved. False if
 // there is no data, data is password protected or error occurred.
-bool ImportCurrentUserProfiles(std::vector<AutofillProfile>* profiles,
+bool ImportCurrentUserProfiles(const std::string& app_locale,
+                               std::vector<AutofillProfile>* profiles,
                                std::vector<CreditCard>* credit_cards) {
   DCHECK(profiles);
   DCHECK(credit_cards);
@@ -252,7 +256,7 @@ bool ImportCurrentUserProfiles(std::vector<AutofillProfile>* profiles,
     key_name.append(iterator_profiles.Name());
     RegKey key(HKEY_CURRENT_USER, key_name.c_str(), KEY_READ);
     AutofillProfile profile;
-    if (ImportSingleProfile(key, reg_to_field, &profile)) {
+    if (ImportSingleProfile(app_locale, key, reg_to_field, &profile)) {
       // Combine phones into whole phone #.
       profiles->push_back(profile);
     }
@@ -275,7 +279,8 @@ bool ImportCurrentUserProfiles(std::vector<AutofillProfile>* profiles,
       key_name.append(iterator_cc.Name());
       RegKey key(HKEY_CURRENT_USER, key_name.c_str(), KEY_READ);
       CreditCard credit_card;
-      if (ImportSingleFormGroup(key, reg_to_field, &credit_card, NULL)) {
+      if (ImportSingleFormGroup(
+              key, reg_to_field, app_locale, &credit_card, NULL)) {
         string16 cc_number = credit_card.GetRawInfo(CREDIT_CARD_NUMBER);
         if (!cc_number.empty())
           credit_cards->push_back(credit_card);
diff --git a/components/autofill/browser/autofill_ie_toolbar_import_win_unittest.cc b/components/autofill/browser/autofill_ie_toolbar_import_win_unittest.cc
index b81a833..be6aeb8 100644
--- a/components/autofill/browser/autofill_ie_toolbar_import_win_unittest.cc
+++ b/components/autofill/browser/autofill_ie_toolbar_import_win_unittest.cc
@@ -16,7 +16,8 @@
 using base::win::RegKey;
 
 // Defined in autofill_ie_toolbar_import_win.cc. Not exposed in the header file.
-bool ImportCurrentUserProfiles(std::vector<AutofillProfile>* profiles,
+bool ImportCurrentUserProfiles(const std::string& app_locale,
+                               std::vector<AutofillProfile>* profiles,
                                std::vector<CreditCard>* credit_cards);
 
 namespace {
@@ -157,7 +158,7 @@ TEST_F(AutofillIeToolbarImportTest, TestAutofillImport) {
 
   std::vector<AutofillProfile> profiles;
   std::vector<CreditCard> credit_cards;
-  EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards));
+  EXPECT_TRUE(ImportCurrentUserProfiles("en-US", &profiles, &credit_cards));
   ASSERT_EQ(2U, profiles.size());
   // The profiles are read in reverse order.
   EXPECT_EQ(profile1[0].value, profiles[1].GetRawInfo(NAME_FIRST));
@@ -195,7 +196,7 @@ TEST_F(AutofillIeToolbarImportTest, TestAutofillImport) {
 
   profiles.clear();
   credit_cards.clear();
-  EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards));
+  EXPECT_TRUE(ImportCurrentUserProfiles("en-US", &profiles, &credit_cards));
   // Profiles are not protected.
   EXPECT_EQ(2U, profiles.size());
   // Credit cards are.
diff --git a/components/autofill/browser/autofill_manager.cc b/components/autofill/browser/autofill_manager.cc
index 3db909b..c9acb0d 100644
--- a/components/autofill/browser/autofill_manager.cc
+++ b/components/autofill/browser/autofill_manager.cc
@@ -23,7 +23,6 @@
 #include "components/autofill/browser/autocheckout/whitelist_manager.h"
 #include "components/autofill/browser/autocheckout_manager.h"
 #include "components/autofill/browser/autocomplete_history_manager.h"
-#include "components/autofill/browser/autofill_country.h"
 #include "components/autofill/browser/autofill_external_delegate.h"
 #include "components/autofill/browser/autofill_field.h"
 #include "components/autofill/browser/autofill_manager_delegate.h"
@@ -172,12 +171,13 @@ void DeterminePossibleFieldTypesForUpload(
 // static
 void AutofillManager::CreateForWebContentsAndDelegate(
     content::WebContents* contents,
-    autofill::AutofillManagerDelegate* delegate) {
+    autofill::AutofillManagerDelegate* delegate,
+    const std::string& app_locale) {
   if (FromWebContents(contents))
     return;
 
   contents->SetUserData(kAutofillManagerWebContentsUserDataKey,
-                        new AutofillManager(contents, delegate));
+                        new AutofillManager(contents, delegate, app_locale));
 
   // Trigger the lazy creation of AutocheckoutWhitelistManagerService, and
   // schedule a fetch of the Autocheckout whitelist file if it's not already
@@ -194,9 +194,11 @@ AutofillManager* AutofillManager::FromWebContents(
 }
 
 AutofillManager::AutofillManager(content::WebContents* web_contents,
-                                 autofill::AutofillManagerDelegate* delegate)
+                                 autofill::AutofillManagerDelegate* delegate,
+                                 const std::string& app_locale)
     : content::WebContentsObserver(web_contents),
       manager_delegate_(delegate),
+      app_locale_(app_locale),
       personal_data_(delegate->GetPersonalDataManager()),
       download_manager_(web_contents->GetBrowserContext(), this),
       disable_download_manager_requests_(false),
@@ -433,7 +435,7 @@ bool AutofillManager::OnFormSubmitted(const FormData& form,
         base::Bind(&DeterminePossibleFieldTypesForUpload,
                    copied_profiles,
                    copied_credit_cards,
-                   AutofillCountry::ApplicationLocale(),
+                   app_locale_,
                    raw_submitted_form),
         base::Bind(&AutofillManager::UploadFormDataAsyncCallback,
                    weak_ptr_factory_.GetWeakPtr(),
@@ -629,7 +631,8 @@ void AutofillManager::OnFillAutofillFormData(int query_id,
     for (std::vector<FormFieldData>::iterator iter = result.fields.begin();
          iter != result.fields.end(); ++iter) {
       if ((*iter) == field) {
-        form_group->FillFormField(*autofill_field, variant, &(*iter));
+        form_group->FillFormField(
+            *autofill_field, variant, app_locale_, &(*iter));
         // Mark the cached field as autofilled, so that we can detect when a
         // user edits an autofilled field (for metrics).
         autofill_field->is_autofilled = true;
@@ -668,6 +671,7 @@ void AutofillManager::OnFillAutofillFormData(int query_id,
       }
       form_group->FillFormField(*cached_field,
                                 use_variant,
+                                app_locale_,
                                 &result.fields[i]);
       // Mark the cached field as autofilled, so that we can detect when a user
       // edits an autofilled field (for metrics).
@@ -1006,6 +1010,7 @@ AutofillManager::AutofillManager(content::WebContents* web_contents,
                                  PersonalDataManager* personal_data)
     : content::WebContentsObserver(web_contents),
       manager_delegate_(delegate),
+      app_locale_("en-US"),
       personal_data_(personal_data),
       download_manager_(web_contents->GetBrowserContext(), this),
       disable_download_manager_requests_(true),
diff --git a/components/autofill/browser/autofill_manager.h b/components/autofill/browser/autofill_manager.h
index fae3984..a7cc564 100644
--- a/components/autofill/browser/autofill_manager.h
+++ b/components/autofill/browser/autofill_manager.h
@@ -79,7 +79,8 @@ class AutofillManager : public content::WebContentsObserver,
  public:
   static void CreateForWebContentsAndDelegate(
       content::WebContents* contents,
-      autofill::AutofillManagerDelegate* delegate);
+      autofill::AutofillManagerDelegate* delegate,
+      const std::string& app_locale);
   static AutofillManager* FromWebContents(content::WebContents* contents);
 
   // Registers our Enable/Disable Autofill pref.
@@ -132,13 +133,16 @@ class AutofillManager : public content::WebContentsObserver,
     return manager_delegate_;
   }
 
+  const std::string& app_locale() const { return app_locale_; }
+
   // Only for testing.
   void SetTestDelegate(autofill::AutofillManagerTestDelegate* delegate);
 
  protected:
   // Only test code should subclass AutofillManager.
   AutofillManager(content::WebContents* web_contents,
-                  autofill::AutofillManagerDelegate* delegate);
+                  autofill::AutofillManagerDelegate* delegate,
+                  const std::string& app_locale);
   virtual ~AutofillManager();
 
   // Test code should prefer to use this constructor.
@@ -358,6 +362,8 @@ class AutofillManager : public content::WebContentsObserver,
 
   autofill::AutofillManagerDelegate* const manager_delegate_;
 
+  std::string app_locale_;
+
   // The personal data manager, used to save and load personal data to/from the
   // web database.  This is overridden by the AutofillManagerTest.
   // Weak reference.
diff --git a/components/autofill/browser/autofill_manager_unittest.cc b/components/autofill/browser/autofill_manager_unittest.cc
index e88906b..475465d 100644
--- a/components/autofill/browser/autofill_manager_unittest.cc
+++ b/components/autofill/browser/autofill_manager_unittest.cc
@@ -71,7 +71,7 @@ typedef Tuple5<int,
 
 class TestPersonalDataManager : public PersonalDataManager {
  public:
-  TestPersonalDataManager() {
+  TestPersonalDataManager() : PersonalDataManager("en-US") {
     CreateTestAutofillProfiles(&web_profiles_);
     CreateTestCreditCards(&credit_cards_);
   }
diff --git a/components/autofill/browser/autofill_merge_unittest.cc b/components/autofill/browser/autofill_merge_unittest.cc
index dad4fdb..5a85b5e 100644
--- a/components/autofill/browser/autofill_merge_unittest.cc
+++ b/components/autofill/browser/autofill_merge_unittest.cc
@@ -82,7 +82,8 @@ class PersonalDataManagerMock : public PersonalDataManager {
   DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerMock);
 };
 
-PersonalDataManagerMock::PersonalDataManagerMock() : PersonalDataManager() {
+PersonalDataManagerMock::PersonalDataManagerMock()
+    : PersonalDataManager("en-US") {
 }
 
 PersonalDataManagerMock::~PersonalDataManagerMock() {
@@ -95,7 +96,7 @@ void PersonalDataManagerMock::Reset() {
 void PersonalDataManagerMock::SaveImportedProfile(
     const AutofillProfile& profile) {
   std::vector<AutofillProfile> profiles;
-  if (!MergeProfile(profile, profiles_.get(), &profiles))
+  if (!MergeProfile(profile, profiles_.get(), "en-US", &profiles))
     profiles_.push_back(new AutofillProfile(profile));
 }
 
diff --git a/components/autofill/browser/autofill_metrics_unittest.cc b/components/autofill/browser/autofill_metrics_unittest.cc
index 60cc4a3..ab9d803 100644
--- a/components/autofill/browser/autofill_metrics_unittest.cc
+++ b/components/autofill/browser/autofill_metrics_unittest.cc
@@ -82,7 +82,9 @@ class MockAutofillMetrics : public AutofillMetrics {
 
 class TestPersonalDataManager : public PersonalDataManager {
  public:
-  TestPersonalDataManager() : autofill_enabled_(true) {
+  TestPersonalDataManager()
+      : PersonalDataManager("en-US"),
+        autofill_enabled_(true) {
     set_metric_logger(new testing::NiceMock<MockAutofillMetrics>());
     CreateTestAutofillProfiles(&web_profiles_);
   }
diff --git a/components/autofill/browser/autofill_profile.cc b/components/autofill/browser/autofill_profile.cc
index b1a0da0..6cbd32d 100644
--- a/components/autofill/browser/autofill_profile.cc
+++ b/components/autofill/browser/autofill_profile.cc
@@ -186,22 +186,28 @@ void CollapseCompoundFieldTypes(FieldTypeSet* type_set) {
 
 class FindByPhone {
  public:
-  FindByPhone(const string16& phone, const std::string& country_code)
+  FindByPhone(const string16& phone,
+              const std::string& country_code,
+              const std::string& app_locale)
       : phone_(phone),
-        country_code_(country_code) {
+        country_code_(country_code),
+        app_locale_(app_locale) {
   }
 
   bool operator()(const string16& phone) {
-    return autofill_i18n::PhoneNumbersMatch(phone, phone_, country_code_);
+    return autofill_i18n::PhoneNumbersMatch(
+        phone, phone_, country_code_, app_locale_);
   }
 
   bool operator()(const string16* phone) {
-    return autofill_i18n::PhoneNumbersMatch(*phone, phone_, country_code_);
+    return autofill_i18n::PhoneNumbersMatch(
+        *phone, phone_, country_code_, app_locale_);
   }
 
  private:
   string16 phone_;
   std::string country_code_;
+  std::string app_locale_;
 };
 
 // Functor used to check for case-insensitive equality of two strings.
@@ -348,18 +354,19 @@ void AutofillProfile::GetMultiInfo(AutofillFieldType type,
 
 void AutofillProfile::FillFormField(const AutofillField& field,
                                     size_t variant,
+                                    const std::string& app_locale,
                                     FormFieldData* field_data) const {
   AutofillFieldType type = field.type();
   DCHECK_NE(AutofillType::CREDIT_CARD, AutofillType(type).group());
   DCHECK(field_data);
 
   if (type == PHONE_HOME_NUMBER) {
-    FillPhoneNumberField(field, variant, field_data);
+    FillPhoneNumberField(field, variant, app_locale, field_data);
   } else if (field_data->form_control_type == "select-one") {
-    FillSelectControl(type, field_data);
+    FillSelectControl(type, app_locale, field_data);
   } else {
     std::vector<string16> values;
-    GetMultiInfo(type, AutofillCountry::ApplicationLocale(), &values);
+    GetMultiInfo(type, app_locale, &values);
     if (variant >= values.size()) {
       // If the variant is unavailable, bail.  This case is reachable, for
       // example if Sync updates a profile during the filling process.
@@ -372,9 +379,10 @@ void AutofillProfile::FillFormField(const AutofillField& field,
 
 void AutofillProfile::FillPhoneNumberField(const AutofillField& field,
                                            size_t variant,
+                                           const std::string& app_locale,
                                            FormFieldData* field_data) const {
   std::vector<string16> values;
-  GetMultiInfo(field.type(), AutofillCountry::ApplicationLocale(), &values);
+  GetMultiInfo(field.type(), app_locale, &values);
   DCHECK(variant < values.size());
 
   // If we are filling a phone number, check to see if the size field
@@ -400,9 +408,9 @@ const string16 AutofillProfile::Label() const {
   return label_;
 }
 
-bool AutofillProfile::IsEmpty() const {
+bool AutofillProfile::IsEmpty(const std::string& app_locale) const {
   FieldTypeSet types;
-  GetNonEmptyTypes(AutofillCountry::ApplicationLocale(), &types);
+  GetNonEmptyTypes(app_locale, &types);
   return types.empty();
 }
 
@@ -459,9 +467,10 @@ const string16 AutofillProfile::PrimaryValue() const {
   return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY);
 }
 
-bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile) const {
+bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile,
+                                 const std::string& app_locale) const {
   FieldTypeSet types;
-  GetNonEmptyTypes(AutofillCountry::ApplicationLocale(), &types);
+  GetNonEmptyTypes(app_locale, &types);
 
   for (FieldTypeSet::const_iterator iter = types.begin(); iter != types.end();
        ++iter) {
@@ -478,7 +487,8 @@ bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile) const {
       } else if (!autofill_i18n::PhoneNumbersMatch(
             GetRawInfo(*iter),
             profile.GetRawInfo(*iter),
-            UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)))) {
+            UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)),
+            app_locale)) {
         return false;
       }
     } else if (StringToLowerASCII(GetRawInfo(*iter)) !=
@@ -490,9 +500,10 @@ bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile) const {
   return true;
 }
 
-void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile) {
+void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile,
+                                           const std::string& app_locale) {
   FieldTypeSet field_types;
-  profile.GetNonEmptyTypes(AutofillCountry::ApplicationLocale(), &field_types);
+  profile.GetNonEmptyTypes(app_locale, &field_types);
 
   // Only transfer "full" types (e.g. full name) and not fragments (e.g.
   // first name, last name).
@@ -516,7 +527,7 @@ void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile) {
            value_iter != new_values.end(); ++value_iter) {
         // Don't add duplicates.
         if (group == AutofillType::PHONE) {
-          AddPhoneIfUnique(*value_iter, &existing_values);
+          AddPhoneIfUnique(*value_iter, app_locale, &existing_values);
         } else {
           std::vector<string16>::const_iterator existing_iter = std::find_if(
               existing_values.begin(), existing_values.end(),
@@ -613,10 +624,10 @@ void AutofillProfile::GetSupportedTypes(FieldTypeSet* supported_types) const {
     (*it)->GetSupportedTypes(supported_types);
 }
 
-bool AutofillProfile::FillCountrySelectControl(FormFieldData* field_data)
-    const {
+bool AutofillProfile::FillCountrySelectControl(
+    const std::string& app_locale,
+    FormFieldData* field_data) const {
   std::string country_code = UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY));
-  std::string app_locale = AutofillCountry::ApplicationLocale();
 
   DCHECK_EQ(field_data->option_values.size(),
             field_data->option_contents.size());
@@ -655,13 +666,14 @@ void AutofillProfile::GetMultiInfoImpl(AutofillFieldType type,
 }
 
 void AutofillProfile::AddPhoneIfUnique(const string16& phone,
+                                       const std::string& app_locale,
                                        std::vector<string16>* existing_phones) {
   DCHECK(existing_phones);
   // Phones allow "fuzzy" matching, so "1-800-FLOWERS", "18003569377",
   // "(800)356-9377" and "356-9377" are considered the same.
-  if (std::find_if(
-          existing_phones->begin(), existing_phones->end(),
-          FindByPhone(phone, UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)))) ==
+  std::string country_code = UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY));
+  if (std::find_if(existing_phones->begin(), existing_phones->end(),
+                   FindByPhone(phone, country_code, app_locale)) ==
       existing_phones->end()) {
     existing_phones->push_back(phone);
   }
diff --git a/components/autofill/browser/autofill_profile.h b/components/autofill/browser/autofill_profile.h
index d5a0561..be7367b 100644
--- a/components/autofill/browser/autofill_profile.h
+++ b/components/autofill/browser/autofill_profile.h
@@ -52,6 +52,7 @@ class AutofillProfile : public FormGroup {
                        const std::string& app_locale) OVERRIDE;
   virtual void FillFormField(const AutofillField& field,
                              size_t variant,
+                             const std::string& app_locale,
                              FormFieldData* field_data) const OVERRIDE;
 
   // Multi-value equivalents to |GetInfo| and |SetInfo|.
@@ -69,6 +70,7 @@ class AutofillProfile : public FormGroup {
   // multi-valued profile.
   void FillPhoneNumberField(const AutofillField& field,
                             size_t variant,
+                            const std::string& app_locale,
                             FormFieldData* field_data) const;
 
   // The user-visible label of the profile, generated in relation to other
@@ -83,7 +85,7 @@ class AutofillProfile : public FormGroup {
   void set_guid(const std::string& guid) { guid_ = guid; }
 
   // Returns true if there are no values (field types) set.
-  bool IsEmpty() const;
+  bool IsEmpty(const std::string& app_locale) const;
 
   // Comparison for Sync.  Returns 0 if the profile is the same as |this|,
   // or < 0, or > 0 if it is different.  The implied ordering can be used for
@@ -104,11 +106,13 @@ class AutofillProfile : public FormGroup {
 
   // Returns true if the data in this AutofillProfile is a subset of the data in
   // |profile|.
-  bool IsSubsetOf(const AutofillProfile& profile) const;
+  bool IsSubsetOf(const AutofillProfile& profile,
+                  const std::string& app_locale) const;
 
   // Overwrites the single-valued field data in |profile| with this
   // Profile.  Or, for multi-valued fields append the new values.
-  void OverwriteWithOrAddTo(const AutofillProfile& profile);
+  void OverwriteWithOrAddTo(const AutofillProfile& profile,
+                            const std::string& app_locale);
 
   // Returns |true| if |type| accepts multi-values.
   static bool SupportsMultiValue(AutofillFieldType type);
@@ -145,7 +149,8 @@ class AutofillProfile : public FormGroup {
   typedef std::vector<const FormGroup*> FormGroupList;
 
   // FormGroup:
-  virtual bool FillCountrySelectControl(FormFieldData* field) const OVERRIDE;
+  virtual bool FillCountrySelectControl(const std::string& app_locale,
+                                        FormFieldData* field) const OVERRIDE;
   virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
 
   // Shared implementation for GetRawMultiInfo() and GetMultiInfo().  Pass an
@@ -160,6 +165,7 @@ class AutofillProfile : public FormGroup {
   // are considered the same.
   // Adds the |phone| to the |existing_phones| if not already there.
   void AddPhoneIfUnique(const string16& phone,
+                        const std::string& app_locale,
                         std::vector<string16>* existing_phones);
 
   // Builds inferred label from the first |num_fields_to_include| non-empty
diff --git a/components/autofill/browser/autofill_profile_unittest.cc b/components/autofill/browser/autofill_profile_unittest.cc
index c93547f..1fb38c1 100644
--- a/components/autofill/browser/autofill_profile_unittest.cc
+++ b/components/autofill/browser/autofill_profile_unittest.cc
@@ -512,13 +512,13 @@ TEST(AutofillProfileTest, IsSubsetOf) {
   autofill_test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson",
       "declaration_guy@gmail.com", "United States Government", "Monticello",
       NULL, "Charlottesville", "Virginia", "22902", NULL, NULL);
-  EXPECT_TRUE(a->IsSubsetOf(*b));
+  EXPECT_TRUE(a->IsSubsetOf(*b, "en-US"));
 
   // |b| is not a subset of |a|.
-  EXPECT_FALSE(b->IsSubsetOf(*a));
+  EXPECT_FALSE(b->IsSubsetOf(*a, "en-US"));
 
   // |a| is a subset of |a|.
-  EXPECT_TRUE(a->IsSubsetOf(*a));
+  EXPECT_TRUE(a->IsSubsetOf(*a, "en-US"));
 
   // One field in |b| is different.
   a.reset(new AutofillProfile);
@@ -529,7 +529,7 @@ TEST(AutofillProfileTest, IsSubsetOf) {
   autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams",
       "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
       NULL);
-  EXPECT_FALSE(a->IsSubsetOf(*b));
+  EXPECT_FALSE(a->IsSubsetOf(*b, "en-US"));
 }
 
 TEST(AutofillProfileTest, AssignmentOperator) {
@@ -731,7 +731,7 @@ TEST(AutofillProfileTest, AddressCountryFull) {
 
   AutofillProfile profile;
   profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
-  profile.FillSelectControl(ADDRESS_HOME_COUNTRY, &field);
+  profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("Canada"), field.value);
 }
 
@@ -751,7 +751,7 @@ TEST(AutofillProfileTest, AddressCountryAbbrev) {
 
   AutofillProfile profile;
   profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
-  profile.FillSelectControl(ADDRESS_HOME_COUNTRY, &field);
+  profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
 }
 
@@ -771,7 +771,7 @@ TEST(AutofillProfileTest, AddressStateFull) {
 
   AutofillProfile profile;
   profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
-  profile.FillSelectControl(ADDRESS_HOME_STATE, &field);
+  profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("California"), field.value);
 }
 
@@ -791,7 +791,7 @@ TEST(AutofillProfileTest, AddressStateAbbrev) {
 
   AutofillProfile profile;
   profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
-  profile.FillSelectControl(ADDRESS_HOME_STATE, &field);
+  profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
 }
 
@@ -813,7 +813,7 @@ TEST(AutofillProfileTest, FillByValue) {
 
   AutofillProfile profile;
   profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
-  profile.FillSelectControl(ADDRESS_HOME_STATE, &field);
+  profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("California"), field.value);
 }
 
@@ -835,6 +835,6 @@ TEST(AutofillProfileTest, FillByContents) {
 
   AutofillProfile profile;
   profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
-  profile.FillSelectControl(ADDRESS_HOME_STATE, &field);
+  profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("2"), field.value);
 }
diff --git a/components/autofill/browser/credit_card.cc b/components/autofill/browser/credit_card.cc
index 4d004c4..d02b47d 100644
--- a/components/autofill/browser/credit_card.cc
+++ b/components/autofill/browser/credit_card.cc
@@ -17,7 +17,6 @@
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "base/utf_string_conversions.h"
-#include "components/autofill/browser/autofill_country.h"
 #include "components/autofill/browser/autofill_field.h"
 #include "components/autofill/browser/autofill_regexes.h"
 #include "components/autofill/browser/autofill_type.h"
@@ -512,14 +511,13 @@ bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card,
 
 void CreditCard::FillFormField(const AutofillField& field,
                                size_t /*variant*/,
+                               const std::string& app_locale,
                                FormFieldData* field_data) const {
   DCHECK_EQ(AutofillType::CREDIT_CARD, AutofillType(field.type()).group());
   DCHECK(field_data);
 
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
-
   if (field_data->form_control_type == "select-one") {
-    FillSelectControl(field.type(), field_data);
+    FillSelectControl(field.type(), app_locale, field_data);
   } else if (field_data->form_control_type == "month") {
     // HTML5 input="month" consists of year-month.
     string16 year = GetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, app_locale);
@@ -563,9 +561,9 @@ bool CreditCard::operator!=(const CreditCard& credit_card) const {
   return !operator==(credit_card);
 }
 
-bool CreditCard::IsEmpty() const {
+bool CreditCard::IsEmpty(const std::string& app_locale) const {
   FieldTypeSet types;
-  GetNonEmptyTypes(AutofillCountry::ApplicationLocale(), &types);
+  GetNonEmptyTypes(app_locale, &types);
   return types.empty();
 }
 
diff --git a/components/autofill/browser/credit_card.h b/components/autofill/browser/credit_card.h
index 320908a..18ad97c 100644
--- a/components/autofill/browser/credit_card.h
+++ b/components/autofill/browser/credit_card.h
@@ -46,6 +46,7 @@ class CreditCard : public FormGroup {
                        const std::string& app_locale) OVERRIDE;
   virtual void FillFormField(const AutofillField& field,
                              size_t variant,
+                             const std::string& app_locale,
                              FormFieldData* field_data) const OVERRIDE;
 
   // Credit card preview summary, for example: ******1234, Exp: 01/2020
@@ -97,7 +98,7 @@ class CreditCard : public FormGroup {
   bool operator!=(const CreditCard& credit_card) const;
 
   // Returns true if there are no values (field types) set.
-  bool IsEmpty() const;
+  bool IsEmpty(const std::string& app_locale) const;
 
   // Returns true if all field types have valid values set.
   bool IsComplete() const;
diff --git a/components/autofill/browser/credit_card_unittest.cc b/components/autofill/browser/credit_card_unittest.cc
index 847b344..fb98e2b 100644
--- a/components/autofill/browser/credit_card_unittest.cc
+++ b/components/autofill/browser/credit_card_unittest.cc
@@ -223,7 +223,7 @@ TEST(CreditCardTest, CreditCardMonthExact) {
 
   CreditCard credit_card;
   credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
-  credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, &field);
+  credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("01"), field.value);
 }
 
@@ -244,7 +244,7 @@ TEST(CreditCardTest, CreditCardMonthAbbreviated) {
 
   CreditCard credit_card;
   credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
-  credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, &field);
+  credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("Jan"), field.value);
 }
 
@@ -265,7 +265,7 @@ TEST(CreditCardTest, CreditCardMonthFull) {
 
   CreditCard credit_card;
   credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
-  credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, &field);
+  credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("January"), field.value);
 }
 
@@ -285,7 +285,7 @@ TEST(CreditCardTest, CreditCardMonthNumeric) {
 
   CreditCard credit_card;
   credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
-  credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, &field);
+  credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("1"), field.value);
 }
 
@@ -305,7 +305,7 @@ TEST(CreditCardTest, CreditCardTwoDigitYear) {
 
   CreditCard credit_card;
   credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2017"));
-  credit_card.FillSelectControl(CREDIT_CARD_EXP_4_DIGIT_YEAR, &field);
+  credit_card.FillSelectControl(CREDIT_CARD_EXP_4_DIGIT_YEAR, "en-US", &field);
   EXPECT_EQ(ASCIIToUTF16("17"), field.value);
   EXPECT_EQ(2017, credit_card.expiration_year());
 }
@@ -333,7 +333,7 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) {
     CreditCard credit_card;
     credit_card.SetRawInfo(CREDIT_CARD_NUMBER,
                            ASCIIToUTF16("4111111111111111"));
-    credit_card.FillSelectControl(CREDIT_CARD_TYPE, &field);
+    credit_card.FillSelectControl(CREDIT_CARD_TYPE, "en-US", &field);
     EXPECT_EQ(ASCIIToUTF16("Visa"), field.value);
   }
 
@@ -342,7 +342,7 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) {
     CreditCard credit_card;
     credit_card.SetRawInfo(CREDIT_CARD_NUMBER,
                            ASCIIToUTF16("5105105105105100"));
-    credit_card.FillSelectControl(CREDIT_CARD_TYPE, &field);
+    credit_card.FillSelectControl(CREDIT_CARD_TYPE, "en-US", &field);
     EXPECT_EQ(ASCIIToUTF16("Master Card"), field.value);
   }
 
@@ -350,7 +350,7 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) {
     // American Express is sometimes abbreviated as AmEx:
     CreditCard credit_card;
     credit_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("371449635398431"));
-    credit_card.FillSelectControl(CREDIT_CARD_TYPE, &field);
+    credit_card.FillSelectControl(CREDIT_CARD_TYPE, "en-US", &field);
     EXPECT_EQ(ASCIIToUTF16("AmEx"), field.value);
   }
 
@@ -359,7 +359,7 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) {
     CreditCard credit_card;
     credit_card.SetRawInfo(CREDIT_CARD_NUMBER,
                            ASCIIToUTF16("6011111111111117"));
-    credit_card.FillSelectControl(CREDIT_CARD_TYPE, &field);
+    credit_card.FillSelectControl(CREDIT_CARD_TYPE, "en-US", &field);
     EXPECT_EQ(ASCIIToUTF16("discover"), field.value);
   }
 }
diff --git a/components/autofill/browser/form_group.cc b/components/autofill/browser/form_group.cc
index b2f21d2..aca01b4 100644
--- a/components/autofill/browser/form_group.cc
+++ b/components/autofill/browser/form_group.cc
@@ -258,17 +258,18 @@ bool FormGroup::SetInfo(AutofillFieldType type,
 
 void FormGroup::FillFormField(const AutofillField& field,
                               size_t variant,
+                              const std::string& app_locale,
                               FormFieldData* field_data) const {
   NOTREACHED();
 }
 
 void FormGroup::FillSelectControl(AutofillFieldType type,
+                                  const std::string& app_locale,
                                   FormFieldData* field) const {
   DCHECK(field);
   DCHECK_EQ("select-one", field->form_control_type);
   DCHECK_EQ(field->option_values.size(), field->option_contents.size());
 
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
   string16 field_text = GetInfo(type, app_locale);
   string16 field_text_lower = StringToLowerASCII(field_text);
   if (field_text.empty())
@@ -299,20 +300,21 @@ void FormGroup::FillSelectControl(AutofillFieldType type,
   if (type == ADDRESS_HOME_STATE || type == ADDRESS_BILLING_STATE) {
     FillStateSelectControl(field_text, field);
   } else if (type == ADDRESS_HOME_COUNTRY || type == ADDRESS_BILLING_COUNTRY) {
-    FillCountrySelectControl(field);
+    FillCountrySelectControl(app_locale, field);
   } else if (type == CREDIT_CARD_EXP_MONTH) {
     FillExpirationMonthSelectControl(field_text, field);
   } else if (type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
     // Attempt to fill the year as a 2-digit year.  This compensates for the
     // fact that our heuristics do not always correctly detect when a website
     // requests a 2-digit rather than a 4-digit year.
-    FillSelectControl(CREDIT_CARD_EXP_2_DIGIT_YEAR, field);
+    FillSelectControl(CREDIT_CARD_EXP_2_DIGIT_YEAR, app_locale, field);
   } else if (type == CREDIT_CARD_TYPE) {
     FillCreditCardTypeSelectControl(field_text, field);
   }
 }
 
-bool FormGroup::FillCountrySelectControl(FormFieldData* field_data) const {
+bool FormGroup::FillCountrySelectControl(const std::string& app_locale,
+                                         FormFieldData* field_data) const {
   return false;
 }
 
diff --git a/components/autofill/browser/form_group.h b/components/autofill/browser/form_group.h
index d7f0c8c..c0038b5 100644
--- a/components/autofill/browser/form_group.h
+++ b/components/autofill/browser/form_group.h
@@ -63,11 +63,13 @@ class FormGroup {
   // data variant |variant|). It is an error to call the default implementation.
   virtual void FillFormField(const AutofillField& field,
                              size_t variant,
+                             const std::string& app_locale,
                              FormFieldData* field_data) const;
 
   // Fills in select control with data matching |type| from |this|.
   // Public for testing purposes.
   void FillSelectControl(AutofillFieldType type,
+                         const std::string& app_locale,
                          FormFieldData* field_data) const;
 
   // Returns true if |value| is a valid US state name or abbreviation.  It is
@@ -86,7 +88,8 @@ class FormGroup {
 
   // Fills in a select control for a country from data in |this|. Returns true
   // for success.
-  virtual bool FillCountrySelectControl(FormFieldData* field_data) const;
+  virtual bool FillCountrySelectControl(const std::string& app_locale,
+                                        FormFieldData* field_data) const;
 };
 
 #endif  // COMPONENTS_AUTOFILL_BROWSER_FORM_GROUP_H_
diff --git a/components/autofill/browser/personal_data_manager.cc b/components/autofill/browser/personal_data_manager.cc
index fd6456b..5696421 100644
--- a/components/autofill/browser/personal_data_manager.cc
+++ b/components/autofill/browser/personal_data_manager.cc
@@ -13,9 +13,8 @@
 #include "base/prefs/pref_service.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/utf_string_conversions.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "components/autofill/browser/autofill-inl.h"
 #include "components/autofill/browser/autofill_country.h"
+#include "components/autofill/browser/autofill-inl.h"
 #include "components/autofill/browser/autofill_field.h"
 #include "components/autofill/browser/autofill_metrics.h"
 #include "components/autofill/browser/form_group.h"
@@ -28,7 +27,6 @@
 #include "components/user_prefs/user_prefs.h"
 #include "components/webdata/autofill/autofill_webdata_service.h"
 #include "content/public/browser/browser_context.h"
-#include "content/public/browser/notification_source.h"
 
 using content::BrowserContext;
 
@@ -82,11 +80,11 @@ T* address_of(T& v) {
 // required as determined by its country code.
 // No verification of validity of the contents is preformed. This is an
 // existence check only.
-bool IsMinimumAddress(const AutofillProfile& profile) {
+bool IsMinimumAddress(const AutofillProfile& profile,
+                      const std::string& app_locale) {
   // All countries require at least one address line.
   if (profile.GetRawInfo(ADDRESS_HOME_LINE1).empty())
     return false;
-  std::string app_locale = AutofillCountry::ApplicationLocale();
   std::string country_code =
       UTF16ToASCII(profile.GetRawInfo(ADDRESS_HOME_COUNTRY));
 
@@ -130,11 +128,12 @@ bool IsValidFieldTypeAndValue(const std::set<AutofillFieldType>& types_seen,
 
 }  // namespace
 
-PersonalDataManager::PersonalDataManager()
+PersonalDataManager::PersonalDataManager(const std::string& app_locale)
     : browser_context_(NULL),
       is_data_loaded_(false),
       pending_profiles_query_(0),
       pending_creditcards_query_(0),
+      app_locale_(app_locale),
       metric_logger_(new AutofillMetrics),
       has_logged_profile_count_(false) {}
 
@@ -238,7 +237,6 @@ bool PersonalDataManager::ImportFormData(
   // complete at the end.
   PhoneNumber::PhoneCombineHelper home;
 
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
   for (size_t i = 0; i < form.field_count(); ++i) {
     const AutofillField* field = form.field(i);
     string16 value = CollapseWhitespace(field->value, false);
@@ -266,7 +264,7 @@ bool PersonalDataManager::ImportFormData(
         DCHECK_EQ(CREDIT_CARD_EXP_MONTH, field_type);
         local_imported_credit_card->SetInfoForMonthInputType(value);
       } else {
-        local_imported_credit_card->SetInfo(field_type, value, app_locale);
+        local_imported_credit_card->SetInfo(field_type, value, app_locale_);
       }
       ++importable_credit_card_fields;
     } else {
@@ -275,7 +273,7 @@ bool PersonalDataManager::ImportFormData(
       // If the fields are not the phone fields in question home.SetInfo() is
       // going to return false.
       if (!home.SetInfo(field_type, value))
-        imported_profile->SetInfo(field_type, value, app_locale);
+        imported_profile->SetInfo(field_type, value, app_locale_);
 
       // Reject profiles with invalid country information.
       if (field_type == ADDRESS_HOME_COUNTRY &&
@@ -290,16 +288,18 @@ bool PersonalDataManager::ImportFormData(
   // Construct the phone number. Reject the profile if the number is invalid.
   if (imported_profile.get() && !home.IsEmpty()) {
     string16 constructed_number;
-    if (!home.ParseNumber(*imported_profile, app_locale, &constructed_number) ||
+    if (!home.ParseNumber(*imported_profile, app_locale_,
+                          &constructed_number) ||
         !imported_profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number,
-                                   app_locale)) {
+                                   app_locale_)) {
       imported_profile.reset();
     }
   }
 
   // Reject the profile if minimum address and validation requirements are not
   // met.
-  if (imported_profile.get() && !IsValidLearnableProfile(*imported_profile))
+  if (imported_profile.get() &&
+      !IsValidLearnableProfile(*imported_profile, app_locale_))
     imported_profile.reset();
 
   // Reject the credit card if we did not detect enough filled credit card
@@ -317,7 +317,7 @@ bool PersonalDataManager::ImportFormData(
          iter != credit_cards_.end();
          ++iter) {
       if ((*iter)->UpdateFromImportedCard(*local_imported_credit_card.get(),
-                                          app_locale)) {
+                                          app_locale_)) {
         merged_credit_card = true;
         UpdateCreditCard(**iter);
         local_imported_credit_card.reset();
@@ -345,7 +345,7 @@ void PersonalDataManager::AddProfile(const AutofillProfile& profile) {
   if (browser_context_->IsOffTheRecord())
     return;
 
-  if (profile.IsEmpty())
+  if (profile.IsEmpty(app_locale_))
     return;
 
   // Don't add an existing profile.
@@ -375,7 +375,7 @@ void PersonalDataManager::UpdateProfile(const AutofillProfile& profile) {
   if (!FindByGUID<AutofillProfile>(web_profiles_, profile.guid()))
     return;
 
-  if (profile.IsEmpty()) {
+  if (profile.IsEmpty(app_locale_)) {
     RemoveByGUID(profile.guid());
     return;
   }
@@ -407,7 +407,7 @@ void PersonalDataManager::AddCreditCard(const CreditCard& credit_card) {
   if (browser_context_->IsOffTheRecord())
     return;
 
-  if (credit_card.IsEmpty())
+  if (credit_card.IsEmpty(app_locale_))
     return;
 
   if (FindByGUID<CreditCard>(credit_cards_, credit_card.guid()))
@@ -436,7 +436,7 @@ void PersonalDataManager::UpdateCreditCard(const CreditCard& credit_card) {
   if (!FindByGUID<CreditCard>(credit_cards_, credit_card.guid()))
     return;
 
-  if (credit_card.IsEmpty()) {
+  if (credit_card.IsEmpty(app_locale_)) {
     RemoveByGUID(credit_card.guid());
     return;
   }
@@ -488,16 +488,15 @@ CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) {
 
 void PersonalDataManager::GetNonEmptyTypes(
     FieldTypeSet* non_empty_types) {
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
   const std::vector<AutofillProfile*>& profiles = GetProfiles();
   for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin();
        iter != profiles.end(); ++iter) {
-    (*iter)->GetNonEmptyTypes(app_locale, non_empty_types);
+    (*iter)->GetNonEmptyTypes(app_locale_, non_empty_types);
   }
 
   for (ScopedVector<CreditCard>::const_iterator iter = credit_cards_.begin();
        iter != credit_cards_.end(); ++iter) {
-    (*iter)->GetNonEmptyTypes(app_locale, non_empty_types);
+    (*iter)->GetNonEmptyTypes(app_locale_, non_empty_types);
   }
 }
 
@@ -550,7 +549,6 @@ void PersonalDataManager::GetProfileSuggestions(
   guid_pairs->clear();
 
   const std::vector<AutofillProfile*>& profiles = GetProfiles();
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
   std::vector<AutofillProfile*> matched_profiles;
   for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin();
        iter != profiles.end(); ++iter) {
@@ -558,7 +556,7 @@ void PersonalDataManager::GetProfileSuggestions(
 
     // The value of the stored data for this field type in the |profile|.
     std::vector<string16> multi_values;
-    profile->GetMultiInfo(type, app_locale, &multi_values);
+    profile->GetMultiInfo(type, app_locale_, &multi_values);
 
     for (size_t i = 0; i < multi_values.size(); ++i) {
       if (!field_is_autofilled) {
@@ -623,13 +621,12 @@ void PersonalDataManager::GetCreditCardSuggestions(
     std::vector<string16>* labels,
     std::vector<string16>* icons,
     std::vector<GUIDPair>* guid_pairs) {
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
   for (std::vector<CreditCard*>::const_iterator iter = credit_cards().begin();
        iter != credit_cards().end(); ++iter) {
     CreditCard* credit_card = *iter;
 
     // The value of the stored data for this field type in the |credit_card|.
-    string16 creditcard_field_value = credit_card->GetInfo(type, app_locale);
+    string16 creditcard_field_value = credit_card->GetInfo(type, app_locale_);
     if (!creditcard_field_value.empty() &&
         StartsWith(creditcard_field_value, field_contents, false)) {
       if (type == CREDIT_CARD_NUMBER)
@@ -638,7 +635,7 @@ void PersonalDataManager::GetCreditCardSuggestions(
       string16 label;
       if (credit_card->number().empty()) {
         // If there is no CC number, return name to show something.
-        label = credit_card->GetInfo(CREDIT_CARD_NAME, app_locale);
+        label = credit_card->GetInfo(CREDIT_CARD_NAME, app_locale_);
       } else {
         label = kCreditCardPrefix;
         label.append(credit_card->LastFourDigits());
@@ -659,8 +656,9 @@ bool PersonalDataManager::IsAutofillEnabled() const {
 
 // static
 bool PersonalDataManager::IsValidLearnableProfile(
-    const AutofillProfile& profile) {
-  if (!IsMinimumAddress(profile))
+    const AutofillProfile& profile,
+    const std::string& app_locale) {
+  if (!IsMinimumAddress(profile, app_locale))
     return false;
 
   string16 email = profile.GetRawInfo(EMAIL_ADDRESS);
@@ -687,6 +685,7 @@ bool PersonalDataManager::IsValidLearnableProfile(
 bool PersonalDataManager::MergeProfile(
     const AutofillProfile& profile,
     const std::vector<AutofillProfile*>& existing_profiles,
+    const std::string& app_locale,
     std::vector<AutofillProfile>* merged_profiles) {
   merged_profiles->clear();
 
@@ -703,7 +702,7 @@ bool PersonalDataManager::MergeProfile(
           StringToLowerASCII((*iter)->PrimaryValue()) ==
               StringToLowerASCII(profile.PrimaryValue())) {
         merged = true;
-        (*iter)->OverwriteWithOrAddTo(profile);
+        (*iter)->OverwriteWithOrAddTo(profile, app_locale);
       }
     }
     merged_profiles->push_back(**iter);
@@ -721,10 +720,13 @@ void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) {
     return;
 
   // Remove empty profiles from input.
-  profiles->erase(
-      std::remove_if(profiles->begin(), profiles->end(),
-                     std::mem_fun_ref(&AutofillProfile::IsEmpty)),
-      profiles->end());
+  for (std::vector<AutofillProfile>::iterator it = profiles->begin();
+       it != profiles->end();) {
+    if (it->IsEmpty(app_locale_))
+      profiles->erase(it);
+    else
+      it++;
+  }
 
   // Ensure that profile labels are up to date.  Currently, sync relies on
   // labels to identify a profile.
@@ -781,11 +783,13 @@ void PersonalDataManager::SetCreditCards(
     return;
 
   // Remove empty credit cards from input.
-  credit_cards->erase(
-      std::remove_if(
-          credit_cards->begin(), credit_cards->end(),
-          std::mem_fun_ref(&CreditCard::IsEmpty)),
-      credit_cards->end());
+  for (std::vector<CreditCard>::iterator it = credit_cards->begin();
+       it != credit_cards->end();) {
+    if (it->IsEmpty(app_locale_))
+      credit_cards->erase(it);
+    else
+      it++;
+  }
 
   scoped_refptr<AutofillWebDataService> autofill_data(
       AutofillWebDataService::FromBrowserContext(browser_context_));
@@ -923,12 +927,12 @@ void PersonalDataManager::SaveImportedProfile(
   for (std::vector<AutofillProfile*>::const_iterator iter =
            auxiliary_profiles_.begin();
        iter != auxiliary_profiles_.end(); ++iter) {
-    if (imported_profile.IsSubsetOf(**iter))
+    if (imported_profile.IsSubsetOf(**iter, app_locale_))
       return;
   }
 
   std::vector<AutofillProfile> profiles;
-  MergeProfile(imported_profile, web_profiles_.get(), &profiles);
+  MergeProfile(imported_profile, web_profiles_.get(), app_locale_, &profiles);
   SetProfiles(&profiles);
 }
 
@@ -946,14 +950,13 @@ void PersonalDataManager::SaveImportedCreditCard(
   // Set to true if |imported_card| is merged into the credit card list.
   bool merged = false;
 
-  const std::string app_locale = AutofillCountry::ApplicationLocale();
   std::vector<CreditCard> credit_cards;
   for (std::vector<CreditCard*>::const_iterator card = credit_cards_.begin();
        card != credit_cards_.end();
        ++card) {
     // If |imported_card| has not yet been merged, check whether it should be
     // with the current |card|.
-    if (!merged && (*card)->UpdateFromImportedCard(imported_card, app_locale))
+    if (!merged && (*card)->UpdateFromImportedCard(imported_card, app_locale_))
       merged = true;
 
     credit_cards.push_back(**card);
diff --git a/components/autofill/browser/personal_data_manager.h b/components/autofill/browser/personal_data_manager.h
index 5920b9a..b614233c 100644
--- a/components/autofill/browser/personal_data_manager.h
+++ b/components/autofill/browser/personal_data_manager.h
@@ -42,7 +42,7 @@ class PersonalDataManager : public WebDataServiceConsumer,
   // specific data variant.
   typedef std::pair<std::string, size_t> GUIDPair;
 
-  PersonalDataManager();
+  explicit PersonalDataManager(const std::string& app_locale);
   virtual ~PersonalDataManager();
 
   // Kicks off asynchronous loading of profiles and credit cards.
@@ -152,8 +152,11 @@ class PersonalDataManager : public WebDataServiceConsumer,
   // Also see SetProfile for more details.
   virtual void Refresh();
 
+  const std::string& app_locale() const { return app_locale_; }
+
   // Checks suitability of |profile| for adding to the user's set of profiles.
-  static bool IsValidLearnableProfile(const AutofillProfile& profile);
+  static bool IsValidLearnableProfile(const AutofillProfile& profile,
+                                      const std::string& app_locale);
 
   // Merges |profile| into one of the |existing_profiles| if possible; otherwise
   // appends |profile| to the end of that list. Fills |merged_profiles| with the
@@ -161,6 +164,7 @@ class PersonalDataManager : public WebDataServiceConsumer,
   static bool MergeProfile(
       const AutofillProfile& profile,
       const std::vector<AutofillProfile*>& existing_profiles,
+      const std::string& app_locale,
       std::vector<AutofillProfile>* merged_profiles);
 
  protected:
@@ -261,6 +265,7 @@ class PersonalDataManager : public WebDataServiceConsumer,
   ObserverList<PersonalDataManagerObserver> observers_;
 
  private:
+  std::string app_locale_;
 
   // For logging UMA metrics. Overridden by metrics tests.
   scoped_ptr<const AutofillMetrics> metric_logger_;
diff --git a/components/autofill/browser/personal_data_manager_mac.mm b/components/autofill/browser/personal_data_manager_mac.mm
index 1ffe696..7534190 100644
--- a/components/autofill/browser/personal_data_manager_mac.mm
+++ b/components/autofill/browser/personal_data_manager_mac.mm
@@ -42,13 +42,15 @@ class AuxiliaryProfilesImpl {
   virtual ~AuxiliaryProfilesImpl() {}
 
   // Import the "me" card from the Mac Address Book and fill in |profiles_|.
-  void GetAddressBookMeCard();
+  void GetAddressBookMeCard(const std::string& app_locale);
 
  private:
   void GetAddressBookNames(ABPerson* me,
                            NSString* addressLabelRaw,
                            AutofillProfile* profile);
-  void GetAddressBookAddress(NSDictionary* address, AutofillProfile* profile);
+  void GetAddressBookAddress(const std::string& app_locale,
+                             NSDictionary* address,
+                             AutofillProfile* profile);
   void GetAddressBookEmail(ABPerson* me,
                            NSString* addressLabelRaw,
                            AutofillProfile* profile);
@@ -67,7 +69,8 @@ class AuxiliaryProfilesImpl {
 // 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() {
+void AuxiliaryProfilesImpl::GetAddressBookMeCard(
+    const std::string& app_locale) {
   profiles_.clear();
 
   // +[ABAddressBook sharedAddressBook] throws an exception internally in
@@ -122,7 +125,7 @@ void AuxiliaryProfilesImpl::GetAddressBookMeCard() {
     GetAddressBookNames(me, addressLabelRaw, profile.get());
 
     // Fill in address information.
-    GetAddressBookAddress(address, profile.get());
+    GetAddressBookAddress(app_locale, address, profile.get());
 
     // Fill in email information.
     GetAddressBookEmail(me, addressLabelRaw, profile.get());
@@ -158,7 +161,8 @@ void AuxiliaryProfilesImpl::GetAddressBookNames(
 // 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::GetAddressBookAddress(NSDictionary* address,
+void AuxiliaryProfilesImpl::GetAddressBookAddress(const std::string& app_locale,
+                                                  NSDictionary* address,
                                                   AutofillProfile* profile) {
   if (NSString* addressField = [address objectForKey:kABAddressStreetKey]) {
     // If there are newlines in the address, split into two lines.
@@ -197,7 +201,7 @@ void AuxiliaryProfilesImpl::GetAddressBookAddress(NSDictionary* address,
   if (NSString* country = [address objectForKey:kABAddressCountryKey]) {
     profile->SetInfo(ADDRESS_HOME_COUNTRY,
                      base::SysNSStringToUTF16(country),
-                     AutofillCountry::ApplicationLocale());
+                     app_locale);
   }
 }
 
@@ -258,5 +262,5 @@ void AuxiliaryProfilesImpl::GetAddressBookPhoneNumbers(
 // Populate |auxiliary_profiles_| with the Address Book data.
 void PersonalDataManager::LoadAuxiliaryProfiles() {
   AuxiliaryProfilesImpl impl(&auxiliary_profiles_);
-  impl.GetAddressBookMeCard();
+  impl.GetAddressBookMeCard(app_locale_);
 }
diff --git a/components/autofill/browser/personal_data_manager_unittest.cc b/components/autofill/browser/personal_data_manager_unittest.cc
index ac3a40f..fe4238c 100644
--- a/components/autofill/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/browser/personal_data_manager_unittest.cc
@@ -92,7 +92,7 @@ class PersonalDataManagerTest : public testing::Test {
   }
 
   void ResetPersonalDataManager() {
-    personal_data_.reset(new PersonalDataManager);
+    personal_data_.reset(new PersonalDataManager("en-US"));
     personal_data_->Init(profile_.get());
     personal_data_->AddObserver(&personal_data_observer_);
 
diff --git a/components/autofill/browser/phone_number_i18n.cc b/components/autofill/browser/phone_number_i18n.cc
index 0f71deb..8ff85df 100644
--- a/components/autofill/browser/phone_number_i18n.cc
+++ b/components/autofill/browser/phone_number_i18n.cc
@@ -18,12 +18,12 @@ using i18n::phonenumbers::PhoneNumberUtil;
 
 namespace {
 
-std::string SanitizeRegion(const std::string& region) {
+std::string SanitizeRegion(const std::string& region,
+                           const std::string& app_locale) {
   if (region.length() == 2)
     return region;
 
-  return AutofillCountry::CountryCodeForLocale(
-      AutofillCountry::ApplicationLocale());
+  return AutofillCountry::CountryCodeForLocale(app_locale);
 }
 
 // Returns true if |phone_number| is valid.
@@ -149,13 +149,14 @@ bool ParsePhoneNumber(const string16& value,
 }
 
 string16 NormalizePhoneNumber(const string16& value,
-                              std::string const& region) {
+                              const std::string& region) {
+  DCHECK_EQ(2u, region.size());
   string16 country_code;
   string16 unused_city_code;
   string16 unused_number;
   PhoneNumber phone_number;
-  if (!ParsePhoneNumber(value, SanitizeRegion(region), &country_code,
-                        &unused_city_code, &unused_number, &phone_number)) {
+  if (!ParsePhoneNumber(value, region, &country_code, &unused_city_code,
+                        &unused_number, &phone_number)) {
     return string16();  // Parsing failed - do not store phone.
   }
 
@@ -169,14 +170,14 @@ bool ConstructPhoneNumber(const string16& country_code,
                           const string16& number,
                           const std::string& region,
                           string16* whole_number) {
+  DCHECK_EQ(2u, region.size());
   whole_number->clear();
 
   string16 unused_country_code;
   string16 unused_city_code;
   string16 unused_number;
   PhoneNumber phone_number;
-  if (!ParsePhoneNumber(country_code + city_code + number,
-                        SanitizeRegion(region),
+  if (!ParsePhoneNumber(country_code + city_code + number, region,
                         &unused_country_code, &unused_city_code, &unused_number,
                         &phone_number)) {
     return false;
@@ -188,9 +189,10 @@ bool ConstructPhoneNumber(const string16& country_code,
 
 bool PhoneNumbersMatch(const string16& number_a,
                        const string16& number_b,
-                       const std::string& raw_region) {
+                       const std::string& raw_region,
+                       const std::string& app_locale) {
   // Sanitize the provided |raw_region| before trying to use it for parsing.
-  const std::string region = SanitizeRegion(raw_region);
+  const std::string region = SanitizeRegion(raw_region, app_locale);
 
   PhoneNumberUtil* phone_util = PhoneNumberUtil::GetInstance();
 
@@ -222,9 +224,11 @@ bool PhoneNumbersMatch(const string16& number_a,
   return false;
 }
 
-PhoneObject::PhoneObject(const string16& number, const std::string& region)
-    : region_(SanitizeRegion(region)),
+PhoneObject::PhoneObject(const string16& number,
+                         const std::string& region)
+    : region_(region),
       i18n_number_(NULL) {
+  DCHECK_EQ(2u, region.size());
   // TODO(isherman): Autofill profiles should always have a |region| set, but in
   // some cases it should be marked as implicit.  Otherwise, phone numbers
   // might behave differently when they are synced across computers:
diff --git a/components/autofill/browser/phone_number_i18n.h b/components/autofill/browser/phone_number_i18n.h
index 3a35c3b..708da45 100644
--- a/components/autofill/browser/phone_number_i18n.h
+++ b/components/autofill/browser/phone_number_i18n.h
@@ -59,12 +59,14 @@ bool ConstructPhoneNumber(const string16& country_code,
 // the given |region|.
 bool PhoneNumbersMatch(const string16& number_a,
                        const string16& number_b,
-                       const std::string& region);
+                       const std::string& region,
+                       const std::string& app_locale);
 
 // The cached phone number, does parsing only once, improves performance.
 class PhoneObject {
  public:
-  PhoneObject(const string16& number, const std::string& region);
+  PhoneObject(const string16& number,
+              const std::string& region);
   PhoneObject(const PhoneObject&);
   PhoneObject();
   ~PhoneObject();
diff --git a/components/autofill/browser/phone_number_i18n_unittest.cc b/components/autofill/browser/phone_number_i18n_unittest.cc
index 8e25520..7744272 100644
--- a/components/autofill/browser/phone_number_i18n_unittest.cc
+++ b/components/autofill/browser/phone_number_i18n_unittest.cc
@@ -332,41 +332,51 @@ TEST(PhoneNumberI18NTest, PhoneNumbersMatch) {
   // Same numbers, defined country code.
   EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
                                 ASCIIToUTF16("4158889999"),
-                                "US"));
+                                "US",
+                                "en-US"));
   // Same numbers, undefined country code.
   EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
                                 ASCIIToUTF16("4158889999"),
-                                ""));
+                                "",
+                                "en-US"));
 
   // Numbers differ by country code only.
   EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
                                 ASCIIToUTF16("4158889999"),
-                                "US"));
+                                "US",
+                                "en-US"));
 
   // Same numbers, different formats.
   EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
                                 ASCIIToUTF16("415-888-9999"),
-                                "US"));
+                                "US",
+                                "en-US"));
   EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
                                 ASCIIToUTF16("(415)888-9999"),
-                                "US"));
+                                "US",
+                                "en-US"));
   EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
                                 ASCIIToUTF16("415 888 9999"),
-                                "US"));
+                                "US",
+                                "en-US"));
   EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"),
                                 ASCIIToUTF16("415 TUV WXYZ"),
-                                "US"));
+                                "US",
+                                "en-US"));
   EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("1(415)888-99-99"),
                                 ASCIIToUTF16("+14158889999"),
-                                "US"));
+                                "US",
+                                "en-US"));
 
   // Partial matches don't count.
   EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
                                  ASCIIToUTF16("8889999"),
-                                 "US"));
+                                 "US",
+                                 "en-US"));
 
   // Different numbers don't match.
   EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
                                  ASCIIToUTF16("1415888"),
-                                 "US"));
+                                 "US",
+                                 "en-US"));
 }
diff --git a/components/autofill/browser/wallet/wallet_address.cc b/components/autofill/browser/wallet/wallet_address.cc
index 9e5f5d4..209330d 100644
--- a/components/autofill/browser/wallet/wallet_address.cc
+++ b/components/autofill/browser/wallet/wallet_address.cc
@@ -233,7 +233,8 @@ string16 Address::DisplayNameDetail() const {
 #endif
 }
 
-string16 Address::GetInfo(AutofillFieldType type) const {
+string16 Address::GetInfo(AutofillFieldType type,
+                          const std::string& app_locale) const {
   switch (type) {
     case NAME_FULL:
       return recipient_name();
@@ -254,8 +255,7 @@ string16 Address::GetInfo(AutofillFieldType type) const {
       return postal_code_number();
 
     case ADDRESS_HOME_COUNTRY: {
-      AutofillCountry country(country_name_code(),
-                              AutofillCountry::ApplicationLocale());
+      AutofillCountry country(country_name_code(), app_locale);
       return country.name();
     }
 
diff --git a/components/autofill/browser/wallet/wallet_address.h b/components/autofill/browser/wallet/wallet_address.h
index c6ac95e..b8ebf94 100644
--- a/components/autofill/browser/wallet/wallet_address.h
+++ b/components/autofill/browser/wallet/wallet_address.h
@@ -88,7 +88,8 @@ class Address {
   string16 DisplayNameDetail() const;
 
   // Returns data appropriate for |type|.
-  string16 GetInfo(AutofillFieldType type) const;
+  string16 GetInfo(AutofillFieldType type,
+                   const std::string& app_locale) const;
 
   const std::string& country_name_code() const { return country_name_code_; }
   const string16& recipient_name() const { return recipient_name_; }
diff --git a/components/autofill/browser/wallet/wallet_items.cc b/components/autofill/browser/wallet/wallet_items.cc
index 4084998..8d7e8c4 100644
--- a/components/autofill/browser/wallet/wallet_items.cc
+++ b/components/autofill/browser/wallet/wallet_items.cc
@@ -313,9 +313,11 @@ const gfx::Image& WalletItems::MaskedInstrument::CardIcon() const {
   return ResourceBundle::GetSharedInstance().GetImageNamed(idr);
 }
 
-string16 WalletItems::MaskedInstrument::GetInfo(AutofillFieldType type) const {
+string16 WalletItems::MaskedInstrument::GetInfo(
+    AutofillFieldType type,
+    const std::string& app_locale) const {
   if (AutofillType(type).group() != AutofillType::CREDIT_CARD)
-    return address().GetInfo(type);
+    return address().GetInfo(type, app_locale);
 
   switch (type) {
     case CREDIT_CARD_NAME:
diff --git a/components/autofill/browser/wallet/wallet_items.h b/components/autofill/browser/wallet/wallet_items.h
index ddd22b7..f072b79 100644
--- a/components/autofill/browser/wallet/wallet_items.h
+++ b/components/autofill/browser/wallet/wallet_items.h
@@ -86,7 +86,8 @@ class WalletItems {
     string16 DisplayNameDetail() const;
 
     // Gets info that corresponds with |type|.
-    string16 GetInfo(AutofillFieldType type) const;
+    string16 GetInfo(AutofillFieldType type,
+                     const std::string& app_locale) const;
 
     // Returns the display type of the and last four digits (e.g. Visa - 4444).
     string16 TypeAndLastFourDigits() const;
diff --git a/components/webdata/autofill/autofill_table.cc b/components/webdata/autofill/autofill_table.cc
index 8218d14..318458d 100644
--- a/components/webdata/autofill/autofill_table.cc
+++ b/components/webdata/autofill/autofill_table.cc
@@ -333,8 +333,8 @@ WebDatabaseTable::TypeKey GetKey() {
 // The maximum length allowed for form data.
 const size_t AutofillTable::kMaxDataLength = 1024;
 
-AutofillTable::AutofillTable()
-    : app_locale_(AutofillCountry::ApplicationLocale()) {
+AutofillTable::AutofillTable(const std::string& app_locale)
+    : app_locale_(app_locale) {
 }
 
 AutofillTable::~AutofillTable() {
@@ -1991,10 +1991,10 @@ bool AutofillTable::MigrateToVersion37MergeAndCullOlderProfiles() {
 
     scoped_ptr<AutofillProfile> p(profile);
 
-    if (PersonalDataManager::IsValidLearnableProfile(*p)) {
+    if (PersonalDataManager::IsValidLearnableProfile(*p, app_locale_)) {
       std::vector<AutofillProfile> merged_profiles;
       bool merged = PersonalDataManager::MergeProfile(
-          *p, accumulated_profiles_p, &merged_profiles);
+          *p, accumulated_profiles_p, app_locale_, &merged_profiles);
 
       std::swap(accumulated_profiles, merged_profiles);
 
diff --git a/components/webdata/autofill/autofill_table.h b/components/webdata/autofill/autofill_table.h
index 22991d4..c0c24bb 100644
--- a/components/webdata/autofill/autofill_table.h
+++ b/components/webdata/autofill/autofill_table.h
@@ -115,7 +115,7 @@ class Time;
 //
 class AutofillTable : public WebDatabaseTable {
  public:
-  AutofillTable();
+  explicit AutofillTable(const std::string& app_locale);
   virtual ~AutofillTable();
 
   // Retrieves the AutofillTable* owned by |database|.
diff --git a/components/webdata/autofill/autofill_table_unittest.cc b/components/webdata/autofill/autofill_table_unittest.cc
index 6ce6d57..34be794 100644
--- a/components/webdata/autofill/autofill_table_unittest.cc
+++ b/components/webdata/autofill/autofill_table_unittest.cc
@@ -98,7 +98,7 @@ class AutofillTableTest : public testing::Test {
     ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
     file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
 
-    table_.reset(new AutofillTable);
+    table_.reset(new AutofillTable("en-US"));
     db_.reset(new WebDatabase);
     db_->AddTable(table_.get());
     ASSERT_EQ(sql::INIT_OK, db_->Init(file_));
diff --git a/components/webdata/autofill/web_data_service_unittest.cc b/components/webdata/autofill/web_data_service_unittest.cc
index b7124ac..0f74612 100644
--- a/components/webdata/autofill/web_data_service_unittest.cc
+++ b/components/webdata/autofill/web_data_service_unittest.cc
@@ -71,7 +71,7 @@ class WebDataServiceTest : public testing::Test {
     base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB");
 
     wdbs_ = new WebDatabaseService(path);
-    wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new AutofillTable()));
+    wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new AutofillTable("en-US")));
     wdbs_->LoadDatabase(WebDatabaseService::InitCallback());
 
     wds_ = new AutofillWebDataService(
diff --git a/components/webdata/autofill/web_database_migration_unittest.cc b/components/webdata/autofill/web_database_migration_unittest.cc
index 8a715a5..8c3bb1c 100644
--- a/components/webdata/autofill/web_database_migration_unittest.cc
+++ b/components/webdata/autofill/web_database_migration_unittest.cc
@@ -175,7 +175,7 @@ class WebDatabaseMigrationTest : public testing::Test {
     // for now, as it needs to know about all the different table
     // types. Once all webdata datatypes have been componentized, this
     // could move to components_unittests.
-    AutofillTable autofill_table;
+    AutofillTable autofill_table("en-US");
     KeywordTable keyword_table;
     LoginsTable logins_table;
     TokenServiceTable token_service_table;
-- 
cgit v1.1