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

Side by Side Diff: chrome/browser/ui/autofill/data_model_wrapper.cc

Issue 13488009: Remove application locale cache in autofill code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 const std::string app_locale = g_browser_process->GetApplicationLocale();
98 for (size_t j = 0; j < inputs->size(); ++j) { 99 for (size_t j = 0; j < inputs->size(); ++j) {
99 std::vector<string16> values; 100 std::vector<string16> values;
100 profile_->GetMultiInfo((*inputs)[j].type, app_locale, &values); 101 profile_->GetMultiInfo((*inputs)[j].type, app_locale, &values);
101 (*inputs)[j].initial_value = values[variant()]; 102 (*inputs)[j].initial_value = values[variant()];
102 } 103 }
103 } 104 }
104 105
105 // AutofillCreditCardWrapper 106 // AutofillCreditCardWrapper
106 107
107 AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card) 108 AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 143 }
143 144
144 // WalletAddressWrapper 145 // WalletAddressWrapper
145 146
146 WalletAddressWrapper::WalletAddressWrapper( 147 WalletAddressWrapper::WalletAddressWrapper(
147 const wallet::Address* address) : address_(address) {} 148 const wallet::Address* address) : address_(address) {}
148 149
149 WalletAddressWrapper::~WalletAddressWrapper() {} 150 WalletAddressWrapper::~WalletAddressWrapper() {}
150 151
151 string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) { 152 string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) {
152 return address_->GetInfo(type); 153 return address_->GetInfo(type, g_browser_process->GetApplicationLocale());
153 } 154 }
154 155
155 // WalletInstrumentWrapper 156 // WalletInstrumentWrapper
156 157
157 WalletInstrumentWrapper::WalletInstrumentWrapper( 158 WalletInstrumentWrapper::WalletInstrumentWrapper(
158 const wallet::WalletItems::MaskedInstrument* instrument) 159 const wallet::WalletItems::MaskedInstrument* instrument)
159 : instrument_(instrument) {} 160 : instrument_(instrument) {}
160 161
161 WalletInstrumentWrapper::~WalletInstrumentWrapper() {} 162 WalletInstrumentWrapper::~WalletInstrumentWrapper() {}
162 163
163 string16 WalletInstrumentWrapper::GetInfo(AutofillFieldType type) { 164 string16 WalletInstrumentWrapper::GetInfo(AutofillFieldType type) {
164 if (type == CREDIT_CARD_EXP_MONTH) 165 if (type == CREDIT_CARD_EXP_MONTH)
165 return MonthComboboxModel::FormatMonth(instrument_->expiration_month()); 166 return MonthComboboxModel::FormatMonth(instrument_->expiration_month());
166 167
167 return instrument_->GetInfo(type); 168 return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale());
168 } 169 }
169 170
170 gfx::Image WalletInstrumentWrapper::GetIcon() { 171 gfx::Image WalletInstrumentWrapper::GetIcon() {
171 return instrument_->CardIcon(); 172 return instrument_->CardIcon();
172 } 173 }
173 174
174 string16 WalletInstrumentWrapper::GetDisplayText() { 175 string16 WalletInstrumentWrapper::GetDisplayText() {
175 // TODO(estade): descriptive_name() is user-provided. Should we use it or 176 // TODO(estade): descriptive_name() is user-provided. Should we use it or
176 // just type + last 4 digits? 177 // just type + last 4 digits?
177 string16 line1 = instrument_->descriptive_name(); 178 string16 line1 = instrument_->descriptive_name();
178 return line1 + ASCIIToUTF16("\n") + DataModelWrapper::GetDisplayText(); 179 return line1 + ASCIIToUTF16("\n") + DataModelWrapper::GetDisplayText();
179 } 180 }
180 181
181 // FullWalletBillingWrapper 182 // FullWalletBillingWrapper
182 183
183 FullWalletBillingWrapper::FullWalletBillingWrapper( 184 FullWalletBillingWrapper::FullWalletBillingWrapper(
184 wallet::FullWallet* full_wallet) 185 wallet::FullWallet* full_wallet)
185 : full_wallet_(full_wallet) { 186 : full_wallet_(full_wallet) {
186 DCHECK(full_wallet_); 187 DCHECK(full_wallet_);
187 } 188 }
188 189
189 FullWalletBillingWrapper::~FullWalletBillingWrapper() {} 190 FullWalletBillingWrapper::~FullWalletBillingWrapper() {}
190 191
191 string16 FullWalletBillingWrapper::GetInfo(AutofillFieldType type) { 192 string16 FullWalletBillingWrapper::GetInfo(AutofillFieldType type) {
192 if (AutofillType(type).group() == AutofillType::CREDIT_CARD) 193 if (AutofillType(type).group() == AutofillType::CREDIT_CARD)
193 return full_wallet_->GetInfo(type); 194 return full_wallet_->GetInfo(type);
194 195
195 return full_wallet_->billing_address()->GetInfo(type); 196 return full_wallet_->billing_address()->GetInfo(
197 type, g_browser_process->GetApplicationLocale());
196 } 198 }
197 199
198 // FullWalletShippingWrapper 200 // FullWalletShippingWrapper
199 201
200 FullWalletShippingWrapper::FullWalletShippingWrapper( 202 FullWalletShippingWrapper::FullWalletShippingWrapper(
201 wallet::FullWallet* full_wallet) 203 wallet::FullWallet* full_wallet)
202 : full_wallet_(full_wallet) { 204 : full_wallet_(full_wallet) {
203 DCHECK(full_wallet_); 205 DCHECK(full_wallet_);
204 } 206 }
205 207
206 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} 208 FullWalletShippingWrapper::~FullWalletShippingWrapper() {}
207 209
208 string16 FullWalletShippingWrapper::GetInfo(AutofillFieldType type) { 210 string16 FullWalletShippingWrapper::GetInfo(AutofillFieldType type) {
209 return full_wallet_->shipping_address()->GetInfo(type); 211 return full_wallet_->shipping_address()->GetInfo(
212 type, g_browser_process->GetApplicationLocale());
210 } 213 }
211 214
212 } // namespace autofill 215 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/country_combobox_model.cc ('k') | chrome/browser/ui/browser_tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698