Commit 734de4c0 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

[jumbo] Make PhoneNumber unambigious

There is a ::i18n::phonenumbers::PhoneNumber and a
::autofill::PhoneNumber. To avoid ambiguity (especially in jumbo
builds where more types are known to more code), refer to
::i18n::phonenumbers::PhoneNumber with the full name inside
autofill code.

Also refer to PhoneNumberUtils from the same namespace the same
way for consistency.

Change-Id: Ic36cae9a8df0ceb07f3494fa34d8b08531cd46e4
Reviewed-on: https://chromium-review.googlesource.com/1050288
Commit-Queue: Daniel Bratell <bratell@opera.com>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557164}
parent 42763731
...@@ -16,19 +16,18 @@ using ::base::android::ConvertJavaStringToUTF8; ...@@ -16,19 +16,18 @@ using ::base::android::ConvertJavaStringToUTF8;
using ::base::android::ConvertUTF8ToJavaString; using ::base::android::ConvertUTF8ToJavaString;
using ::base::android::JavaParamRef; using ::base::android::JavaParamRef;
using ::base::android::ScopedJavaLocalRef; using ::base::android::ScopedJavaLocalRef;
using ::i18n::phonenumbers::PhoneNumber;
using ::i18n::phonenumbers::PhoneNumberUtil;
// Formats the |phone_number| to the specified |format| for the given country // Formats the |phone_number| to the specified |format| for the given country
// |country_code|. Returns the original number if the operation is not possible. // |country_code|. Returns the original number if the operation is not possible.
std::string FormatPhoneNumberWithCountryCode( std::string FormatPhoneNumberWithCountryCode(
const std::string& phone_number, const std::string& phone_number,
const std::string& country_code, const std::string& country_code,
PhoneNumberUtil::PhoneNumberFormat format) { i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat format) {
PhoneNumber parsed_number; i18n::phonenumbers::PhoneNumber parsed_number;
PhoneNumberUtil* phone_number_util = PhoneNumberUtil::GetInstance(); i18n::phonenumbers::PhoneNumberUtil* phone_number_util =
i18n::phonenumbers::PhoneNumberUtil::GetInstance();
if (phone_number_util->Parse(phone_number, country_code, &parsed_number) != if (phone_number_util->Parse(phone_number, country_code, &parsed_number) !=
PhoneNumberUtil::NO_PARSING_ERROR) { i18n::phonenumbers::PhoneNumberUtil::NO_PARSING_ERROR) {
return phone_number; return phone_number;
} }
...@@ -40,8 +39,9 @@ std::string FormatPhoneNumberWithCountryCode( ...@@ -40,8 +39,9 @@ std::string FormatPhoneNumberWithCountryCode(
// Formats the |phone_number| to the specified |format|. Use application locale // Formats the |phone_number| to the specified |format|. Use application locale
// to determine country code. Returns the original number if the operation is // to determine country code. Returns the original number if the operation is
// not possible. // not possible.
std::string FormatPhoneNumber(const std::string& phone_number, std::string FormatPhoneNumber(
PhoneNumberUtil::PhoneNumberFormat format) { const std::string& phone_number,
i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat format) {
return FormatPhoneNumberWithCountryCode( return FormatPhoneNumberWithCountryCode(
phone_number, phone_number,
autofill::AutofillCountry::CountryCodeForLocale( autofill::AutofillCountry::CountryCodeForLocale(
...@@ -61,14 +61,15 @@ ScopedJavaLocalRef<jstring> JNI_PhoneNumberUtil_FormatForDisplay( ...@@ -61,14 +61,15 @@ ScopedJavaLocalRef<jstring> JNI_PhoneNumberUtil_FormatForDisplay(
const JavaParamRef<jstring>& jphone_number, const JavaParamRef<jstring>& jphone_number,
const JavaParamRef<jstring>& jcountry_code) { const JavaParamRef<jstring>& jcountry_code) {
return ConvertUTF8ToJavaString( return ConvertUTF8ToJavaString(
env, env, jcountry_code.is_null()
jcountry_code.is_null() ? FormatPhoneNumber(ConvertJavaStringToUTF8(env, jphone_number),
? FormatPhoneNumber(ConvertJavaStringToUTF8(env, jphone_number), i18n::phonenumbers::PhoneNumberUtil::
PhoneNumberUtil::PhoneNumberFormat::INTERNATIONAL) PhoneNumberFormat::INTERNATIONAL)
: FormatPhoneNumberWithCountryCode( : FormatPhoneNumberWithCountryCode(
ConvertJavaStringToUTF8(env, jphone_number), ConvertJavaStringToUTF8(env, jphone_number),
ConvertJavaStringToUTF8(env, jcountry_code), ConvertJavaStringToUTF8(env, jcountry_code),
PhoneNumberUtil::PhoneNumberFormat::INTERNATIONAL)); i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::
INTERNATIONAL));
} }
// Formats the given number |jphone_number| to // Formats the given number |jphone_number| to
...@@ -81,8 +82,9 @@ ScopedJavaLocalRef<jstring> JNI_PhoneNumberUtil_FormatForResponse( ...@@ -81,8 +82,9 @@ ScopedJavaLocalRef<jstring> JNI_PhoneNumberUtil_FormatForResponse(
const base::android::JavaParamRef<jclass>& jcaller, const base::android::JavaParamRef<jclass>& jcaller,
const JavaParamRef<jstring>& jphone_number) { const JavaParamRef<jstring>& jphone_number) {
return ConvertUTF8ToJavaString( return ConvertUTF8ToJavaString(
env, FormatPhoneNumber(ConvertJavaStringToUTF8(env, jphone_number), env, FormatPhoneNumber(
PhoneNumberUtil::PhoneNumberFormat::E164)); ConvertJavaStringToUTF8(env, jphone_number),
i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::E164));
} }
// Checks whether the given number |jphone_number| is a possible number for a // Checks whether the given number |jphone_number| is a possible number for a
...@@ -99,8 +101,8 @@ jboolean JNI_PhoneNumberUtil_IsPossibleNumber( ...@@ -99,8 +101,8 @@ jboolean JNI_PhoneNumberUtil_IsPossibleNumber(
g_browser_process->GetApplicationLocale()) g_browser_process->GetApplicationLocale())
: ConvertJavaStringToUTF8(env, jcountry_code); : ConvertJavaStringToUTF8(env, jcountry_code);
return PhoneNumberUtil::GetInstance()->IsPossibleNumberForString( return i18n::phonenumbers::PhoneNumberUtil::GetInstance()
phone_number, country_code); ->IsPossibleNumberForString(phone_number, country_code);
} }
} // namespace autofill } // namespace autofill
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment