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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 23756007: [rac] Show amex specific cvc hint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bring back the deprecated IconForField method, as it is still used on Mac Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index 059027f06883b74e691ccb469f204fb9adeaa073..dadc111439a41f0426be975b44eb4072ebe2ff5e 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -1507,13 +1507,22 @@ gfx::Image AutofillDialogControllerImpl::SuggestionIconForSection(
}
gfx::Image AutofillDialogControllerImpl::ExtraSuggestionIconForSection(
- DialogSection section) const {
- if (section == SECTION_CC || section == SECTION_CC_BILLING)
- return IconForField(CREDIT_CARD_VERIFICATION_CODE, string16());
-
- return gfx::Image();
+ DialogSection section) {
+ if (section != SECTION_CC && section != SECTION_CC_BILLING)
+ return gfx::Image();
+ scoped_ptr<DataModelWrapper> model = CreateWrapper(section);
+ if (!model.get())
+ return gfx::Image();
+ FieldValueMap section_values;
+ section_values[CREDIT_CARD_NUMBER] =
+ model->GetInfo(AutofillType(CREDIT_CARD_NUMBER));
Evan Stade 2013/09/16 23:36:59 this won't work for wallet (SECTION_CC_BILLING); w
please use gerrit instead 2013/09/17 00:38:17 Using CREDIT_CARD_TYPE instead.
+ section_values[CREDIT_CARD_VERIFICATION_CODE] = string16();
+ FieldIconMap section_icons = IconsForFields(section_values);
+ return section_icons[CREDIT_CARD_VERIFICATION_CODE];
Evan Stade 2013/09/16 23:36:59 this function needs vertical whitespace
please use gerrit instead 2013/09/17 00:38:17 Done.
}
+// TODO(groby): Remove this deprecated method after Mac starts using
+// IconsForFields. http://crbug.com/292876
gfx::Image AutofillDialogControllerImpl::IconForField(
ServerFieldType type, const string16& user_input) const {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
@@ -1537,6 +1546,47 @@ gfx::Image AutofillDialogControllerImpl::IconForField(
return gfx::Image();
}
+FieldIconMap AutofillDialogControllerImpl::IconsForFields(
+ const FieldValueMap& user_inputs) const {
+ FieldIconMap result;
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ FieldValueMap::const_iterator credit_card_iter =
+ user_inputs.find(CREDIT_CARD_NUMBER);
+ std::string credit_card_type = autofill::kGenericCard;
+ if (credit_card_iter != user_inputs.end()) {
+ const string16& credit_card_number = credit_card_iter->second;
+ credit_card_type = CreditCard::GetCreditCardType(credit_card_number);
+ const int input_card_idr = CreditCard::IconResourceId(credit_card_type);
+ result[CREDIT_CARD_NUMBER] = rb.GetImageNamed(input_card_idr);
+ if (input_card_idr == IDR_AUTOFILL_CC_GENERIC) {
+ // When the credit card type is unknown, no image should be shown.
+ // However, to simplify the view code on Mac, save space for the credit
+ // card image by returning a transparent image of the appropriate size.
+ result[CREDIT_CARD_NUMBER] =
+ gfx::Image(gfx::ImageSkiaOperations::CreateTransparentImage(
+ result[CREDIT_CARD_NUMBER].AsImageSkia(), 0));
+ }
+ }
+
+ FieldValueMap::const_iterator cvc_iter =
+ user_inputs.find(CREDIT_CARD_VERIFICATION_CODE);
+ if (cvc_iter == user_inputs.end())
+ return result;
+ if (credit_card_type == autofill::kAmericanExpressCard) {
+ result[CREDIT_CARD_VERIFICATION_CODE] =
+ rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT_AMEX);
+ return result;
+ }
+ result[CREDIT_CARD_VERIFICATION_CODE] =
+ rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT);
+ return result;
+}
+
+bool AutofillDialogControllerImpl::FieldControlsIcons(
+ ServerFieldType type) const {
+ return type == CREDIT_CARD_NUMBER;
+}
+
// TODO(estade): Replace all the error messages here with more helpful and
// translateable ones. TODO(groby): Also add tests.
string16 AutofillDialogControllerImpl::InputValidityMessage(

Powered by Google App Engine
This is Rietveld 408576698