| Index: chrome/browser/autofill/autofill_country.cc
|
| diff --git a/chrome/browser/autofill/autofill_country.cc b/chrome/browser/autofill/autofill_country.cc
|
| index a6860a03d6f4c923fdd1e2256ac54044b7c85356..951e8bfc0590db8f4823bf678d27f5d785e7309b 100644
|
| --- a/chrome/browser/autofill/autofill_country.cc
|
| +++ b/chrome/browser/autofill/autofill_country.cc
|
| @@ -16,6 +16,7 @@
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/browser_process.h"
|
| +#include "content/browser/browser_thread.h"
|
| #include "grit/generated_resources.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "unicode/coll.h"
|
| @@ -355,6 +356,9 @@ 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,
|
| @@ -404,6 +408,9 @@ class CountryNames {
|
| // Maps ICU locale names to their corresponding collators.
|
| std::map<std::string, icu::Collator*> collators_;
|
|
|
| + // Caches the application locale, for thread-safe access.
|
| + std::string application_locale_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(CountryNames);
|
| };
|
|
|
| @@ -412,6 +419,15 @@ CountryNames* CountryNames::GetInstance() {
|
| return Singleton<CountryNames>::get();
|
| }
|
|
|
| +const std::string CountryNames::ApplicationLocale() {
|
| + if (application_locale_.empty()) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + application_locale_ = g_browser_process->GetApplicationLocale();
|
| + }
|
| +
|
| + return application_locale_;
|
| +}
|
| +
|
| CountryNames::CountryNames() {
|
| // Add 2- and 3-letter ISO country codes.
|
| for (CountryDataMap::Iterator it = CountryDataMap::Begin();
|
| @@ -628,7 +644,7 @@ const std::string AutofillCountry::GetCountryCode(const string16& country,
|
|
|
| // static
|
| const std::string AutofillCountry::ApplicationLocale() {
|
| - return g_browser_process->GetApplicationLocale();
|
| + return CountryNames::GetInstance()->ApplicationLocale();
|
| }
|
|
|
| AutofillCountry::AutofillCountry(const std::string& country_code,
|
|
|