OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/content/browser/wallet/wallet_items.h" | 5 #include "components/autofill/content/browser/wallet/wallet_items.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return WalletItems::MaskedInstrument::DISABLED_FOR_THIS_MERCHANT; | 73 return WalletItems::MaskedInstrument::DISABLED_FOR_THIS_MERCHANT; |
74 if (status_string == "UNSUPPORTED_COUNTRY") | 74 if (status_string == "UNSUPPORTED_COUNTRY") |
75 return WalletItems::MaskedInstrument::UNSUPPORTED_COUNTRY; | 75 return WalletItems::MaskedInstrument::UNSUPPORTED_COUNTRY; |
76 if (status_string == "EXPIRED") | 76 if (status_string == "EXPIRED") |
77 return WalletItems::MaskedInstrument::EXPIRED; | 77 return WalletItems::MaskedInstrument::EXPIRED; |
78 if (status_string == "BILLING_INCOMPLETE") | 78 if (status_string == "BILLING_INCOMPLETE") |
79 return WalletItems::MaskedInstrument::BILLING_INCOMPLETE; | 79 return WalletItems::MaskedInstrument::BILLING_INCOMPLETE; |
80 return WalletItems::MaskedInstrument::INAPPLICABLE; | 80 return WalletItems::MaskedInstrument::INAPPLICABLE; |
81 } | 81 } |
82 | 82 |
83 std::string StringIdentifierFromType(WalletItems::MaskedInstrument::Type type) { | 83 base::string16 DisplayStringFromType(WalletItems::MaskedInstrument::Type type) { |
84 switch (type) { | 84 switch (type) { |
| 85 case WalletItems::MaskedInstrument::AMEX: |
| 86 return CreditCard::TypeForDisplay(kAmericanExpressCard); |
| 87 case WalletItems::MaskedInstrument::DISCOVER: |
| 88 return CreditCard::TypeForDisplay(kDiscoverCard); |
| 89 case WalletItems::MaskedInstrument::MASTER_CARD: |
| 90 return CreditCard::TypeForDisplay(kMasterCard); |
85 case WalletItems::MaskedInstrument::VISA: | 91 case WalletItems::MaskedInstrument::VISA: |
86 return kVisaCard; | 92 return CreditCard::TypeForDisplay(kVisaCard); |
87 case WalletItems::MaskedInstrument::MASTER_CARD: | |
88 return kMasterCard; | |
89 case WalletItems::MaskedInstrument::AMEX: | |
90 return kAmericanExpressCard; | |
91 case WalletItems::MaskedInstrument::DISCOVER: | |
92 return kDiscoverCard; | |
93 default: | 93 default: |
94 return kGenericCard; | 94 return CreditCard::TypeForDisplay(kGenericCard); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 } // anonymous namespace | 98 } // anonymous namespace |
99 | 99 |
100 WalletItems::MaskedInstrument::MaskedInstrument( | 100 WalletItems::MaskedInstrument::MaskedInstrument( |
101 const base::string16& descriptive_name, | 101 const base::string16& descriptive_name, |
102 const WalletItems::MaskedInstrument::Type& type, | 102 const WalletItems::MaskedInstrument::Type& type, |
103 const std::vector<base::string16>& supported_currencies, | 103 const std::vector<base::string16>& supported_currencies, |
104 const base::string16& last_four_digits, | 104 const base::string16& last_four_digits, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 base::string16 WalletItems::MaskedInstrument::DisplayNameDetail() const { | 269 base::string16 WalletItems::MaskedInstrument::DisplayNameDetail() const { |
270 #if defined(OS_ANDROID) | 270 #if defined(OS_ANDROID) |
271 // TODO(aruslan): improve this stub implementation. | 271 // TODO(aruslan): improve this stub implementation. |
272 return address().DisplayName(); | 272 return address().DisplayName(); |
273 #else | 273 #else |
274 return base::string16(); | 274 return base::string16(); |
275 #endif | 275 #endif |
276 } | 276 } |
277 | 277 |
278 base::string16 WalletItems::MaskedInstrument::TypeAndLastFourDigits() const { | 278 base::string16 WalletItems::MaskedInstrument::TypeAndLastFourDigits() const { |
279 base::string16 display_type; | |
280 | |
281 if (type_ == AMEX) | |
282 display_type = CreditCard::TypeForDisplay(kAmericanExpressCard); | |
283 else if (type_ == DISCOVER) | |
284 display_type = CreditCard::TypeForDisplay(kDiscoverCard); | |
285 else if (type_ == MASTER_CARD) | |
286 display_type = CreditCard::TypeForDisplay(kMasterCard); | |
287 else if (type_ == VISA) | |
288 display_type = CreditCard::TypeForDisplay(kVisaCard); | |
289 else | |
290 display_type = CreditCard::TypeForDisplay(kGenericCard); | |
291 | |
292 // TODO(dbeam): i18n. | 279 // TODO(dbeam): i18n. |
293 return display_type + ASCIIToUTF16(" - ") + last_four_digits(); | 280 return DisplayStringFromType(type_) + ASCIIToUTF16(" - ") + |
| 281 last_four_digits(); |
294 } | 282 } |
295 | 283 |
296 const gfx::Image& WalletItems::MaskedInstrument::CardIcon() const { | 284 const gfx::Image& WalletItems::MaskedInstrument::CardIcon() const { |
297 int idr = 0; | 285 int idr = 0; |
298 switch (type_) { | 286 switch (type_) { |
299 case AMEX: | 287 case AMEX: |
300 idr = IDR_AUTOFILL_CC_AMEX; | 288 idr = IDR_AUTOFILL_CC_AMEX; |
301 break; | 289 break; |
302 | 290 |
303 case DISCOVER: | 291 case DISCOVER: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 case CREDIT_CARD_NUMBER: | 324 case CREDIT_CARD_NUMBER: |
337 return DisplayName(); | 325 return DisplayName(); |
338 | 326 |
339 case CREDIT_CARD_EXP_4_DIGIT_YEAR: | 327 case CREDIT_CARD_EXP_4_DIGIT_YEAR: |
340 return base::IntToString16(expiration_year()); | 328 return base::IntToString16(expiration_year()); |
341 | 329 |
342 case CREDIT_CARD_VERIFICATION_CODE: | 330 case CREDIT_CARD_VERIFICATION_CODE: |
343 break; | 331 break; |
344 | 332 |
345 case CREDIT_CARD_TYPE: | 333 case CREDIT_CARD_TYPE: |
346 return UTF8ToUTF16(StringIdentifierFromType(type_)); | 334 return DisplayStringFromType(type_); |
347 | 335 |
348 default: | 336 default: |
349 NOTREACHED(); | 337 NOTREACHED(); |
350 } | 338 } |
351 | 339 |
352 return base::string16(); | 340 return base::string16(); |
353 } | 341 } |
354 | 342 |
355 WalletItems::LegalDocument::~LegalDocument() {} | 343 WalletItems::LegalDocument::~LegalDocument() {} |
356 | 344 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 VectorsAreEqual<LegalDocument>(legal_documents(), | 522 VectorsAreEqual<LegalDocument>(legal_documents(), |
535 other.legal_documents()); | 523 other.legal_documents()); |
536 } | 524 } |
537 | 525 |
538 bool WalletItems::operator!=(const WalletItems& other) const { | 526 bool WalletItems::operator!=(const WalletItems& other) const { |
539 return !(*this == other); | 527 return !(*this == other); |
540 } | 528 } |
541 | 529 |
542 } // namespace wallet | 530 } // namespace wallet |
543 } // namespace autofill | 531 } // namespace autofill |
OLD | NEW |