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 "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 if (input_card_idr == IDR_AUTOFILL_CC_GENERIC) { | 539 if (input_card_idr == IDR_AUTOFILL_CC_GENERIC) { |
540 // When the credit card type is unknown, no image should be shown. However, | 540 // When the credit card type is unknown, no image should be shown. However, |
541 // to simplify the view code on Mac, save space for the credit card image by | 541 // to simplify the view code on Mac, save space for the credit card image by |
542 // returning a transparent image of the appropriate size. | 542 // returning a transparent image of the appropriate size. |
543 result = gfx::Image(gfx::ImageSkiaOperations::CreateTransparentImage( | 543 result = gfx::Image(gfx::ImageSkiaOperations::CreateTransparentImage( |
544 result.AsImageSkia(), 0)); | 544 result.AsImageSkia(), 0)); |
545 } | 545 } |
546 return result; | 546 return result; |
547 } | 547 } |
548 | 548 |
549 gfx::Image CvcIconForCreditCardType(const std::string& credit_card_type) { | 549 gfx::Image CvcIconForCreditCardType(const base::string16& credit_card_type) { |
550 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 550 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
551 if (credit_card_type == autofill::kAmericanExpressCard) | 551 if (credit_card_type == l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX)) |
552 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT_AMEX); | 552 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT_AMEX); |
553 | 553 |
554 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT); | 554 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT); |
555 } | 555 } |
556 | 556 |
557 } // namespace | 557 } // namespace |
558 | 558 |
559 AutofillDialogViewDelegate::~AutofillDialogViewDelegate() {} | 559 AutofillDialogViewDelegate::~AutofillDialogViewDelegate() {} |
560 | 560 |
561 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { | 561 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 gfx::Image AutofillDialogControllerImpl::ExtraSuggestionIconForSection( | 1532 gfx::Image AutofillDialogControllerImpl::ExtraSuggestionIconForSection( |
1533 DialogSection section) { | 1533 DialogSection section) { |
1534 if (section != SECTION_CC && section != SECTION_CC_BILLING) | 1534 if (section != SECTION_CC && section != SECTION_CC_BILLING) |
1535 return gfx::Image(); | 1535 return gfx::Image(); |
1536 | 1536 |
1537 scoped_ptr<DataModelWrapper> model = CreateWrapper(section); | 1537 scoped_ptr<DataModelWrapper> model = CreateWrapper(section); |
1538 if (!model.get()) | 1538 if (!model.get()) |
1539 return gfx::Image(); | 1539 return gfx::Image(); |
1540 | 1540 |
1541 return CvcIconForCreditCardType( | 1541 return CvcIconForCreditCardType( |
1542 UTF16ToUTF8(model->GetInfo(AutofillType(CREDIT_CARD_TYPE)))); | 1542 model->GetInfo(AutofillType(CREDIT_CARD_TYPE))); |
1543 } | 1543 } |
1544 | 1544 |
1545 // TODO(groby): Remove this deprecated method after Mac starts using | 1545 // TODO(groby): Remove this deprecated method after Mac starts using |
1546 // IconsForFields. http://crbug.com/292876 | 1546 // IconsForFields. http://crbug.com/292876 |
1547 gfx::Image AutofillDialogControllerImpl::IconForField( | 1547 gfx::Image AutofillDialogControllerImpl::IconForField( |
1548 ServerFieldType type, const string16& user_input) const { | 1548 ServerFieldType type, const string16& user_input) const { |
1549 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1549 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
1550 if (type == CREDIT_CARD_VERIFICATION_CODE) | 1550 if (type == CREDIT_CARD_VERIFICATION_CODE) |
1551 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT); | 1551 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT); |
1552 | 1552 |
(...skipping 10 matching lines...) Expand all Loading... |
1563 return | 1563 return |
1564 gfx::Image(gfx::ImageSkiaOperations::CreateTransparentImage(image, 0)); | 1564 gfx::Image(gfx::ImageSkiaOperations::CreateTransparentImage(image, 0)); |
1565 } | 1565 } |
1566 | 1566 |
1567 return gfx::Image(); | 1567 return gfx::Image(); |
1568 } | 1568 } |
1569 | 1569 |
1570 FieldIconMap AutofillDialogControllerImpl::IconsForFields( | 1570 FieldIconMap AutofillDialogControllerImpl::IconsForFields( |
1571 const FieldValueMap& user_inputs) const { | 1571 const FieldValueMap& user_inputs) const { |
1572 FieldIconMap result; | 1572 FieldIconMap result; |
1573 std::string credit_card_type = autofill::kGenericCard; | 1573 base::string16 credit_card_type; |
1574 | 1574 |
1575 FieldValueMap::const_iterator credit_card_iter = | 1575 FieldValueMap::const_iterator credit_card_iter = |
1576 user_inputs.find(CREDIT_CARD_NUMBER); | 1576 user_inputs.find(CREDIT_CARD_NUMBER); |
1577 if (credit_card_iter != user_inputs.end()) { | 1577 if (credit_card_iter != user_inputs.end()) { |
1578 const string16& credit_card_number = credit_card_iter->second; | 1578 const string16& number = credit_card_iter->second; |
1579 credit_card_type = CreditCard::GetCreditCardType(credit_card_number); | 1579 const std::string type = CreditCard::GetCreditCardType(number); |
1580 result[CREDIT_CARD_NUMBER] = CreditCardIconForType(credit_card_type); | 1580 credit_card_type = CreditCard::TypeForDisplay(type); |
| 1581 result[CREDIT_CARD_NUMBER] = CreditCardIconForType(type); |
1581 } | 1582 } |
1582 | 1583 |
1583 if (!user_inputs.count(CREDIT_CARD_VERIFICATION_CODE)) | 1584 if (!user_inputs.count(CREDIT_CARD_VERIFICATION_CODE)) |
1584 return result; | 1585 return result; |
1585 | 1586 |
1586 result[CREDIT_CARD_VERIFICATION_CODE] = | 1587 result[CREDIT_CARD_VERIFICATION_CODE] = |
1587 CvcIconForCreditCardType(credit_card_type); | 1588 CvcIconForCreditCardType(credit_card_type); |
1588 | 1589 |
1589 return result; | 1590 return result; |
1590 } | 1591 } |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3416 } | 3417 } |
3417 | 3418 |
3418 void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() { | 3419 void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() { |
3419 if (!view_) | 3420 if (!view_) |
3420 return; | 3421 return; |
3421 ScopedViewUpdates updates(view_.get()); | 3422 ScopedViewUpdates updates(view_.get()); |
3422 view_->UpdateButtonStrip(); | 3423 view_->UpdateButtonStrip(); |
3423 } | 3424 } |
3424 | 3425 |
3425 } // namespace autofill | 3426 } // namespace autofill |
OLD | NEW |