Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: chrome/browser/autofill/phone_number_i18n.cc

Issue 8355025: Fix an Autofill crash caused by accessing the g_browser_process on the DB thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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())) {

Powered by Google App Engine
This is Rietveld 408576698