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

Side by Side Diff: components/autofill/browser/wallet/wallet_items.cc

Issue 12893007: Implementing VERIFY_CVV required action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
« no previous file with comments | « components/autofill/browser/wallet/wallet_items.h ('k') | no next file » | 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 "components/autofill/browser/wallet/wallet_items.h" 5 #include "components/autofill/browser/wallet/wallet_items.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "components/autofill/browser/autofill_type.h" 11 #include "components/autofill/browser/autofill_type.h"
12 #include "components/autofill/browser/credit_card.h"
11 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
12 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
13 #include "grit/webkit_resources.h" 15 #include "grit/webkit_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
17 19
18 namespace autofill { 20 namespace autofill {
19 namespace wallet { 21 namespace wallet {
20 22
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return !(*this == other); 222 return !(*this == other);
221 } 223 }
222 224
223 bool WalletItems::HasRequiredAction(RequiredAction action) const { 225 bool WalletItems::HasRequiredAction(RequiredAction action) const {
224 DCHECK(ActionAppliesToWalletItems(action)); 226 DCHECK(ActionAppliesToWalletItems(action));
225 return std::find(required_actions_.begin(), 227 return std::find(required_actions_.begin(),
226 required_actions_.end(), 228 required_actions_.end(),
227 action) != required_actions_.end(); 229 action) != required_actions_.end();
228 } 230 }
229 231
232 const WalletItems::MaskedInstrument* WalletItems::GetInstrumentById(
233 const std::string& object_id) const {
234 if (object_id.empty())
235 return NULL;
236
237 for (size_t i = 0; i < instruments_.size(); ++i) {
238 if (instruments_[i]->object_id() == object_id)
239 return instruments_[i];
240 }
241
242 return NULL;
243 }
244
230 string16 WalletItems::MaskedInstrument::DisplayName() const { 245 string16 WalletItems::MaskedInstrument::DisplayName() const {
231 #if defined(OS_ANDROID) 246 #if defined(OS_ANDROID)
232 // TODO(aruslan): improve this stub implementation. 247 // TODO(aruslan): improve this stub implementation.
233 return descriptive_name(); 248 return descriptive_name();
234 #else 249 #else
235 return descriptive_name(); 250 return descriptive_name();
236 #endif 251 #endif
237 } 252 }
238 253
239 string16 WalletItems::MaskedInstrument::DisplayNameDetail() const { 254 string16 WalletItems::MaskedInstrument::DisplayNameDetail() const {
240 #if defined(OS_ANDROID) 255 #if defined(OS_ANDROID)
241 // TODO(aruslan): improve this stub implementation. 256 // TODO(aruslan): improve this stub implementation.
242 return address().DisplayName(); 257 return address().DisplayName();
243 #else 258 #else
244 return string16(); 259 return string16();
245 #endif 260 #endif
246 } 261 }
247 262
263 string16 WalletItems::MaskedInstrument::TypeAndLastFourDigits() const {
264 string16 display_type;
265
266 if (type_ == AMEX)
267 display_type = CreditCard::TypeForDisplay(kAmericanExpressCard);
268 else if (type_ == DISCOVER)
269 display_type = CreditCard::TypeForDisplay(kDiscoverCard);
270 else if (type_ == MASTER_CARD)
271 display_type = CreditCard::TypeForDisplay(kMasterCard);
272 else if (type_ == SOLO)
273 display_type = CreditCard::TypeForDisplay(kSoloCard);
274 else if (type_ == VISA)
275 display_type = CreditCard::TypeForDisplay(kVisaCard);
276 else
277 display_type = CreditCard::TypeForDisplay(kGenericCard);
278
279 // TODO(dbeam): i18n.
280 return display_type + ASCIIToUTF16(" - ") + last_four_digits();
281 }
282
248 const gfx::Image& WalletItems::MaskedInstrument::CardIcon() const { 283 const gfx::Image& WalletItems::MaskedInstrument::CardIcon() const {
249 int idr = 0; 284 int idr = 0;
250 switch (type_) { 285 switch (type_) {
251 case AMEX: 286 case AMEX:
252 idr = IDR_AUTOFILL_CC_AMEX; 287 idr = IDR_AUTOFILL_CC_AMEX;
253 break; 288 break;
254 289
255 case DISCOVER: 290 case DISCOVER:
256 idr = IDR_AUTOFILL_CC_DISCOVER; 291 idr = IDR_AUTOFILL_CC_DISCOVER;
257 break; 292 break;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 VectorsAreEqual<LegalDocument>(legal_documents(), 520 VectorsAreEqual<LegalDocument>(legal_documents(),
486 other.legal_documents()); 521 other.legal_documents());
487 } 522 }
488 523
489 bool WalletItems::operator!=(const WalletItems& other) const { 524 bool WalletItems::operator!=(const WalletItems& other) const {
490 return !(*this == other); 525 return !(*this == other);
491 } 526 }
492 527
493 } // namespace wallet 528 } // namespace wallet
494 } // namespace autofill 529 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/browser/wallet/wallet_items.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698