diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 01:02:41 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 01:02:41 +0000 |
commit | fab0ab8e10370b6ba3d7edf57934aced69f84db4 (patch) | |
tree | 17bd691a87e9fbd4779515b5d5c2054c6d2fc905 | |
parent | d140fd77ba6a08111d2b7c1be59f0073b9dbe1fd (diff) | |
download | chromium_src-fab0ab8e10370b6ba3d7edf57934aced69f84db4.zip chromium_src-fab0ab8e10370b6ba3d7edf57934aced69f84db4.tar.gz chromium_src-fab0ab8e10370b6ba3d7edf57934aced69f84db4.tar.bz2 |
Add alt attribute to Autofill credit card icons
BUG=77713
TEST=none
Review URL: http://codereview.chromium.org/6825025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81198 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 25 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/autofill/credit_card.cc | 6 | ||||
-rw-r--r-- | chrome/browser/autofill/credit_card.h | 4 | ||||
-rw-r--r-- | chrome/browser/autofill/credit_card_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/resources/options/autofill_options_list.js | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/autofill_options_handler.cc | 27 |
7 files changed, 59 insertions, 9 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index a3a1bb8..d95c205 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7084,6 +7084,31 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_AUTOFILL_USE_MAC_ADDRESS_BOOK" desc="Checkbox label to enable Address Book on Mac."> Include addresses from my Address Book card </message> + + <message name="IDS_AUTOFILL_CC_AMEX" desc="American Express credit card name, for use as an image's 'alt' attribute."> + American Express + </message> + <message name="IDS_AUTOFILL_CC_DINERS" desc="Diners Club credit card name, for use as an image's 'alt' attribute."> + Diners Club + </message> + <message name="IDS_AUTOFILL_CC_DISCOVER" desc="Discover credit card name, for use as an image's 'alt' attribute."> + Discover + </message> + <message name="IDS_AUTOFILL_CC_GENERIC" desc="Generic credit card description, for use as an image's 'alt' attribute."> + Credit card (other) + </message> + <message name="IDS_AUTOFILL_CC_JCB" desc="JCB credit card name, for use as an image's 'alt' attribute."> + JCB + </message> + <message name="IDS_AUTOFILL_CC_MASTERCARD" desc="MasterCard credit card name, for use as an image's 'alt' attribute."> + MasterCard + </message> + <message name="IDS_AUTOFILL_CC_SOLO" desc="Solo credit card name, for use as an image's 'alt' attribute."> + Solo debit card + </message> + <message name="IDS_AUTOFILL_CC_VISA" desc="Visa credit card name, for use as an image's 'alt' attribute."> + Visa + </message> <if expr="not pp_ifdef('use_titlecase')"> <message name="IDS_AUTOFILL_ADDRESSES_GROUP_NAME" desc="In sentence case: The name of the Addresses group of the Autofill dialog."> diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index be3358a..93f32a9 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -876,7 +876,7 @@ void AutofillManager::GetCreditCardSuggestions(FormStructure* form, values->push_back(creditcard_field_value); labels->push_back(label); - icons->push_back(credit_card->type()); + icons->push_back(UTF8ToUTF16(credit_card->type())); unique_ids->push_back(PackGUIDs(GUIDPair(credit_card->guid(), 0), GUIDPair(std::string(), 0))); } diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc index 85e1f26..afb20e0 100644 --- a/chrome/browser/autofill/credit_card.cc +++ b/chrome/browser/autofill/credit_card.cc @@ -138,14 +138,14 @@ bool ConvertDate(const string16& date, int* num) { } // namespace CreditCard::CreditCard(const std::string& guid) - : type_(ASCIIToUTF16(kGenericCard)), + : type_(kGenericCard), expiration_month_(0), expiration_year_(0), guid_(guid) { } CreditCard::CreditCard() - : type_(ASCIIToUTF16(kGenericCard)), + : type_(kGenericCard), expiration_month_(0), expiration_year_(0), guid_(guid::GenerateGUID()) { @@ -478,7 +478,7 @@ void CreditCard::SetExpirationYearFromString(const string16& text) { void CreditCard::SetNumber(const string16& number) { number_ = number; - type_ = ASCIIToUTF16(GetCreditCardType(StripSeparators(number_))); + type_ = GetCreditCardType(StripSeparators(number_)); } void CreditCard::SetExpirationMonth(int expiration_month) { diff --git a/chrome/browser/autofill/credit_card.h b/chrome/browser/autofill/credit_card.h index ed8a828..a96e0a0 100644 --- a/chrome/browser/autofill/credit_card.h +++ b/chrome/browser/autofill/credit_card.h @@ -41,7 +41,7 @@ class CreditCard : public FormGroup { // The last four digits of the credit card number. string16 LastFourDigits() const; - const string16& type() const { return type_; } + const std::string& type() const { return type_; } // The guid is the primary identifier for |CreditCard| objects. const std::string guid() const { return guid_; } @@ -117,7 +117,7 @@ class CreditCard : public FormGroup { string16 number_; // The credit card number. string16 name_on_card_; // The cardholder's name. - string16 type_; // The type of the card. + std::string type_; // The type of the card. // These members are zero if not present. int expiration_month_; diff --git a/chrome/browser/autofill/credit_card_unittest.cc b/chrome/browser/autofill/credit_card_unittest.cc index 488c0c8..4ffc00f 100644 --- a/chrome/browser/autofill/credit_card_unittest.cc +++ b/chrome/browser/autofill/credit_card_unittest.cc @@ -122,7 +122,7 @@ TEST(CreditCardTest, InvalidMastercardNumber) { autofill_test::SetCreditCardInfo(&card, "Baby Face Nelson", "5200000000000004", "01", "2010"); - EXPECT_EQ(ASCIIToUTF16("genericCC"), card.type()); + EXPECT_EQ("genericCC", card.type()); } // Verify that we preserve exactly what the user typed for credit card numbers. diff --git a/chrome/browser/resources/options/autofill_options_list.js b/chrome/browser/resources/options/autofill_options_list.js index 8638726..61f563d 100644 --- a/chrome/browser/resources/options/autofill_options_list.js +++ b/chrome/browser/resources/options/autofill_options_list.js @@ -50,6 +50,7 @@ cr.define('options.autofillOptions', function() { el.guid = entry[0]; el.label = entry[1]; el.icon = entry[2]; + el.description = entry[3]; el.__proto__ = CreditCardListItem.prototype; el.decorate(); @@ -72,6 +73,7 @@ cr.define('options.autofillOptions', function() { // The credit card icon. var icon = this.ownerDocument.createElement('image'); icon.src = this.icon; + icon.alt = this.description; this.contentElement.appendChild(icon); }, }; diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc index 8bf7709..ab0038b 100644 --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc @@ -24,8 +24,7 @@ namespace { // Converts a credit card type to the appropriate resource ID of the CC icon. -int CreditCardTypeToResourceID(const string16& type16) { - std::string type = UTF16ToUTF8(type16); +int CreditCardTypeToResourceID(const std::string& type) { if (type == kAmericanExpressCard) return IDR_AUTOFILL_CC_AMEX; else if (type == kDinersCard) @@ -47,6 +46,29 @@ int CreditCardTypeToResourceID(const string16& type16) { return 0; } +// Converts a credit card type to the appropriate localized card type. +string16 LocalizedCreditCardType(const std::string& type) { + if (type == kAmericanExpressCard) + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX); + else if (type == kDinersCard) + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DINERS); + else if (type == kDiscoverCard) + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DISCOVER); + else if (type == kGenericCard) + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_GENERIC); + else if (type == kJCBCard) + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_JCB); + else if (type == kMasterCard) + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD); + else if (type == kSoloCard) + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_SOLO); + else if (type == kVisaCard) + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); + + NOTREACHED(); + return string16(); +} + // Returns a dictionary that maps country codes to data for the country. DictionaryValue* GetCountryData() { std::string app_locale = AutofillCountry::ApplicationLocale(); @@ -247,6 +269,7 @@ void AutofillOptionsHandler::LoadAutofillData() { int res = CreditCardTypeToResourceID((*i)->type()); entry->Append( new StringValue(web_ui_util::GetImageDataUrlFromResource(res))); + entry->Append(new StringValue(LocalizedCreditCardType((*i)->type()))); credit_cards.Append(entry); } |