diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 08:11:18 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 08:11:18 +0000 |
commit | e4da53118be91655d0233c93311636270a86ff36 (patch) | |
tree | f723689bf1310ff7e6b8f70d72bd7f170124650d | |
parent | a558f0fc3e509da6c8811b3b1c9d556d25512e17 (diff) | |
download | chromium_src-e4da53118be91655d0233c93311636270a86ff36.zip chromium_src-e4da53118be91655d0233c93311636270a86ff36.tar.gz chromium_src-e4da53118be91655d0233c93311636270a86ff36.tar.bz2 |
change some string types in wallet code
BUG=none
Review URL: https://chromiumcodereview.appspot.com/12262028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183429 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autofill/wallet/full_wallet_unittest.cc | 39 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/instrument.cc | 6 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/instrument.h | 17 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/instrument_unittest.cc | 55 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_address.cc | 57 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_address.h | 56 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_address_unittest.cc | 79 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_client.cc | 14 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_items.cc | 14 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_items.h | 19 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_items_unittest.cc | 59 | ||||
-rw-r--r-- | chrome/browser/autofill/wallet/wallet_test_util.cc | 38 | ||||
-rw-r--r-- | chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/autofill/data_model_wrapper.cc | 2 |
14 files changed, 234 insertions, 223 deletions
diff --git a/chrome/browser/autofill/wallet/full_wallet_unittest.cc b/chrome/browser/autofill/wallet/full_wallet_unittest.cc index 55560ac..86d955d 100644 --- a/chrome/browser/autofill/wallet/full_wallet_unittest.cc +++ b/chrome/browser/autofill/wallet/full_wallet_unittest.cc @@ -5,6 +5,7 @@ #include "base/json/json_reader.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/autofill/wallet/full_wallet.h" #include "chrome/browser/autofill/wallet/required_action.h" @@ -425,24 +426,26 @@ TEST_F(FullWalletTest, CreateFullWalletWithInvalidRequiredActions) { TEST_F(FullWalletTest, CreateFullWallet) { SetUpDictionary(kFullWalletValidResponse); - scoped_ptr<Address> billing_address(new Address("country_name_code", - "recipient_name", - "address_line_1", - "address_line_2", - "locality_name", - "administrative_area_name", - "postal_code_number", - "phone_number", - "id")); - scoped_ptr<Address> shipping_address(new Address("ship_country_name_code", - "ship_recipient_name", - "ship_address_line_1", - "ship_address_line_2", - "ship_locality_name", - "ship_admin_area_name", - "ship_postal_code_number", - "ship_phone_number", - "ship_id")); + scoped_ptr<Address> billing_address(new Address( + "country_name_code", + ASCIIToUTF16("recipient_name"), + ASCIIToUTF16("address_line_1"), + ASCIIToUTF16("address_line_2"), + ASCIIToUTF16("locality_name"), + ASCIIToUTF16("administrative_area_name"), + ASCIIToUTF16("postal_code_number"), + ASCIIToUTF16("phone_number"), + "id")); + scoped_ptr<Address> shipping_address(new Address( + "ship_country_name_code", + ASCIIToUTF16("ship_recipient_name"), + ASCIIToUTF16("ship_address_line_1"), + ASCIIToUTF16("ship_address_line_2"), + ASCIIToUTF16("ship_locality_name"), + ASCIIToUTF16("ship_admin_area_name"), + ASCIIToUTF16("ship_postal_code_number"), + ASCIIToUTF16("ship_phone_number"), + "ship_id")); std::vector<RequiredAction> required_actions; FullWallet full_wallet(12, 2012, diff --git a/chrome/browser/autofill/wallet/instrument.cc b/chrome/browser/autofill/wallet/instrument.cc index 7169f2e..94ce9ac 100644 --- a/chrome/browser/autofill/wallet/instrument.cc +++ b/chrome/browser/autofill/wallet/instrument.cc @@ -37,8 +37,8 @@ std::string FormOfPaymentToString( namespace wallet { -Instrument::Instrument(const std::string& primary_account_number, - const std::string& card_verification_number, +Instrument::Instrument(const string16& primary_account_number, + const string16& card_verification_number, int expiration_month, int expiration_year, FormOfPayment form_of_payment, @@ -80,7 +80,7 @@ bool Instrument::IsValid() const { if (!IsStringASCII(primary_account_number_)) return false; bool primary_account_number_valid = - autofill::IsValidCreditCardNumber(ASCIIToUTF16(primary_account_number_)); + autofill::IsValidCreditCardNumber(primary_account_number_); bool card_verification_number_valid = card_verification_number_.size() == 3 || card_verification_number_.size() == 4; bool exp_month_valid = expiration_month_ >= 1 && expiration_month_ <= 12; diff --git a/chrome/browser/autofill/wallet/instrument.h b/chrome/browser/autofill/wallet/instrument.h index 11f15d4..9c31b63 100644 --- a/chrome/browser/autofill/wallet/instrument.h +++ b/chrome/browser/autofill/wallet/instrument.h @@ -8,6 +8,7 @@ #include <string> #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" +#include "base/string16.h" namespace base { class DictionaryValue; @@ -31,8 +32,8 @@ class Instrument { JCB, }; - Instrument(const std::string& primary_account_number, - const std::string& card_verification_number, + Instrument(const string16& primary_account_number, + const string16& card_verification_number, int expiration_month, int expiration_year, FormOfPayment form_of_payment, @@ -45,24 +46,24 @@ class Instrument { // in the constructor were valid for use with Google Wallet. bool IsValid() const; - const std::string& primary_account_number() const { + const string16& primary_account_number() const { return primary_account_number_; } - const std::string& card_verification_number() const { + const string16& card_verification_number() const { return card_verification_number_; } int expiration_month() const { return expiration_month_; } int expiration_year() const { return expiration_year_; } const Address& address() const { return *address_; } FormOfPayment form_of_payment() const { return form_of_payment_; } - const std::string& last_four_digits() { return last_four_digits_; } + const string16& last_four_digits() { return last_four_digits_; } private: // |primary_account_number_| is expected to be \d{12-19}. - std::string primary_account_number_; + string16 primary_account_number_; // |card_verification_number_| is expected to be \d{3-4}. - std::string card_verification_number_; + string16 card_verification_number_; // |expiration month_| should be 1-12. int expiration_month_; @@ -77,7 +78,7 @@ class Instrument { scoped_ptr<Address> address_; // The last four digits of |primary_account_number_|. - std::string last_four_digits_; + string16 last_four_digits_; DISALLOW_COPY_AND_ASSIGN(Instrument); }; diff --git a/chrome/browser/autofill/wallet/instrument_unittest.cc b/chrome/browser/autofill/wallet/instrument_unittest.cc index ae9d746..321546e 100644 --- a/chrome/browser/autofill/wallet/instrument_unittest.cc +++ b/chrome/browser/autofill/wallet/instrument_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/autofill/wallet/instrument.h" #include "chrome/browser/autofill/wallet/wallet_address.h" @@ -19,20 +20,20 @@ const char kLastFourDigits[] = "4448"; namespace wallet { TEST(Instrument, LastFourDigits) { - Instrument instrument(kPrimaryAccountNumber, - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + ASCIIToUTF16(kCardVerificationNumber), 12, 2015, Instrument::VISA, GetTestShippingAddress().Pass()); - EXPECT_EQ(kLastFourDigits, instrument.last_four_digits()); + EXPECT_EQ(ASCIIToUTF16(kLastFourDigits), instrument.last_four_digits()); EXPECT_TRUE(instrument.IsValid()); } TEST(Instrument, NoPrimaryAccountNumberIsInvalid) { - Instrument instrument(std::string(), - kCardVerificationNumber, + Instrument instrument(string16(), + ASCIIToUTF16(kCardVerificationNumber), 12, 2015, Instrument::VISA, @@ -42,8 +43,8 @@ TEST(Instrument, NoPrimaryAccountNumberIsInvalid) { } TEST(Instrument, TooShortPrimaryAccountNumberIsInvalid) { - Instrument instrument("44447", - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16("44447"), + ASCIIToUTF16(kCardVerificationNumber), 12, 2015, Instrument::VISA, @@ -53,8 +54,8 @@ TEST(Instrument, TooShortPrimaryAccountNumberIsInvalid) { } TEST(Instrument, TooLongPrimaryAccountNumberIsInvalid) { - Instrument instrument("44444444444444444448", - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16("44444444444444444448"), + ASCIIToUTF16(kCardVerificationNumber), 12, 2015, Instrument::VISA, @@ -64,8 +65,8 @@ TEST(Instrument, TooLongPrimaryAccountNumberIsInvalid) { } TEST(Instrument, PrimaryAccountNumberNotPassingLuhnIsInvalid) { - Instrument instrument("4444444444444444", - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16("4444444444444444"), + ASCIIToUTF16(kCardVerificationNumber), 12, 2015, Instrument::VISA, @@ -75,8 +76,8 @@ TEST(Instrument, PrimaryAccountNumberNotPassingLuhnIsInvalid) { } TEST(Instrument, NoCardVerificationNumberIsInvalid) { - Instrument instrument(kPrimaryAccountNumber, - std::string(), + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + string16(), 12, 2015, Instrument::VISA, @@ -86,8 +87,8 @@ TEST(Instrument, NoCardVerificationNumberIsInvalid) { } TEST(Instrument, TooShortCardVerificationNumberIsInvalid) { - Instrument instrument(kPrimaryAccountNumber, - "12", + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + ASCIIToUTF16("12"), 12, 2015, Instrument::VISA, @@ -97,8 +98,8 @@ TEST(Instrument, TooShortCardVerificationNumberIsInvalid) { } TEST(Instrument, TooLongCardVerificationNumberIsInvalid) { - Instrument instrument(kPrimaryAccountNumber, - "12345", + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + ASCIIToUTF16("12345"), 12, 2015, Instrument::VISA, @@ -108,8 +109,8 @@ TEST(Instrument, TooLongCardVerificationNumberIsInvalid) { } TEST(Instrument, ZeroAsExpirationMonthIsInvalid) { - Instrument instrument(kPrimaryAccountNumber, - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + ASCIIToUTF16(kCardVerificationNumber), 0, 2015, Instrument::VISA, @@ -119,8 +120,8 @@ TEST(Instrument, ZeroAsExpirationMonthIsInvalid) { } TEST(Instrument, TooLargeExpirationMonthIsInvalid) { - Instrument instrument(kPrimaryAccountNumber, - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + ASCIIToUTF16(kCardVerificationNumber), 13, 2015, Instrument::VISA, @@ -130,8 +131,8 @@ TEST(Instrument, TooLargeExpirationMonthIsInvalid) { } TEST(Instrument, TooSmallExpirationYearIsInvalid) { - Instrument instrument(kPrimaryAccountNumber, - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + ASCIIToUTF16(kCardVerificationNumber), 12, 999, Instrument::VISA, @@ -141,8 +142,8 @@ TEST(Instrument, TooSmallExpirationYearIsInvalid) { } TEST(Instrument, TooLargeExpirationYearIsInvalid) { - Instrument instrument(kPrimaryAccountNumber, - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + ASCIIToUTF16(kCardVerificationNumber), 12, 10000, Instrument::VISA, @@ -173,8 +174,8 @@ TEST(Instrument, ToDictionary) { address_lines->AppendString("ship_address_line_2"); expected.Set("credit_card.address.address_line", address_lines); - Instrument instrument(kPrimaryAccountNumber, - kCardVerificationNumber, + Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber), + ASCIIToUTF16(kCardVerificationNumber), 12, 2015, Instrument::VISA, diff --git a/chrome/browser/autofill/wallet/wallet_address.cc b/chrome/browser/autofill/wallet/wallet_address.cc index da75f1d5..eb34483 100644 --- a/chrome/browser/autofill/wallet/wallet_address.cc +++ b/chrome/browser/autofill/wallet/wallet_address.cc @@ -13,13 +13,13 @@ namespace wallet { Address::Address() {} Address::Address(const std::string& country_name_code, - const std::string& recipient_name, - const std::string& address_line_1, - const std::string& address_line_2, - const std::string& locality_name, - const std::string& administrative_area_name, - const std::string& postal_code_number, - const std::string& phone_number, + const string16& recipient_name, + const string16& address_line_1, + const string16& address_line_2, + const string16& locality_name, + const string16& administrative_area_name, + const string16& postal_code_number, + const string16& phone_number, const std::string& object_id) : country_name_code_(country_name_code), recipient_name_(recipient_name), @@ -65,28 +65,28 @@ scoped_ptr<base::DictionaryValue> Address::ToDictionaryWithoutID() const { string16 Address::DisplayName() const { // TODO(estade): improve this stub implementation. - return UTF8ToUTF16(recipient_name() + ", " + address_line_1()); + return recipient_name() + ASCIIToUTF16(", ") + address_line_1(); } string16 Address::GetInfo(AutofillFieldType type) const { switch (type) { case NAME_FULL: - return UTF8ToUTF16(recipient_name()); + return recipient_name(); case ADDRESS_HOME_LINE1: - return UTF8ToUTF16(address_line_1()); + return address_line_1(); case ADDRESS_HOME_LINE2: - return UTF8ToUTF16(address_line_2()); + return address_line_2(); case ADDRESS_HOME_CITY: - return UTF8ToUTF16(locality_name()); + return locality_name(); case ADDRESS_HOME_STATE: - return UTF8ToUTF16(admin_area_name()); + return admin_area_name(); case ADDRESS_HOME_ZIP: - return UTF8ToUTF16(postal_code_number()); + return postal_code_number(); // TODO(estade): implement more. default: @@ -110,26 +110,26 @@ scoped_ptr<Address> return scoped_ptr<Address>(); } - std::string recipient_name; + string16 recipient_name; if (!dictionary.GetString("postal_address.recipient_name", &recipient_name)) { DLOG(ERROR) << "Response from Google Wallet recipient name"; return scoped_ptr<Address>(); } - std::string postal_code_number; + string16 postal_code_number; if (!dictionary.GetString("postal_address.postal_code_number", &postal_code_number)) { DLOG(ERROR) << "Response from Google Wallet missing postal code number"; return scoped_ptr<Address>(); } - std::string phone_number; + string16 phone_number; if (!dictionary.GetString("phone_number", &phone_number)) DVLOG(1) << "Response from Google Wallet missing phone number"; - std::string address_line_1; - std::string address_line_2; + string16 address_line_1; + string16 address_line_2; const ListValue* address_line_list; if (dictionary.GetList("postal_address.address_line", &address_line_list)) { if (!address_line_list->GetString(0, &address_line_1)) @@ -140,13 +140,13 @@ scoped_ptr<Address> DVLOG(1) << "Response from Google Wallet missing address lines"; } - std::string locality_name; + string16 locality_name; if (!dictionary.GetString("postal_address.locality_name", &locality_name)) { DVLOG(1) << "Response from Google Wallet missing locality name"; } - std::string administrative_area_name; + string16 administrative_area_name; if (!dictionary.GetString("postal_address.administrative_area_name", &administrative_area_name)) { DVLOG(1) << "Response from Google Wallet missing administrative area name"; @@ -163,7 +163,6 @@ scoped_ptr<Address> object_id)); } - scoped_ptr<Address> Address::CreateDisplayAddress(const base::DictionaryValue& dictionary) { std::string country_code; @@ -172,35 +171,35 @@ scoped_ptr<Address> return scoped_ptr<Address>(); } - std::string name; + string16 name; if (!dictionary.GetString("name", &name)) { DLOG(ERROR) << "Reponse from Google Wallet missing name"; return scoped_ptr<Address>(); } - std::string postal_code; + string16 postal_code; if (!dictionary.GetString("postal_code", &postal_code)) { DLOG(ERROR) << "Reponse from Google Wallet missing postal code"; return scoped_ptr<Address>(); } - std::string address1; + string16 address1; if (!dictionary.GetString("address1", &address1)) DVLOG(1) << "Reponse from Google Wallet missing address1"; - std::string address2; + string16 address2; if (!dictionary.GetString("address2", &address2)) DVLOG(1) << "Reponse from Google Wallet missing address2"; - std::string city; + string16 city; if (!dictionary.GetString("city", &city)) DVLOG(1) << "Reponse from Google Wallet missing city"; - std::string state; + string16 state; if (!dictionary.GetString("state", &state)) DVLOG(1) << "Reponse from Google Wallet missing state"; - std::string phone_number; + string16 phone_number; if (!dictionary.GetString("phone_number", &phone_number)) DVLOG(1) << "Reponse from Google Wallet missing phone number"; diff --git a/chrome/browser/autofill/wallet/wallet_address.h b/chrome/browser/autofill/wallet/wallet_address.h index 2d7e6151..adba56e 100644 --- a/chrome/browser/autofill/wallet/wallet_address.h +++ b/chrome/browser/autofill/wallet/wallet_address.h @@ -33,49 +33,49 @@ class Address { // is_minimal_address, is_valid, is_default) when SaveToWallet is implemented. // See http://crbug.com/164284. Address(const std::string& country_name_code, - const std::string& recipient_name, - const std::string& address_line_1, - const std::string& address_line_2, - const std::string& locality_name, - const std::string& administrative_area_name, - const std::string& postal_code_number, - const std::string& phone_number, + const string16& recipient_name, + const string16& address_line_1, + const string16& address_line_2, + const string16& locality_name, + const string16& administrative_area_name, + const string16& postal_code_number, + const string16& phone_number, const std::string& object_id); ~Address(); const std::string& country_name_code() const { return country_name_code_; } - const std::string& recipient_name() const { return recipient_name_; } - const std::string& address_line_1() const { return address_line_1_; } - const std::string& address_line_2() const { return address_line_2_; } - const std::string& locality_name() const { return locality_name_; } - const std::string& admin_area_name() const { + const string16& recipient_name() const { return recipient_name_; } + const string16& address_line_1() const { return address_line_1_; } + const string16& address_line_2() const { return address_line_2_; } + const string16& locality_name() const { return locality_name_; } + const string16& admin_area_name() const { return administrative_area_name_; } - const std::string& postal_code_number() const { return postal_code_number_; } - const std::string& phone_number() const { return phone_number_; } + const string16& postal_code_number() const { return postal_code_number_; } + const string16& phone_number() const { return phone_number_; } const std::string& object_id() const { return object_id_; } void set_country_name_code(const std::string& country_name_code) { country_name_code_ = country_name_code; } - void set_recipient_name(const std::string& recipient_name) { + void set_recipient_name(const string16& recipient_name) { recipient_name_ = recipient_name; } - void set_address_line_1(const std::string& address_line_1) { + void set_address_line_1(const string16& address_line_1) { address_line_1_ = address_line_1; } - void set_address_line_2(const std::string& address_line_2) { + void set_address_line_2(const string16& address_line_2) { address_line_2_ = address_line_2; } - void set_locality_name(const std::string& locality_name) { + void set_locality_name(const string16& locality_name) { locality_name_ = locality_name; } - void set_admin_area_name(const std::string& administrative_area_name) { + void set_admin_area_name(const string16& administrative_area_name) { administrative_area_name_ = administrative_area_name; } - void set_postal_code_number(const std::string& postal_code_number) { + void set_postal_code_number(const string16& postal_code_number) { postal_code_number_ = postal_code_number; } - void set_phone_number(const std::string& phone_number) { + void set_phone_number(const string16& phone_number) { phone_number_ = phone_number; } void set_object_id(const std::string& object_id) { @@ -117,12 +117,12 @@ class Address { std::string country_name_code_; // The recipient's name. For example "John Doe". - std::string recipient_name_; + string16 recipient_name_; // |address_line_1| and |address_line_2| correspond to the "AddressLine" // elements in xAL, which are used to hold unstructured text. - std::string address_line_1_; - std::string address_line_2_; + string16 address_line_1_; + string16 address_line_2_; // Locality. This is something of a fuzzy term, but it generally refers to // the city/town portion of an address. In regions of the world where @@ -130,20 +130,20 @@ class Address { // (for example, Japan and China), leave locality_name empty and use // |address_line_2|. // Examples: US city, IT comune, UK post town. - std::string locality_name_; + string16 locality_name_; // Top-level administrative subdivision of this country. // Examples: US state, IT region, UK constituent nation, JP prefecture. - std::string administrative_area_name_; + string16 administrative_area_name_; // Despite the name, |postal_code_number_| values are frequently alphanumeric. // Examples: "94043", "SW1W", "SW1W 9TQ". - std::string postal_code_number_; + string16 postal_code_number_; // A valid international phone number. If |phone_number_| is a user provided // value, it should have been validated using libphonenumber by clients of // this class before being set; see http://code.google.com/p/libphonenumber/. - std::string phone_number_; + string16 phone_number_; // Externalized Online Wallet id for this address. std::string object_id_; diff --git a/chrome/browser/autofill/wallet/wallet_address_unittest.cc b/chrome/browser/autofill/wallet/wallet_address_unittest.cc index abe54ee..06dc9f7 100644 --- a/chrome/browser/autofill/wallet/wallet_address_unittest.cc +++ b/chrome/browser/autofill/wallet/wallet_address_unittest.cc @@ -5,6 +5,7 @@ #include "base/json/json_reader.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/autofill/wallet/wallet_address.h" #include "testing/gtest/include/gtest/gtest.h" @@ -159,72 +160,72 @@ class WalletAddressTest : public testing::Test { scoped_ptr<Value> value(base::JSONReader::Read(json)); DCHECK(value.get()); DCHECK(value->IsType(Value::TYPE_DICTIONARY)); - dict.reset(static_cast<DictionaryValue*>(value.release())); + dict_.reset(static_cast<DictionaryValue*>(value.release())); } - scoped_ptr<const DictionaryValue> dict; + scoped_ptr<const DictionaryValue> dict_; }; TEST_F(WalletAddressTest, CreateAddressWithIDMissingObjectId) { SetUpDictionary(kAddressMissingObjectId); - ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict).get()); + ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict_).get()); } TEST_F(WalletAddressTest, CreateAddressWithIDMissingCountryNameCode) { SetUpDictionary(kAddressMissingCountryNameCode); - ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict).get()); + ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict_).get()); } TEST_F(WalletAddressTest, CreateAddressWithIDMissingRecipientName) { SetUpDictionary(kAddressMissingRecipientName); - ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict).get()); + ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict_).get()); } TEST_F(WalletAddressTest, CreateAddressWithIDMissingPostalCodeNumber) { SetUpDictionary(kAddressMissingPostalCodeNumber); - ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict).get()); + ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict_).get()); } TEST_F(WalletAddressTest, CreateAddressWithID) { SetUpDictionary(kValidAddress); Address address("country_name_code", - "recipient_name", - "address_line_1", - "address_line_2", - "locality_name", - "administrative_area_name", - "postal_code_number", - "phone_number", + ASCIIToUTF16("recipient_name"), + ASCIIToUTF16("address_line_1"), + ASCIIToUTF16("address_line_2"), + ASCIIToUTF16("locality_name"), + ASCIIToUTF16("administrative_area_name"), + ASCIIToUTF16("postal_code_number"), + ASCIIToUTF16("phone_number"), "id"); - ASSERT_EQ(address, *Address::CreateAddressWithID(*dict)); + ASSERT_EQ(address, *Address::CreateAddressWithID(*dict_)); } TEST_F(WalletAddressTest, CreateDisplayAddressMissingCountryNameCode) { SetUpDictionary(kClientAddressMissingCountryCode); - ASSERT_EQ(NULL, Address::CreateDisplayAddress(*dict).get()); + ASSERT_EQ(NULL, Address::CreateDisplayAddress(*dict_).get()); } TEST_F(WalletAddressTest, CreateDisplayAddressMissingName) { SetUpDictionary(kClientAddressMissingName); - ASSERT_EQ(NULL, Address::CreateDisplayAddress(*dict).get()); + ASSERT_EQ(NULL, Address::CreateDisplayAddress(*dict_).get()); } TEST_F(WalletAddressTest, CreateDisplayAddressMissingPostalCode) { SetUpDictionary(kClientAddressMissingPostalCode); - ASSERT_EQ(NULL, Address::CreateDisplayAddress(*dict).get()); + ASSERT_EQ(NULL, Address::CreateDisplayAddress(*dict_).get()); } TEST_F(WalletAddressTest, CreateDisplayAddress) { SetUpDictionary(kClientValidAddress); Address address("country_code", - "name", - "address1", - "address2", - "city", - "state", - "postal_code", - "phone_number", + ASCIIToUTF16("name"), + ASCIIToUTF16("address1"), + ASCIIToUTF16("address2"), + ASCIIToUTF16("city"), + ASCIIToUTF16("state"), + ASCIIToUTF16("postal_code"), + ASCIIToUTF16("phone_number"), ""); - ASSERT_EQ(address, *Address::CreateDisplayAddress(*dict)); + ASSERT_EQ(address, *Address::CreateDisplayAddress(*dict_)); } TEST_F(WalletAddressTest, ToDictionaryWithoutID) { @@ -245,13 +246,13 @@ TEST_F(WalletAddressTest, ToDictionaryWithoutID) { expected.Set("address_line", address_lines); Address address("country_name_code", - "recipient_name", - "address_line_1", - "address_line_2", - "locality_name", - "administrative_area_name", - "postal_code_number", - "phone_number", + ASCIIToUTF16("recipient_name"), + ASCIIToUTF16("address_line_1"), + ASCIIToUTF16("address_line_2"), + ASCIIToUTF16("locality_name"), + ASCIIToUTF16("administrative_area_name"), + ASCIIToUTF16("postal_code_number"), + ASCIIToUTF16("phone_number"), ""); EXPECT_TRUE(expected.Equals(address.ToDictionaryWithoutID().get())); @@ -277,13 +278,13 @@ TEST_F(WalletAddressTest, ToDictionaryWithID) { expected.Set("postal_address.address_line", address_lines); Address address("country_name_code", - "recipient_name", - "address_line_1", - "address_line_2", - "locality_name", - "administrative_area_name", - "postal_code_number", - "phone_number", + ASCIIToUTF16("recipient_name"), + ASCIIToUTF16("address_line_1"), + ASCIIToUTF16("address_line_2"), + ASCIIToUTF16("locality_name"), + ASCIIToUTF16("administrative_area_name"), + ASCIIToUTF16("postal_code_number"), + ASCIIToUTF16("phone_number"), "id"); EXPECT_TRUE(expected.Equals(address.ToDictionaryWithID().get())); diff --git a/chrome/browser/autofill/wallet/wallet_client.cc b/chrome/browser/autofill/wallet/wallet_client.cc index 5c3f03a..5398cc1 100644 --- a/chrome/browser/autofill/wallet/wallet_client.cc +++ b/chrome/browser/autofill/wallet/wallet_client.cc @@ -11,6 +11,7 @@ #include "base/string_split.h" #include "base/stringprintf.h" #include "base/strings/string_number_conversions.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/autofill/wallet/cart.h" #include "chrome/browser/autofill/wallet/full_wallet.h" @@ -90,9 +91,10 @@ void WalletClient::EncryptOtp(const void* otp, request_type_ = ENCRYPT_OTP; - std::string post_body = StringPrintf(kEncryptOtpBodyFormat, - base::HexEncode(&num_bits, 1).c_str(), - base::HexEncode(otp, length).c_str()); + std::string post_body = base::StringPrintf( + kEncryptOtpBodyFormat, + base::HexEncode(&num_bits, 1).c_str(), + base::HexEncode(otp, length).c_str()); MakeWalletRequest(GetEncryptionUrl(), post_body, @@ -107,11 +109,11 @@ void WalletClient::EscrowSensitiveInformation( DCHECK_EQ(NO_PENDING_REQUEST, request_type_); request_type_ = ESCROW_SENSITIVE_INFORMATION; - std::string post_body = StringPrintf( + std::string post_body = base::StringPrintf( kEscrowSensitiveInformationFormat, obfuscated_gaia_id.c_str(), - new_instrument.primary_account_number().c_str(), - new_instrument.card_verification_number().c_str()); + UTF16ToUTF8(new_instrument.primary_account_number()).c_str(), + UTF16ToUTF8(new_instrument.card_verification_number()).c_str()); MakeWalletRequest(GetEscrowUrl(), post_body, observer, kApplicationMimeType); } diff --git a/chrome/browser/autofill/wallet/wallet_items.cc b/chrome/browser/autofill/wallet/wallet_items.cc index 96ccc0a..9a89478e 100644 --- a/chrome/browser/autofill/wallet/wallet_items.cc +++ b/chrome/browser/autofill/wallet/wallet_items.cc @@ -54,10 +54,10 @@ wallet::WalletItems::MaskedInstrument::Status namespace wallet { WalletItems::MaskedInstrument::MaskedInstrument( - const std::string& descriptive_name, + const string16& descriptive_name, const WalletItems::MaskedInstrument::Type& type, - const std::vector<std::string>& supported_currencies, - const std::string& last_four_digits, + const std::vector<string16>& supported_currencies, + const string16& last_four_digits, int expiration_month, int expiration_year, scoped_ptr<Address> address, @@ -89,7 +89,7 @@ scoped_ptr<WalletItems::MaskedInstrument> return scoped_ptr<MaskedInstrument>(); } - std::string last_four_digits; + string16 last_four_digits; if (!dictionary.GetString("last_four_digits", &last_four_digits)) { DLOG(ERROR) << "Response from Google Wallet missing last four digits"; return scoped_ptr<MaskedInstrument>(); @@ -122,11 +122,11 @@ scoped_ptr<WalletItems::MaskedInstrument> return scoped_ptr<MaskedInstrument>(); } - std::vector<std::string> supported_currencies; + std::vector<string16> supported_currencies; const ListValue* supported_currency_list; if (dictionary.GetList("supported_currency", &supported_currency_list)) { for (size_t i = 0; i < supported_currency_list->GetSize(); ++i) { - std::string currency; + string16 currency; if (supported_currency_list->GetString(i, ¤cy)) supported_currencies.push_back(currency); } @@ -142,7 +142,7 @@ scoped_ptr<WalletItems::MaskedInstrument> if (!dictionary.GetInteger("expiration_year", &expiration_year)) DVLOG(1) << "Response from Google Wallet missing expiration year"; - std::string descriptive_name; + string16 descriptive_name; if (!dictionary.GetString("descriptive_name", &descriptive_name)) DVLOG(1) << "Response from Google Wallet missing descriptive name"; diff --git a/chrome/browser/autofill/wallet/wallet_items.h b/chrome/browser/autofill/wallet/wallet_items.h index 4615990..ed5130d 100644 --- a/chrome/browser/autofill/wallet/wallet_items.h +++ b/chrome/browser/autofill/wallet/wallet_items.h @@ -13,6 +13,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" +#include "base/string16.h" #include "chrome/browser/autofill/wallet/required_action.h" #include "chrome/browser/autofill/wallet/wallet_address.h" @@ -67,12 +68,12 @@ class WalletItems { bool operator==(const MaskedInstrument& other) const; bool operator!=(const MaskedInstrument& other) const; - const std::string& descriptive_name() const { return descriptive_name_; } + const string16& descriptive_name() const { return descriptive_name_; } const Type& type() const { return type_; } - const std::vector<std::string>& supported_currencies() const { + const std::vector<string16>& supported_currencies() const { return supported_currencies_; } - const std::string& last_four_digits() const { return last_four_digits_; } + const string16& last_four_digits() const { return last_four_digits_; } int expiration_month() const { return expiration_month_; } int expiration_year() const { return expiration_year_; } const Address& address() const { return *address_; } @@ -83,10 +84,10 @@ class WalletItems { friend class WalletItemsTest; FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, CreateMaskedInstrument); FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, CreateWalletItems); - MaskedInstrument(const std::string& descriptve_name, + MaskedInstrument(const string16& descriptve_name, const Type& type, - const std::vector<std::string>& supported_currencies, - const std::string& last_four_digits, + const std::vector<string16>& supported_currencies, + const string16& last_four_digits, int expiration_month, int expiration_year, scoped_ptr<Address> address, @@ -95,16 +96,16 @@ class WalletItems { // A user-provided description of the instrument. For example, "Google Visa // Card". - std::string descriptive_name_; + string16 descriptive_name_; // The payment network of the instrument. For example, Visa. Type type_; // |supported_currencies_| are ISO 4217 currency codes, e.g. USD. - std::vector<std::string> supported_currencies_; + std::vector<string16> supported_currencies_; // The last four digits of the primary account number of the instrument. - std::string last_four_digits_; + string16 last_four_digits_; // |expiration month_| should be 1-12. int expiration_month_; diff --git a/chrome/browser/autofill/wallet/wallet_items_unittest.cc b/chrome/browser/autofill/wallet/wallet_items_unittest.cc index da1e157..1e585ef 100644 --- a/chrome/browser/autofill/wallet/wallet_items_unittest.cc +++ b/chrome/browser/autofill/wallet/wallet_items_unittest.cc @@ -5,6 +5,7 @@ #include "base/json/json_reader.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/autofill/wallet/required_action.h" #include "chrome/browser/autofill/wallet/wallet_items.h" @@ -398,21 +399,21 @@ TEST_F(WalletItemsTest, CreateMaskedInstrumentMissingObjectId) { TEST_F(WalletItemsTest, CreateMaskedInstrument) { SetUpDictionary(kMaskedInstrument); scoped_ptr<Address> address(new Address("country_code", - "name", - "address1", - "address2", - "city", - "state", - "postal_code", - "phone_number", + ASCIIToUTF16("name"), + ASCIIToUTF16("address1"), + ASCIIToUTF16("address2"), + ASCIIToUTF16("city"), + ASCIIToUTF16("state"), + ASCIIToUTF16("postal_code"), + ASCIIToUTF16("phone_number"), "")); - std::vector<std::string> supported_currencies; - supported_currencies.push_back("currency"); + std::vector<string16> supported_currencies; + supported_currencies.push_back(ASCIIToUTF16("currency")); WalletItems::MaskedInstrument masked_instrument( - "descriptive_name", + ASCIIToUTF16("descriptive_name"), WalletItems::MaskedInstrument::VISA, supported_currencies, - "last_four_digits", + ASCIIToUTF16("last_four_digits"), 12, 2012, address.Pass(), @@ -493,21 +494,21 @@ TEST_F(WalletItemsTest, CreateWalletItems) { "obfuscated_gaia_id"); scoped_ptr<Address> billing_address(new Address("country_code", - "name", - "address1", - "address2", - "city", - "state", - "postal_code", - "phone_number", + ASCIIToUTF16("name"), + ASCIIToUTF16("address1"), + ASCIIToUTF16("address2"), + ASCIIToUTF16("city"), + ASCIIToUTF16("state"), + ASCIIToUTF16("postal_code"), + ASCIIToUTF16("phone_number"), "")); - std::vector<std::string> supported_currencies; - supported_currencies.push_back("currency"); + std::vector<string16> supported_currencies; + supported_currencies.push_back(ASCIIToUTF16("currency")); scoped_ptr<WalletItems::MaskedInstrument> masked_instrument( - new WalletItems::MaskedInstrument("descriptive_name", + new WalletItems::MaskedInstrument(ASCIIToUTF16("descriptive_name"), WalletItems::MaskedInstrument::VISA, supported_currencies, - "last_four_digits", + ASCIIToUTF16("last_four_digits"), 12, 2012, billing_address.Pass(), @@ -516,13 +517,13 @@ TEST_F(WalletItemsTest, CreateWalletItems) { expected.AddInstrument(masked_instrument.Pass()); scoped_ptr<Address> shipping_address(new Address("country_code", - "name", - "address1", - "address2", - "city", - "state", - "postal_code", - "phone_number", + ASCIIToUTF16("name"), + ASCIIToUTF16("address1"), + ASCIIToUTF16("address2"), + ASCIIToUTF16("city"), + ASCIIToUTF16("state"), + ASCIIToUTF16("postal_code"), + ASCIIToUTF16("phone_number"), "id")); expected.AddAddress(shipping_address.Pass()); diff --git a/chrome/browser/autofill/wallet/wallet_test_util.cc b/chrome/browser/autofill/wallet/wallet_test_util.cc index b521834..4ff4ee9 100644 --- a/chrome/browser/autofill/wallet/wallet_test_util.cc +++ b/chrome/browser/autofill/wallet/wallet_test_util.cc @@ -4,14 +4,15 @@ #include "chrome/browser/autofill/wallet/wallet_test_util.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/autofill/wallet/instrument.h" #include "chrome/browser/autofill/wallet/wallet_address.h" namespace wallet { scoped_ptr<Instrument> GetTestInstrument() { - return scoped_ptr<Instrument>(new Instrument("4444444444444448", - "123", + return scoped_ptr<Instrument>(new Instrument(ASCIIToUTF16("4444444444444448"), + ASCIIToUTF16("123"), 12, 2012, Instrument::VISA, @@ -19,26 +20,27 @@ scoped_ptr<Instrument> GetTestInstrument() { } scoped_ptr<Address> GetTestShippingAddress() { - return scoped_ptr<Address>(new Address("ship_country_name_code", - "ship_recipient_name", - "ship_address_line_1", - "ship_address_line_2", - "ship_locality_name", - "ship_admin_area_name", - "ship_postal_code_number", - "ship_phone_number", - std::string())); + return scoped_ptr<Address>(new Address( + "ship_country_name_code", + ASCIIToUTF16("ship_recipient_name"), + ASCIIToUTF16("ship_address_line_1"), + ASCIIToUTF16("ship_address_line_2"), + ASCIIToUTF16("ship_locality_name"), + ASCIIToUTF16("ship_admin_area_name"), + ASCIIToUTF16("ship_postal_code_number"), + ASCIIToUTF16("ship_phone_number"), + std::string())); } scoped_ptr<Address> GetTestAddress() { return scoped_ptr<Address>(new Address("country_name_code", - "recipient_name", - "address_line_1", - "address_line_2", - "locality_name", - "admin_area_name", - "postal_code_number", - "phone_number", + ASCIIToUTF16("recipient_name"), + ASCIIToUTF16("address_line_1"), + ASCIIToUTF16("address_line_2"), + ASCIIToUTF16("locality_name"), + ASCIIToUTF16("admin_area_name"), + ASCIIToUTF16("postal_code_number"), + ASCIIToUTF16("phone_number"), std::string())); } diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index ee05c5c..41dcd3a 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -960,7 +960,7 @@ void AutofillDialogControllerImpl::GenerateSuggestionsModels() { for (size_t i = 0; i < instruments.size(); ++i) { suggested_cc_billing_.AddKeyedItem( base::IntToString(i), - UTF8ToUTF16(instruments[i]->descriptive_name())); + instruments[i]->descriptive_name()); } } diff --git a/chrome/browser/ui/autofill/data_model_wrapper.cc b/chrome/browser/ui/autofill/data_model_wrapper.cc index f84c9e4..6221cfd 100644 --- a/chrome/browser/ui/autofill/data_model_wrapper.cc +++ b/chrome/browser/ui/autofill/data_model_wrapper.cc @@ -159,7 +159,7 @@ void WalletInstrumentWrapper::FillInputs(DetailInputs* inputs) { string16 WalletInstrumentWrapper::GetDisplayText() { // TODO(estade): implement better. - return UTF8ToUTF16(instrument_->descriptive_name()); + return instrument_->descriptive_name(); } void WalletInstrumentWrapper::FillFormField(AutofillField* field) { |