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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 116 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
117 for (size_t j = 0; j < inputs->size(); ++j) { | 117 for (size_t j = 0; j < inputs->size(); ++j) { |
118 std::vector<string16> values; | 118 std::vector<string16> values; |
119 profile_->GetMultiInfo( | 119 profile_->GetMultiInfo( |
120 AutofillType((*inputs)[j].type), app_locale, &values); | 120 AutofillType((*inputs)[j].type), app_locale, &values); |
121 (*inputs)[j].initial_value = values[variant()]; | 121 (*inputs)[j].initial_value = values[variant()]; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 void AutofillProfileWrapper::FillFormField(AutofillField* field) const { | 125 void AutofillProfileWrapper::FillFormField(AutofillField* field) const { |
126 AutofillType field_type = field->Type(); | 126 HtmlFieldType html_type = field->html_type(); |
Evan Stade
2013/08/05 18:47:24
nit: declare as late as possible, not at top of fu
Ilya Sherman
2013/08/06 05:05:39
Hmm, I'm not sure where you'd prefer to see this d
Evan Stade
2013/08/06 18:39:59
I see, I missed that. Can you give the variable a
Ilya Sherman
2013/08/06 23:04:56
Done.
| |
127 HtmlFieldMode html_mode = field->html_mode(); | |
127 | 128 |
128 if (field_type.native_type() == CREDIT_CARD_NAME) { | 129 if (field->Type().GetEquivalentNativeType() == CREDIT_CARD_NAME) { |
129 // Requests for the user's credit card are filled from the billing address, | 130 // Requests for the user's credit card are filled from the billing address, |
130 // but the AutofillProfile class doesn't know how to fill credit card | 131 // but the AutofillProfile class doesn't know how to fill credit card |
131 // fields. So, temporarily set the type to the corresponding profile type. | 132 // fields. So, temporarily set the type to the corresponding profile type. |
132 field->set_heuristic_type(NAME_FULL); | 133 field->SetHtmlType(HTML_TYPE_NAME, html_mode); |
133 } | 134 } |
134 | 135 |
135 AutofillDataModelWrapper::FillFormField(field); | 136 AutofillDataModelWrapper::FillFormField(field); |
136 | 137 |
137 field->set_heuristic_type(field_type.native_type()); | 138 field->SetHtmlType(html_type, html_mode); |
138 } | 139 } |
139 | 140 |
140 // AutofillCreditCardWrapper | 141 // AutofillCreditCardWrapper |
141 | 142 |
142 AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card) | 143 AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card) |
143 : AutofillDataModelWrapper(card, 0), | 144 : AutofillDataModelWrapper(card, 0), |
144 card_(card) {} | 145 card_(card) {} |
145 | 146 |
146 AutofillCreditCardWrapper::~AutofillCreditCardWrapper() {} | 147 AutofillCreditCardWrapper::~AutofillCreditCardWrapper() {} |
147 | 148 |
148 string16 AutofillCreditCardWrapper::GetInfo(const AutofillType& type) const { | 149 string16 AutofillCreditCardWrapper::GetInfo(const AutofillType& type) const { |
149 if (type.native_type() == CREDIT_CARD_EXP_MONTH) | 150 if (type.GetEquivalentNativeType() == CREDIT_CARD_EXP_MONTH) |
150 return MonthComboboxModel::FormatMonth(card_->expiration_month()); | 151 return MonthComboboxModel::FormatMonth(card_->expiration_month()); |
151 | 152 |
152 return AutofillDataModelWrapper::GetInfo(type); | 153 return AutofillDataModelWrapper::GetInfo(type); |
153 } | 154 } |
154 | 155 |
155 gfx::Image AutofillCreditCardWrapper::GetIcon() { | 156 gfx::Image AutofillCreditCardWrapper::GetIcon() { |
156 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 157 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
157 return rb.GetImageNamed(CreditCard::IconResourceId(card_->type())); | 158 return rb.GetImageNamed(CreditCard::IconResourceId(card_->type())); |
158 } | 159 } |
159 | 160 |
(...skipping 26 matching lines...) Expand all Loading... | |
186 | 187 |
187 // WalletInstrumentWrapper | 188 // WalletInstrumentWrapper |
188 | 189 |
189 WalletInstrumentWrapper::WalletInstrumentWrapper( | 190 WalletInstrumentWrapper::WalletInstrumentWrapper( |
190 const wallet::WalletItems::MaskedInstrument* instrument) | 191 const wallet::WalletItems::MaskedInstrument* instrument) |
191 : instrument_(instrument) {} | 192 : instrument_(instrument) {} |
192 | 193 |
193 WalletInstrumentWrapper::~WalletInstrumentWrapper() {} | 194 WalletInstrumentWrapper::~WalletInstrumentWrapper() {} |
194 | 195 |
195 string16 WalletInstrumentWrapper::GetInfo(const AutofillType& type) const { | 196 string16 WalletInstrumentWrapper::GetInfo(const AutofillType& type) const { |
196 if (type.native_type() == CREDIT_CARD_EXP_MONTH) | 197 if (type.GetEquivalentNativeType() == CREDIT_CARD_EXP_MONTH) |
197 return MonthComboboxModel::FormatMonth(instrument_->expiration_month()); | 198 return MonthComboboxModel::FormatMonth(instrument_->expiration_month()); |
198 | 199 |
199 return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale()); | 200 return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale()); |
200 } | 201 } |
201 | 202 |
202 gfx::Image WalletInstrumentWrapper::GetIcon() { | 203 gfx::Image WalletInstrumentWrapper::GetIcon() { |
203 return instrument_->CardIcon(); | 204 return instrument_->CardIcon(); |
204 } | 205 } |
205 | 206 |
206 string16 WalletInstrumentWrapper::GetDisplayText() { | 207 string16 WalletInstrumentWrapper::GetDisplayText() { |
(...skipping 14 matching lines...) Expand all Loading... | |
221 | 222 |
222 FullWalletBillingWrapper::FullWalletBillingWrapper( | 223 FullWalletBillingWrapper::FullWalletBillingWrapper( |
223 wallet::FullWallet* full_wallet) | 224 wallet::FullWallet* full_wallet) |
224 : full_wallet_(full_wallet) { | 225 : full_wallet_(full_wallet) { |
225 DCHECK(full_wallet_); | 226 DCHECK(full_wallet_); |
226 } | 227 } |
227 | 228 |
228 FullWalletBillingWrapper::~FullWalletBillingWrapper() {} | 229 FullWalletBillingWrapper::~FullWalletBillingWrapper() {} |
229 | 230 |
230 string16 FullWalletBillingWrapper::GetInfo(const AutofillType& type) const { | 231 string16 FullWalletBillingWrapper::GetInfo(const AutofillType& type) const { |
231 if (type.native_type() == CREDIT_CARD_EXP_MONTH) | 232 if (type.GetEquivalentNativeType() == CREDIT_CARD_EXP_MONTH) |
232 return MonthComboboxModel::FormatMonth(full_wallet_->expiration_month()); | 233 return MonthComboboxModel::FormatMonth(full_wallet_->expiration_month()); |
233 | 234 |
234 if (type.group() == CREDIT_CARD) | 235 if (type.group() == CREDIT_CARD) |
235 return full_wallet_->GetInfo(type); | 236 return full_wallet_->GetInfo(type); |
236 | 237 |
237 return full_wallet_->billing_address()->GetInfo( | 238 return full_wallet_->billing_address()->GetInfo( |
238 type, g_browser_process->GetApplicationLocale()); | 239 type, g_browser_process->GetApplicationLocale()); |
239 } | 240 } |
240 | 241 |
241 string16 FullWalletBillingWrapper::GetDisplayText() { | 242 string16 FullWalletBillingWrapper::GetDisplayText() { |
(...skipping 18 matching lines...) Expand all Loading... | |
260 return full_wallet_->shipping_address()->GetInfo( | 261 return full_wallet_->shipping_address()->GetInfo( |
261 type, g_browser_process->GetApplicationLocale()); | 262 type, g_browser_process->GetApplicationLocale()); |
262 } | 263 } |
263 | 264 |
264 DetailOutputWrapper::DetailOutputWrapper(const DetailOutputMap& outputs) | 265 DetailOutputWrapper::DetailOutputWrapper(const DetailOutputMap& outputs) |
265 : outputs_(outputs) {} | 266 : outputs_(outputs) {} |
266 | 267 |
267 DetailOutputWrapper::~DetailOutputWrapper() {} | 268 DetailOutputWrapper::~DetailOutputWrapper() {} |
268 | 269 |
269 base::string16 DetailOutputWrapper::GetInfo(const AutofillType& type) const { | 270 base::string16 DetailOutputWrapper::GetInfo(const AutofillType& type) const { |
271 NativeFieldType native_type = type.GetEquivalentNativeType(); | |
270 for (DetailOutputMap::const_iterator it = outputs_.begin(); | 272 for (DetailOutputMap::const_iterator it = outputs_.begin(); |
271 it != outputs_.end(); ++it) { | 273 it != outputs_.end(); ++it) { |
272 if (type.native_type() == it->first->type) | 274 if (native_type == AutofillType(it->first->type).GetEquivalentNativeType()) |
273 return it->second; | 275 return it->second; |
274 } | 276 } |
275 return base::string16(); | 277 return base::string16(); |
276 } | 278 } |
277 | 279 |
278 } // namespace autofill | 280 } // namespace autofill |
OLD | NEW |