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

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

Issue 17099006: Validate saved credit card number in interactive autocomplete (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix test name Created 7 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/data_model_wrapper_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 return AutofillDataModelWrapper::GetInfo(type); 134 return AutofillDataModelWrapper::GetInfo(type);
135 } 135 }
136 136
137 gfx::Image AutofillCreditCardWrapper::GetIcon() { 137 gfx::Image AutofillCreditCardWrapper::GetIcon() {
138 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 138 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
139 return rb.GetImageNamed(card_->IconResourceId()); 139 return rb.GetImageNamed(card_->IconResourceId());
140 } 140 }
141 141
142 string16 AutofillCreditCardWrapper::GetDisplayText() { 142 string16 AutofillCreditCardWrapper::GetDisplayText() {
143 if (!autofill::IsValidCreditCardExpirationDate( 143 if (!autofill::IsValidCreditCardExpirationDate(
Evan Stade 2013/06/14 22:29:49 I feel like this should be a function on card_
please use gerrit instead 2013/06/17 18:35:42 Done.
144 card_->GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR), 144 card_->GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR),
145 card_->GetRawInfo(CREDIT_CARD_EXP_MONTH), 145 card_->GetRawInfo(CREDIT_CARD_EXP_MONTH),
146 base::Time::Now())) { 146 base::Time::Now()) ||
147 !autofill::IsValidCreditCardNumber(
148 card_->GetRawInfo(CREDIT_CARD_NUMBER))) {
147 return string16(); 149 return string16();
148 } 150 }
149 151
150 return card_->TypeAndLastFourDigits(); 152 return card_->TypeAndLastFourDigits();
151 } 153 }
152 154
153 void AutofillCreditCardWrapper::FillFormField(AutofillField* field) const { 155 void AutofillCreditCardWrapper::FillFormField(AutofillField* field) const {
154 AutofillFieldType field_type = field->type(); 156 AutofillFieldType field_type = field->type();
155 157
156 if (field_type == NAME_FULL) { 158 if (field_type == NAME_FULL) {
(...skipping 13 matching lines...) Expand all
170 WalletAddressWrapper::WalletAddressWrapper( 172 WalletAddressWrapper::WalletAddressWrapper(
171 const wallet::Address* address) : address_(address) {} 173 const wallet::Address* address) : address_(address) {}
172 174
173 WalletAddressWrapper::~WalletAddressWrapper() {} 175 WalletAddressWrapper::~WalletAddressWrapper() {}
174 176
175 string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) const { 177 string16 WalletAddressWrapper::GetInfo(AutofillFieldType type) const {
176 return address_->GetInfo(type, g_browser_process->GetApplicationLocale()); 178 return address_->GetInfo(type, g_browser_process->GetApplicationLocale());
177 } 179 }
178 180
179 string16 WalletAddressWrapper::GetDisplayText() { 181 string16 WalletAddressWrapper::GetDisplayText() {
180 if (!address_->is_complete_address() || 182 if (!address_->is_complete_address() ||
Evan Stade 2013/06/14 22:29:49 like this, sort of. (you also need to do validatio
please use gerrit instead 2013/06/17 18:35:42 I'm working on that in a separate CL. (Small CLs a
181 GetInfo(PHONE_HOME_WHOLE_NUMBER).empty()) { 183 GetInfo(PHONE_HOME_WHOLE_NUMBER).empty()) {
182 return string16(); 184 return string16();
183 } 185 }
184 186
185 return DataModelWrapper::GetDisplayText(); 187 return DataModelWrapper::GetDisplayText();
186 } 188 }
187 189
188 // WalletInstrumentWrapper 190 // WalletInstrumentWrapper
189 191
190 WalletInstrumentWrapper::WalletInstrumentWrapper( 192 WalletInstrumentWrapper::WalletInstrumentWrapper(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 255 }
254 256
255 FullWalletShippingWrapper::~FullWalletShippingWrapper() {} 257 FullWalletShippingWrapper::~FullWalletShippingWrapper() {}
256 258
257 string16 FullWalletShippingWrapper::GetInfo(AutofillFieldType type) const { 259 string16 FullWalletShippingWrapper::GetInfo(AutofillFieldType type) const {
258 return full_wallet_->shipping_address()->GetInfo( 260 return full_wallet_->shipping_address()->GetInfo(
259 type, g_browser_process->GetApplicationLocale()); 261 type, g_browser_process->GetApplicationLocale());
260 } 262 }
261 263
262 } // namespace autofill 264 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/data_model_wrapper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698