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

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

Issue 13488009: Remove application locale cache in autofill code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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: components/autofill/browser/phone_number_i18n.cc
===================================================================
--- components/autofill/browser/phone_number_i18n.cc (revision 192175)
+++ components/autofill/browser/phone_number_i18n.cc (working copy)
@@ -18,12 +18,12 @@
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,15 @@
}
string16 NormalizePhoneNumber(const string16& value,
- std::string const& region) {
+ std::string const& region,
Ilya Sherman 2013/04/04 04:27:38 Optional nit: As long as you're here, could you fi
jam 2013/04/04 17:58:12 Done.
+ const std::string& app_locale) {
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, SanitizeRegion(region, app_locale),
Ilya Sherman 2013/04/04 04:36:14 Looking through the call sites, it looks like this
jam 2013/04/04 17:58:12 Done.
+ &country_code, &unused_city_code, &unused_number,
+ &phone_number)) {
return string16(); // Parsing failed - do not store phone.
}
@@ -168,6 +170,7 @@
const string16& city_code,
const string16& number,
const std::string& region,
+ const std::string& app_locale,
string16* whole_number) {
whole_number->clear();
@@ -176,7 +179,7 @@
string16 unused_number;
PhoneNumber phone_number;
if (!ParsePhoneNumber(country_code + city_code + number,
- SanitizeRegion(region),
+ SanitizeRegion(region, app_locale),
Ilya Sherman 2013/04/04 04:36:14 Likewise, this one can be replaced by a DCHECK.
jam 2013/04/04 17:58:12 Done.
&unused_country_code, &unused_city_code, &unused_number,
&phone_number)) {
return false;
@@ -188,9 +191,10 @@
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);
Ilya Sherman 2013/04/04 04:36:14 This one is still needed, though, due to callsites
PhoneNumberUtil* phone_util = PhoneNumberUtil::GetInstance();
@@ -222,8 +226,10 @@
return false;
}
-PhoneObject::PhoneObject(const string16& number, const std::string& region)
- : region_(SanitizeRegion(region)),
+PhoneObject::PhoneObject(const string16& number,
+ const std::string& region,
+ const std::string& app_locale)
+ : region_(SanitizeRegion(region, app_locale)),
Ilya Sherman 2013/04/04 04:36:14 Likewise, this one can be replaced by a DCHECK.
jam 2013/04/04 17:58:12 Done.
i18n_number_(NULL) {
// TODO(isherman): Autofill profiles should always have a |region| set, but in
// some cases it should be marked as implicit. Otherwise, phone numbers

Powered by Google App Engine
This is Rietveld 408576698