Chromium Code Reviews| Index: chrome/browser/autofill/phone_number_i18n.cc |
| diff --git a/chrome/browser/autofill/phone_number_i18n.cc b/chrome/browser/autofill/phone_number_i18n.cc |
| index a1c1636cd13a010dc9779fb3076b5f977c206e7f..ed038173490377c0998496e85dbc73b2bc005914 100644 |
| --- a/chrome/browser/autofill/phone_number_i18n.cc |
| +++ b/chrome/browser/autofill/phone_number_i18n.cc |
| @@ -10,7 +10,9 @@ |
| #include "base/string_number_conversions.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/autofill/autofill_country.h" |
| +#include "content/browser/browser_thread.h" |
| #include "third_party/libphonenumber/cpp/src/phonenumberutil.h" |
| +#include "unicode/locid.h" |
| using i18n::phonenumbers::PhoneNumber; |
| using i18n::phonenumbers::PhoneNumberUtil; |
| @@ -230,7 +232,7 @@ bool PhoneNumbersMatch(const string16& number_a, |
| PhoneNumber i18n_number2; |
| if (phone_util->Parse(UTF16ToUTF8(number_b), locale.c_str(), &i18n_number2) != |
| - i18n::phonenumbers::PhoneNumberUtil::NO_PARSING_ERROR) { |
| + i18n::phonenumbers::PhoneNumberUtil::NO_PARSING_ERROR) { |
|
dhollowa
2011/10/20 15:34:27
nit: indent seems off here. The 'i' should line u
|
| return false; |
| } |
| @@ -251,8 +253,26 @@ bool PhoneNumbersMatch(const string16& number_a, |
| } |
| PhoneObject::PhoneObject(const string16& number, const std::string& locale) |
| - : locale_(SanitizeLocaleCode(locale)), |
| + : locale_(locale), |
| i18n_number_(NULL) { |
| + if (locale_.empty()) { |
| + // TODO(isherman): Autofill profiles should always have a locale set, but in |
| + // some cases it should be marked as implicit. Otherwise, phone numbers |
| + // might behave differently when they are synced across computers: |
| + // http://crbug.com/100845 |
| + |
| + // For now, to avoid a data race on shutdown, make sure that we always |
| + // provide a non-empty locale: http://crbug.com/100745 |
| + if (BrowserThread::CurrentlyOn(BrowserThread::UI)) |
| + locale_ = AutofillCountry::ApplicationLocale(); |
| + else |
| + locale_ = icu::Locale::getDefault().getCountry(); |
| + |
| + if (locale_.empty()) |
| + locale_ = "US"; |
| + } |
| + locale_ = SanitizeLocaleCode(locale_); |
| + |
| scoped_ptr<PhoneNumber> i18n_number(new PhoneNumber); |
| if (ParsePhoneNumberInternal(number, locale_, &country_code_, &city_code_, |
| &number_, i18n_number.get())) { |