| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 5 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 10 #include "components/autofill/browser/autofill_country.h" | |
| 11 #include "components/autofill/browser/autofill_profile.h" | 11 #include "components/autofill/browser/autofill_profile.h" |
| 12 #include "components/autofill/browser/autofill_type.h" | 12 #include "components/autofill/browser/autofill_type.h" |
| 13 #include "components/autofill/browser/credit_card.h" | 13 #include "components/autofill/browser/credit_card.h" |
| 14 #include "components/autofill/browser/form_group.h" | 14 #include "components/autofill/browser/form_group.h" |
| 15 #include "components/autofill/browser/form_structure.h" | 15 #include "components/autofill/browser/form_structure.h" |
| 16 #include "components/autofill/browser/wallet/full_wallet.h" | 16 #include "components/autofill/browser/wallet/full_wallet.h" |
| 17 #include "components/autofill/browser/wallet/wallet_address.h" | 17 #include "components/autofill/browser/wallet/wallet_address.h" |
| 18 #include "components/autofill/browser/wallet/wallet_items.h" | 18 #include "components/autofill/browser/wallet/wallet_items.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // AutofillFormGroupWrapper | 70 // AutofillFormGroupWrapper |
| 71 | 71 |
| 72 AutofillFormGroupWrapper::AutofillFormGroupWrapper(const FormGroup* form_group, | 72 AutofillFormGroupWrapper::AutofillFormGroupWrapper(const FormGroup* form_group, |
| 73 size_t variant) | 73 size_t variant) |
| 74 : form_group_(form_group), | 74 : form_group_(form_group), |
| 75 variant_(variant) {} | 75 variant_(variant) {} |
| 76 | 76 |
| 77 AutofillFormGroupWrapper::~AutofillFormGroupWrapper() {} | 77 AutofillFormGroupWrapper::~AutofillFormGroupWrapper() {} |
| 78 | 78 |
| 79 string16 AutofillFormGroupWrapper::GetInfo(AutofillFieldType type) { | 79 string16 AutofillFormGroupWrapper::GetInfo(AutofillFieldType type) { |
| 80 return form_group_->GetInfo(type, AutofillCountry::ApplicationLocale()); | 80 return form_group_->GetInfo(type, g_browser_process->GetApplicationLocale()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void AutofillFormGroupWrapper::FillFormField(AutofillField* field) { | 83 void AutofillFormGroupWrapper::FillFormField(AutofillField* field) { |
| 84 form_group_->FillFormField(*field, variant_, field); | 84 form_group_->FillFormField( |
| 85 *field, variant_, g_browser_process->GetApplicationLocale(), field); |
| 85 } | 86 } |
| 86 | 87 |
| 87 // AutofillProfileWrapper | 88 // AutofillProfileWrapper |
| 88 | 89 |
| 89 AutofillProfileWrapper::AutofillProfileWrapper( | 90 AutofillProfileWrapper::AutofillProfileWrapper( |
| 90 const AutofillProfile* profile, size_t variant) | 91 const AutofillProfile* profile, size_t variant) |
| 91 : AutofillFormGroupWrapper(profile, variant), | 92 : AutofillFormGroupWrapper(profile, variant), |
| 92 profile_(profile) {} | 93 profile_(profile) {} |
| 93 | 94 |
| 94 AutofillProfileWrapper::~AutofillProfileWrapper() {} | 95 AutofillProfileWrapper::~AutofillProfileWrapper() {} |
| 95 | 96 |
| 96 void AutofillProfileWrapper::FillInputs(DetailInputs* inputs) { | 97 void AutofillProfileWrapper::FillInputs(DetailInputs* inputs) { |
| 97 const std::string app_locale = AutofillCountry::ApplicationLocale(); | |
| 98 for (size_t j = 0; j < inputs->size(); ++j) { | 98 for (size_t j = 0; j < inputs->size(); ++j) { |
| 99 std::vector<string16> values; | 99 std::vector<string16> values; |
| 100 profile_->GetMultiInfo((*inputs)[j].type, app_locale, &values); | 100 profile_->GetMultiInfo((*inputs)[j].type, |
| 101 g_browser_process->GetApplicationLocale(), |
| 102 &values); |
| 101 (*inputs)[j].initial_value = values[variant()]; | 103 (*inputs)[j].initial_value = values[variant()]; |
| 102 } | 104 } |
| 103 } | 105 } |
| 104 | 106 |
| 105 // AutofillCreditCardWrapper | 107 // AutofillCreditCardWrapper |
| 106 | 108 |
| 107 AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card) | 109 AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card) |
| 108 : AutofillFormGroupWrapper(card, 0), | 110 : AutofillFormGroupWrapper(card, 0), |
| 109 card_(card) {} | 111 card_(card) {} |
| 110 | 112 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 144 } |
| 143 | 145 |
| 144 // WalletAddressWrapper | 146 // WalletAddressWrapper |
| 145 | 147 |
| 146 WalletAddressWrapper::WalletAddressWrapper( | 148 WalletAddressWrapper::WalletAddressWrapper( |
| 147 const wallet::Address* address) : address_(address) {} | 149 const wallet::Address* address) : address_(address) {} |
| 148 | 150 |
| 149 WalletAddressWrapper::~WalletAddressWrapper() {} | 151 WalletAddressWrapper::~WalletAddressWrapper() {} |
| 150 | 152 |
| 151 string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) { | 153 string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) { |
| 152 return address_->GetInfo(type); | 154 return address_->GetInfo(type, g_browser_process->GetApplicationLocale()); |
| 153 } | 155 } |
| 154 | 156 |
| 155 // WalletInstrumentWrapper | 157 // WalletInstrumentWrapper |
| 156 | 158 |
| 157 WalletInstrumentWrapper::WalletInstrumentWrapper( | 159 WalletInstrumentWrapper::WalletInstrumentWrapper( |
| 158 const wallet::WalletItems::MaskedInstrument* instrument) | 160 const wallet::WalletItems::MaskedInstrument* instrument) |
| 159 : instrument_(instrument) {} | 161 : instrument_(instrument) {} |
| 160 | 162 |
| 161 WalletInstrumentWrapper::~WalletInstrumentWrapper() {} | 163 WalletInstrumentWrapper::~WalletInstrumentWrapper() {} |
| 162 | 164 |
| 163 string16 WalletInstrumentWrapper::GetInfo(AutofillFieldType type) { | 165 string16 WalletInstrumentWrapper::GetInfo(AutofillFieldType type) { |
| 164 if (type == CREDIT_CARD_EXP_MONTH) | 166 if (type == CREDIT_CARD_EXP_MONTH) |
| 165 return MonthComboboxModel::FormatMonth(instrument_->expiration_month()); | 167 return MonthComboboxModel::FormatMonth(instrument_->expiration_month()); |
| 166 | 168 |
| 167 return instrument_->GetInfo(type); | 169 return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale()); |
| 168 } | 170 } |
| 169 | 171 |
| 170 gfx::Image WalletInstrumentWrapper::GetIcon() { | 172 gfx::Image WalletInstrumentWrapper::GetIcon() { |
| 171 return instrument_->CardIcon(); | 173 return instrument_->CardIcon(); |
| 172 } | 174 } |
| 173 | 175 |
| 174 string16 WalletInstrumentWrapper::GetDisplayText() { | 176 string16 WalletInstrumentWrapper::GetDisplayText() { |
| 175 // TODO(estade): descriptive_name() is user-provided. Should we use it or | 177 // TODO(estade): descriptive_name() is user-provided. Should we use it or |
| 176 // just type + last 4 digits? | 178 // just type + last 4 digits? |
| 177 string16 line1 = instrument_->descriptive_name(); | 179 string16 line1 = instrument_->descriptive_name(); |
| 178 return line1 + ASCIIToUTF16("\n") + DataModelWrapper::GetDisplayText(); | 180 return line1 + ASCIIToUTF16("\n") + DataModelWrapper::GetDisplayText(); |
| 179 } | 181 } |
| 180 | 182 |
| 181 // FullWalletBillingWrapper | 183 // FullWalletBillingWrapper |
| 182 | 184 |
| 183 FullWalletBillingWrapper::FullWalletBillingWrapper( | 185 FullWalletBillingWrapper::FullWalletBillingWrapper( |
| 184 wallet::FullWallet* full_wallet) | 186 wallet::FullWallet* full_wallet) |
| 185 : full_wallet_(full_wallet) { | 187 : full_wallet_(full_wallet) { |
| 186 DCHECK(full_wallet_); | 188 DCHECK(full_wallet_); |
| 187 } | 189 } |
| 188 | 190 |
| 189 FullWalletBillingWrapper::~FullWalletBillingWrapper() {} | 191 FullWalletBillingWrapper::~FullWalletBillingWrapper() {} |
| 190 | 192 |
| 191 string16 FullWalletBillingWrapper::GetInfo(AutofillFieldType type) { | 193 string16 FullWalletBillingWrapper::GetInfo(AutofillFieldType type) { |
| 192 if (AutofillType(type).group() == AutofillType::CREDIT_CARD) | 194 if (AutofillType(type).group() == AutofillType::CREDIT_CARD) |
| 193 return full_wallet_->GetInfo(type); | 195 return full_wallet_->GetInfo(type); |
| 194 | 196 |
| 195 return full_wallet_->billing_address()->GetInfo(type); | 197 return full_wallet_->billing_address()->GetInfo( |
| 198 type, g_browser_process->GetApplicationLocale()); |
| 196 } | 199 } |
| 197 | 200 |
| 198 // FullWalletShippingWrapper | 201 // FullWalletShippingWrapper |
| 199 | 202 |
| 200 FullWalletShippingWrapper::FullWalletShippingWrapper( | 203 FullWalletShippingWrapper::FullWalletShippingWrapper( |
| 201 wallet::FullWallet* full_wallet) | 204 wallet::FullWallet* full_wallet) |
| 202 : full_wallet_(full_wallet) { | 205 : full_wallet_(full_wallet) { |
| 203 DCHECK(full_wallet_); | 206 DCHECK(full_wallet_); |
| 204 } | 207 } |
| 205 | 208 |
| 206 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} | 209 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} |
| 207 | 210 |
| 208 string16 FullWalletShippingWrapper::GetInfo(AutofillFieldType type) { | 211 string16 FullWalletShippingWrapper::GetInfo(AutofillFieldType type) { |
| 209 return full_wallet_->shipping_address()->GetInfo(type); | 212 return full_wallet_->shipping_address()->GetInfo( |
| 213 type, g_browser_process->GetApplicationLocale()); |
| 210 } | 214 } |
| 211 | 215 |
| 212 } // namespace autofill | 216 } // namespace autofill |
| OLD | NEW |