void DataModelWrapper::FillInputs(DetailInputs* inputs) {
for (size_t i = 0; i < inputs->size(); ++i) {
- (*inputs)[i].initial_value = GetInfo(AutofillType((*inputs)[i].type));
+ (*inputs)[i].initial_value =
+ GetInfoForDisplay(AutofillType((*inputs)[i].type));
}
}
i18ninput::CreateAddressData(
base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this)),
&address_data);
+ address_data.language_code = GetLanguageCode();
std::vector<std::string> lines;
address_data.FormatForDisplay(&lines);
// The separator is locale-specific.
std::string compact_separator =
- ::i18n::addressinput::GetCompactAddressLinesSeparator(
- g_browser_process->GetApplicationLocale());
+ ::i18n::addressinput::GetCompactAddressLinesSeparator(GetLanguageCode());
*vertically_compact =
base::UTF8ToUTF16(JoinString(lines, compact_separator)) +
non_address_info;
std::string region = base::UTF16ToASCII(
GetInfo(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE)));
i18n::PhoneObject phone(phone_number, region);
- return phone.GetFormattedNumber();
+ base::string16 formatted_number = phone.GetFormattedNumber();
+ // Formatting may fail.
+ if (!formatted_number.empty())
+ return formatted_number;
}
return phone_number;
return DataModelWrapper::GetInfoForDisplay(type);
}
+const std::string& AutofillProfileWrapper::GetLanguageCode() const {
+ return profile_->language_code();
+}
+
size_t AutofillProfileWrapper::GetVariantForType(const AutofillType& type)
const {
if (type.group() == variant_group_)
return true;
}
+const std::string& AutofillCreditCardWrapper::GetLanguageCode() const {
+ // Formatting a credit card for display does not depend on language code.
+ return base::EmptyString();
+}
+
// WalletAddressWrapper
WalletAddressWrapper::WalletAddressWrapper(
horizontally_compact);
}
+const std::string& WalletAddressWrapper::GetLanguageCode() const {
+ return address_->language_code();
+}
+
// WalletInstrumentWrapper
WalletInstrumentWrapper::WalletInstrumentWrapper(
return true;
}
+const std::string& WalletInstrumentWrapper::GetLanguageCode() const {
+ return instrument_->address().language_code();
+}
+
// FullWalletBillingWrapper
FullWalletBillingWrapper::FullWalletBillingWrapper(
horizontally_compact);
}
+const std::string& FullWalletBillingWrapper::GetLanguageCode() const {
+ // Can be NULL if there are required actions.
+ return full_wallet_->billing_address() ?
+ full_wallet_->billing_address()->language_code() : base::EmptyString();
+}
+
// FullWalletShippingWrapper
FullWalletShippingWrapper::FullWalletShippingWrapper(
type, g_browser_process->GetApplicationLocale());
}
+const std::string& FullWalletShippingWrapper::GetLanguageCode() const {
+ // Can be NULL if there are required actions or shipping address is not
+ // required.
+ return full_wallet_->shipping_address() ?
+ full_wallet_->shipping_address()->language_code() : base::EmptyString();
+}
+
+// I18nAddressDataWrapper
+
I18nAddressDataWrapper::I18nAddressDataWrapper(
const ::i18n::addressinput::AddressData* address)
: address_(address) {}
return base::UTF8ToUTF16(address_->GetFieldValue(field));
}
+const std::string& I18nAddressDataWrapper::GetLanguageCode() const {
+ return address_->language_code;
+}
+
} // namespace autofill