diff --git a/components/payments/core/payment_currency_amount.cc b/components/payments/core/payment_currency_amount.cc index 40ca4cb6ffba37..0eb7c228dd57e6 100644 --- a/components/payments/core/payment_currency_amount.cc +++ b/components/payments/core/payment_currency_amount.cc @@ -5,7 +5,6 @@ #include "components/payments/core/payment_currency_amount.h" #include "base/memory/ptr_util.h" -#include "base/strings/utf_string_conversions.h" #include "base/values.h" namespace payments { @@ -25,8 +24,7 @@ static const char kPaymentCurrencyAmountValue[] = "value"; PaymentCurrencyAmount::PaymentCurrencyAmount() // By default, the currency is defined by [ISO4217]. For example, USD for // US Dollars. - : currency_system( - base::ASCIIToUTF16(kPaymentCurrencyAmountCurrencySystemISO4217)) {} + : currency_system(kPaymentCurrencyAmountCurrencySystemISO4217) {} PaymentCurrencyAmount::~PaymentCurrencyAmount() = default; diff --git a/components/payments/core/payment_currency_amount.h b/components/payments/core/payment_currency_amount.h index 64cb24228df400..f35f60e560a40c 100644 --- a/components/payments/core/payment_currency_amount.h +++ b/components/payments/core/payment_currency_amount.h @@ -6,8 +6,7 @@ #define COMPONENTS_PAYMENTS_CORE_PAYMENT_CURRENCY_AMOUNT_H_ #include - -#include "base/strings/string16.h" +#include // C++ bindings for the PaymentRequest API PaymentCurrencyAmount. Conforms to // the following spec: @@ -39,14 +38,14 @@ class PaymentCurrencyAmount { // A currency identifier. The most common identifiers are three-letter // alphabetic codes as defined by ISO 4217 (for example, "USD" for US Dollars) // however any string is considered valid. - base::string16 currency; + std::string currency; // A string containing the decimal monetary value. - base::string16 value; + std::string value; // A URL that indicates the currency system that the currency identifier // belongs to. - base::string16 currency_system; + std::string currency_system; }; } // namespace payments diff --git a/components/payments/core/payment_currency_amount_unittest.cc b/components/payments/core/payment_currency_amount_unittest.cc index d227736784cd8f..bddca30e371210 100644 --- a/components/payments/core/payment_currency_amount_unittest.cc +++ b/components/payments/core/payment_currency_amount_unittest.cc @@ -4,7 +4,6 @@ #include "components/payments/core/payment_currency_amount.h" -#include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "testing/gtest/include/gtest/gtest.h" @@ -14,8 +13,8 @@ namespace payments { // dictionary. TEST(PaymentRequestTest, PaymentCurrencyAmountFromDictionaryValueSuccess) { PaymentCurrencyAmount expected; - expected.currency = base::ASCIIToUTF16("AUD"); - expected.value = base::ASCIIToUTF16("-438.23"); + expected.currency = "AUD"; + expected.value = "-438.23"; base::DictionaryValue amount_dict; amount_dict.SetString("currency", "AUD"); @@ -26,7 +25,7 @@ TEST(PaymentRequestTest, PaymentCurrencyAmountFromDictionaryValueSuccess) { EXPECT_EQ(expected, actual); - expected.currency_system = base::ASCIIToUTF16("urn:iso:std:iso:123456789"); + expected.currency_system = "urn:iso:std:iso:123456789"; amount_dict.SetString("currencySystem", "urn:iso:std:iso:123456789"); EXPECT_TRUE(actual.FromDictionaryValue(amount_dict)); EXPECT_EQ(expected, actual); @@ -57,18 +56,18 @@ TEST(PaymentRequestTest, PaymentCurrencyAmountEquality) { PaymentCurrencyAmount currency_amount2; EXPECT_EQ(currency_amount1, currency_amount2); - currency_amount1.currency = base::ASCIIToUTF16("HKD"); + currency_amount1.currency = "HKD"; EXPECT_NE(currency_amount1, currency_amount2); - currency_amount2.currency = base::ASCIIToUTF16("USD"); + currency_amount2.currency = "USD"; EXPECT_NE(currency_amount1, currency_amount2); - currency_amount2.currency = base::ASCIIToUTF16("HKD"); + currency_amount2.currency = "HKD"; EXPECT_EQ(currency_amount1, currency_amount2); - currency_amount1.value = base::ASCIIToUTF16("49.89"); + currency_amount1.value = "49.89"; EXPECT_NE(currency_amount1, currency_amount2); - currency_amount2.value = base::ASCIIToUTF16("49.99"); + currency_amount2.value = "49.99"; EXPECT_NE(currency_amount1, currency_amount2); - currency_amount2.value = base::ASCIIToUTF16("49.89"); + currency_amount2.value = "49.89"; EXPECT_EQ(currency_amount1, currency_amount2); } @@ -96,10 +95,9 @@ TEST(PaymentRequestTest, PopulatedCurrencyAmountDictionary) { expected_value.SetString("currencySystem", "urn:iso:std:iso:123456789"); PaymentCurrencyAmount payment_currency_amount; - payment_currency_amount.currency = base::ASCIIToUTF16("AUD"); - payment_currency_amount.value = base::ASCIIToUTF16("-438.23"); - payment_currency_amount.currency_system = - base::ASCIIToUTF16("urn:iso:std:iso:123456789"); + payment_currency_amount.currency = "AUD"; + payment_currency_amount.value = "-438.23"; + payment_currency_amount.currency_system = "urn:iso:std:iso:123456789"; EXPECT_TRUE( expected_value.Equals(payment_currency_amount.ToDictionaryValue().get())); diff --git a/components/payments/core/payment_details.h b/components/payments/core/payment_details.h index c65003382eda0a..3a4b4da244082c 100644 --- a/components/payments/core/payment_details.h +++ b/components/payments/core/payment_details.h @@ -8,7 +8,6 @@ #include #include -#include "base/strings/string16.h" #include "components/payments/core/payment_details_modifier.h" #include "components/payments/core/payment_item.h" #include "components/payments/core/payment_shipping_option.h" @@ -60,7 +59,7 @@ class PaymentDetails { // If non-empty, this is the error message the user agent should display to // the user when the payment request is updated using updateWith. - base::string16 error; + std::string error; }; } // namespace payments diff --git a/components/payments/core/payment_details_modifier.h b/components/payments/core/payment_details_modifier.h index 2bbd5c27256373..261f0010ee650f 100644 --- a/components/payments/core/payment_details_modifier.h +++ b/components/payments/core/payment_details_modifier.h @@ -6,9 +6,9 @@ #define COMPONENTS_PAYMENTS_CORE_PAYMENT_DETAILS_MODIFIER_H_ #include +#include #include -#include "base/strings/string16.h" #include "components/payments/core/payment_item.h" // C++ bindings for the PaymentRequest API PaymentDetailsModifier. Conforms to @@ -39,7 +39,7 @@ class PaymentDetailsModifier { // A sequence of payment method identifiers. The remaining fields in the // PaymentDetailsModifier apply only if the user selects a payment method // included in this sequence. - std::vector supported_methods; + std::vector supported_methods; // This value overrides the total field in the PaymentDetails dictionary for // the payment method identifiers in the supportedMethods field. diff --git a/components/payments/core/payment_details_modifier_unittest.cc b/components/payments/core/payment_details_modifier_unittest.cc index 4035a33e179e18..f10447d40dbd90 100644 --- a/components/payments/core/payment_details_modifier_unittest.cc +++ b/components/payments/core/payment_details_modifier_unittest.cc @@ -59,13 +59,11 @@ TEST(PaymentRequestTest, PopulatedDetailsModifierDictionary) { expected_value.SetDictionary("total", std::move(item_dict)); PaymentDetailsModifier payment_detials_modififer; - payment_detials_modififer.supported_methods.push_back( - base::ASCIIToUTF16("visa")); - payment_detials_modififer.supported_methods.push_back( - base::ASCIIToUTF16("amex")); - payment_detials_modififer.total.label = base::ASCIIToUTF16("Gratuity"); - payment_detials_modififer.total.amount.currency = base::ASCIIToUTF16("USD"); - payment_detials_modififer.total.amount.value = base::ASCIIToUTF16("139.99"); + payment_detials_modififer.supported_methods.push_back("visa"); + payment_detials_modififer.supported_methods.push_back("amex"); + payment_detials_modififer.total.label = "Gratuity"; + payment_detials_modififer.total.amount.currency = "USD"; + payment_detials_modififer.total.amount.value = "139.99"; EXPECT_TRUE(expected_value.Equals( payment_detials_modififer.ToDictionaryValue().get())); @@ -80,27 +78,27 @@ TEST(PaymentRequestTest, PaymentDetailsModifierEquality) { PaymentDetailsModifier details_modifier2; EXPECT_EQ(details_modifier1, details_modifier2); - std::vector supported_methods1; - supported_methods1.push_back(base::ASCIIToUTF16("China UnionPay")); - supported_methods1.push_back(base::ASCIIToUTF16("BobPay")); + std::vector supported_methods1; + supported_methods1.push_back("China UnionPay"); + supported_methods1.push_back("BobPay"); details_modifier1.supported_methods = supported_methods1; EXPECT_NE(details_modifier1, details_modifier2); - std::vector supported_methods2; - supported_methods2.push_back(base::ASCIIToUTF16("BobPay")); + std::vector supported_methods2; + supported_methods2.push_back("BobPay"); details_modifier2.supported_methods = supported_methods2; EXPECT_NE(details_modifier1, details_modifier2); details_modifier2.supported_methods = supported_methods1; EXPECT_EQ(details_modifier1, details_modifier2); - details_modifier1.total.label = base::ASCIIToUTF16("Total"); + details_modifier1.total.label = "Total"; EXPECT_NE(details_modifier1, details_modifier2); - details_modifier2.total.label = base::ASCIIToUTF16("Gratuity"); + details_modifier2.total.label = "Gratuity"; EXPECT_NE(details_modifier1, details_modifier2); - details_modifier2.total.label = base::ASCIIToUTF16("Total"); + details_modifier2.total.label = "Total"; EXPECT_EQ(details_modifier1, details_modifier2); PaymentItem payment_item; - payment_item.label = base::ASCIIToUTF16("Tax"); + payment_item.label = "Tax"; std::vector display_items1; display_items1.push_back(payment_item); details_modifier1.additional_display_items = display_items1; diff --git a/components/payments/core/payment_details_unittest.cc b/components/payments/core/payment_details_unittest.cc index a520027e432631..660aab78ee71ab 100644 --- a/components/payments/core/payment_details_unittest.cc +++ b/components/payments/core/payment_details_unittest.cc @@ -6,7 +6,6 @@ #include -#include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "testing/gtest/include/gtest/gtest.h" @@ -15,7 +14,7 @@ namespace payments { // Tests the success case when populating a PaymentDetails from a dictionary. TEST(PaymentRequestTest, PaymentDetailsFromDictionaryValueSuccess) { PaymentDetails expected; - expected.error = base::ASCIIToUTF16("Error in details"); + expected.error = "Error in details"; base::DictionaryValue details_dict; details_dict.SetString("error", "Error in details"); @@ -24,9 +23,9 @@ TEST(PaymentRequestTest, PaymentDetailsFromDictionaryValueSuccess) { actual.FromDictionaryValue(details_dict, /*requires_total=*/false)); EXPECT_EQ(expected, actual); - expected.total.label = base::ASCIIToUTF16("TOTAL"); - expected.total.amount.currency = base::ASCIIToUTF16("GBP"); - expected.total.amount.value = base::ASCIIToUTF16("6.66"); + expected.total.label = "TOTAL"; + expected.total.amount.currency = "GBP"; + expected.total.amount.value = "6.66"; std::unique_ptr total_dict(new base::DictionaryValue); total_dict->SetString("label", "TOTAL"); @@ -48,10 +47,10 @@ TEST(PaymentRequestTest, PaymentDetailsFromDictionaryValueSuccess) { // Tests the failure case when populating a PaymentDetails from a dictionary. TEST(PaymentRequestTest, PaymentDetailsFromDictionaryValueFailure) { PaymentDetails expected; - expected.total.label = base::ASCIIToUTF16("TOTAL"); - expected.total.amount.currency = base::ASCIIToUTF16("GBP"); - expected.total.amount.value = base::ASCIIToUTF16("6.66"); - expected.error = base::ASCIIToUTF16("Error in details"); + expected.total.label = "TOTAL"; + expected.total.amount.currency = "GBP"; + expected.total.amount.value = "6.66"; + expected.error = "Error in details"; base::DictionaryValue details_dict; details_dict.SetString("error", "Error in details"); @@ -77,22 +76,22 @@ TEST(PaymentRequestTest, PaymentDetailsEquality) { details2.id = details1.id; EXPECT_EQ(details1, details2); - details1.total.label = base::ASCIIToUTF16("Total"); + details1.total.label = "Total"; EXPECT_NE(details1, details2); - details2.total.label = base::ASCIIToUTF16("Shipping"); + details2.total.label = "Shipping"; EXPECT_NE(details1, details2); - details2.total.label = base::ASCIIToUTF16("Total"); + details2.total.label = "Total"; EXPECT_EQ(details1, details2); - details1.error = base::ASCIIToUTF16("Foo"); + details1.error = "Foo"; EXPECT_NE(details1, details2); - details2.error = base::ASCIIToUTF16("Bar"); + details2.error = "Bar"; EXPECT_NE(details1, details2); - details2.error = base::ASCIIToUTF16("Foo"); + details2.error = "Foo"; EXPECT_EQ(details1, details2); PaymentItem payment_item; - payment_item.label = base::ASCIIToUTF16("Tax"); + payment_item.label = "Tax"; std::vector display_items1; display_items1.push_back(payment_item); details1.display_items = display_items1; @@ -106,7 +105,7 @@ TEST(PaymentRequestTest, PaymentDetailsEquality) { EXPECT_EQ(details1, details2); PaymentShippingOption shipping_option; - shipping_option.label = base::ASCIIToUTF16("Overnight"); + shipping_option.label = "Overnight"; std::vector shipping_options1; shipping_options1.push_back(shipping_option); details1.shipping_options = shipping_options1; @@ -120,15 +119,10 @@ TEST(PaymentRequestTest, PaymentDetailsEquality) { EXPECT_EQ(details1, details2); PaymentDetailsModifier details_modifier; - details_modifier.total.label = base::ASCIIToUTF16("Total"); - std::vector details_modifiers1; - details_modifiers1.push_back(details_modifier); - details1.modifiers = details_modifiers1; + details_modifier.total.label = "Total"; + details1.modifiers.push_back(details_modifier); EXPECT_NE(details1, details2); - std::vector details_modifiers2; - details2.modifiers = details_modifiers2; - EXPECT_NE(details1, details2); - details2.modifiers = details_modifiers1; + details2.modifiers.push_back(details_modifier); EXPECT_EQ(details1, details2); } diff --git a/components/payments/core/payment_item.h b/components/payments/core/payment_item.h index f4b6b4169e8c0b..0a4776a0034065 100644 --- a/components/payments/core/payment_item.h +++ b/components/payments/core/payment_item.h @@ -6,8 +6,8 @@ #define COMPONENTS_PAYMENTS_CORE_PAYMENT_ITEM_H_ #include +#include -#include "base/strings/string16.h" #include "components/payments/core/payment_currency_amount.h" // C++ bindings for the PaymentRequest API PaymentItem. Conforms to the @@ -39,7 +39,7 @@ class PaymentItem { std::unique_ptr ToDictionaryValue() const; // A human-readable description of the item. - base::string16 label; + std::string label; // The monetary amount for the item. PaymentCurrencyAmount amount; diff --git a/components/payments/core/payment_item_unittest.cc b/components/payments/core/payment_item_unittest.cc index 78a1b2159180bf..a2fe8b83efda87 100644 --- a/components/payments/core/payment_item_unittest.cc +++ b/components/payments/core/payment_item_unittest.cc @@ -14,9 +14,9 @@ namespace payments { // Tests the success case when populating a PaymentItem from a dictionary. TEST(PaymentRequestTest, PaymentItemFromDictionaryValueSuccess) { PaymentItem expected; - expected.label = base::ASCIIToUTF16("Payment Total"); - expected.amount.currency = base::ASCIIToUTF16("NZD"); - expected.amount.value = base::ASCIIToUTF16("2,242,093.00"); + expected.label = "Payment Total"; + expected.amount.currency = "NZD"; + expected.amount.value = "2,242,093.00"; base::DictionaryValue item_dict; item_dict.SetString("label", "Payment Total"); @@ -59,18 +59,18 @@ TEST(PaymentRequestTest, PaymentItemEquality) { PaymentItem item2; EXPECT_EQ(item1, item2); - item1.label = base::ASCIIToUTF16("Subtotal"); + item1.label = "Subtotal"; EXPECT_NE(item1, item2); - item2.label = base::ASCIIToUTF16("Total"); + item2.label = "Total"; EXPECT_NE(item1, item2); - item2.label = base::ASCIIToUTF16("Subtotal"); + item2.label = "Subtotal"; EXPECT_EQ(item1, item2); - item1.amount.value = base::ASCIIToUTF16("104.34"); + item1.amount.value = "104.34"; EXPECT_NE(item1, item2); - item2.amount.value = base::ASCIIToUTF16("104"); + item2.amount.value = "104"; EXPECT_NE(item1, item2); - item2.amount.value = base::ASCIIToUTF16("104.34"); + item2.amount.value = "104.34"; EXPECT_EQ(item1, item2); item1.pending = true; @@ -110,9 +110,9 @@ TEST(PaymentRequestTest, PopulatedPaymentItemDictionary) { expected_value.SetBoolean("pending", true); PaymentItem payment_item; - payment_item.label = base::ASCIIToUTF16("Payment Total"); - payment_item.amount.currency = base::ASCIIToUTF16("NZD"); - payment_item.amount.value = base::ASCIIToUTF16("2,242,093.00"); + payment_item.label = "Payment Total"; + payment_item.amount.currency = "NZD"; + payment_item.amount.value = "2,242,093.00"; payment_item.pending = true; EXPECT_TRUE(expected_value.Equals(payment_item.ToDictionaryValue().get())); diff --git a/components/payments/core/payment_shipping_option.h b/components/payments/core/payment_shipping_option.h index def7b53ad4bf21..676b07b9f29fab 100644 --- a/components/payments/core/payment_shipping_option.h +++ b/components/payments/core/payment_shipping_option.h @@ -34,11 +34,11 @@ class PaymentShippingOption { // An identifier used to reference this PaymentShippingOption. It is unique // for a given PaymentRequest. - base::string16 id; + std::string id; // A human-readable description of the item. The user agent should use this // string to display the shipping option to the user. - base::string16 label; + std::string label; // A PaymentCurrencyAmount containing the monetary amount for the option. PaymentCurrencyAmount amount; diff --git a/components/payments/core/payment_shipping_option_unittest.cc b/components/payments/core/payment_shipping_option_unittest.cc index ea423d79940c3c..e124ffc5eb131e 100644 --- a/components/payments/core/payment_shipping_option_unittest.cc +++ b/components/payments/core/payment_shipping_option_unittest.cc @@ -16,10 +16,10 @@ namespace payments { // dictionary. TEST(PaymentRequestTest, PaymentShippingOptionFromDictionaryValueSuccess) { PaymentShippingOption expected; - expected.id = base::ASCIIToUTF16("123"); - expected.label = base::ASCIIToUTF16("Ground Shipping"); - expected.amount.currency = base::ASCIIToUTF16("BRL"); - expected.amount.value = base::ASCIIToUTF16("4,000.32"); + expected.id = "123"; + expected.label = "Ground Shipping"; + expected.amount.currency = "BRL"; + expected.amount.value = "4,000.32"; expected.selected = true; base::DictionaryValue shipping_option_dict; @@ -41,10 +41,10 @@ TEST(PaymentRequestTest, PaymentShippingOptionFromDictionaryValueSuccess) { // dictionary. TEST(PaymentRequestTest, PaymentShippingOptionFromDictionaryValueFailure) { PaymentShippingOption expected; - expected.id = base::ASCIIToUTF16("123"); - expected.label = base::ASCIIToUTF16("Ground Shipping"); - expected.amount.currency = base::ASCIIToUTF16("BRL"); - expected.amount.value = base::ASCIIToUTF16("4,000.32"); + expected.id = "123"; + expected.label = "Ground Shipping"; + expected.amount.currency = "BRL"; + expected.amount.value = "4,000.32"; expected.selected = true; PaymentShippingOption actual; @@ -80,25 +80,25 @@ TEST(PaymentRequestTest, PaymentShippingOptionEquality) { PaymentShippingOption shipping_option2; EXPECT_EQ(shipping_option1, shipping_option2); - shipping_option1.id = base::ASCIIToUTF16("a8df2"); + shipping_option1.id = "a8df2"; EXPECT_NE(shipping_option1, shipping_option2); - shipping_option2.id = base::ASCIIToUTF16("k42jk"); + shipping_option2.id = "k42jk"; EXPECT_NE(shipping_option1, shipping_option2); - shipping_option2.id = base::ASCIIToUTF16("a8df2"); + shipping_option2.id = "a8df2"; EXPECT_EQ(shipping_option1, shipping_option2); - shipping_option1.label = base::ASCIIToUTF16("Overnight"); + shipping_option1.label = "Overnight"; EXPECT_NE(shipping_option1, shipping_option2); - shipping_option2.label = base::ASCIIToUTF16("Ground"); + shipping_option2.label = "Ground"; EXPECT_NE(shipping_option1, shipping_option2); - shipping_option2.label = base::ASCIIToUTF16("Overnight"); + shipping_option2.label = "Overnight"; EXPECT_EQ(shipping_option1, shipping_option2); - shipping_option1.amount.currency = base::ASCIIToUTF16("AUD"); + shipping_option1.amount.currency = "AUD"; EXPECT_NE(shipping_option1, shipping_option2); - shipping_option2.amount.currency = base::ASCIIToUTF16("HKD"); + shipping_option2.amount.currency = "HKD"; EXPECT_NE(shipping_option1, shipping_option2); - shipping_option2.amount.currency = base::ASCIIToUTF16("AUD"); + shipping_option2.amount.currency = "AUD"; EXPECT_EQ(shipping_option1, shipping_option2); shipping_option1.selected = true; diff --git a/ios/chrome/browser/payments/payment_request.mm b/ios/chrome/browser/payments/payment_request.mm index 5601854856f26f..30439c82b65526 100644 --- a/ios/chrome/browser/payments/payment_request.mm +++ b/ios/chrome/browser/payments/payment_request.mm @@ -227,9 +227,8 @@ CurrencyFormatter* PaymentRequest::GetOrCreateCurrencyFormatter() { if (!currency_formatter_) { currency_formatter_.reset(new CurrencyFormatter( - base::UTF16ToASCII(web_payment_request_.details.total.amount.currency), - base::UTF16ToASCII( - web_payment_request_.details.total.amount.currency_system), + web_payment_request_.details.total.amount.currency, + web_payment_request_.details.total.amount.currency_system, GetApplicationLocale())); } return currency_formatter_.get(); diff --git a/ios/chrome/browser/payments/payment_request_test_util.mm b/ios/chrome/browser/payments/payment_request_test_util.mm index bd1c44eb884b23..4b3481740971b5 100644 --- a/ios/chrome/browser/payments/payment_request_test_util.mm +++ b/ios/chrome/browser/payments/payment_request_test_util.mm @@ -22,26 +22,26 @@ method_datum.supported_methods.push_back("visa"); method_datum.supported_methods.push_back("amex"); web_payment_request.method_data.push_back(method_datum); - web_payment_request.details.total.label = base::ASCIIToUTF16("Total"); - web_payment_request.details.total.amount.value = base::ASCIIToUTF16("1.00"); - web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("USD"); + web_payment_request.details.total.label = "Total"; + web_payment_request.details.total.amount.value = "1.00"; + web_payment_request.details.total.amount.currency = "USD"; payments::PaymentItem display_item; - display_item.label = base::ASCIIToUTF16("Subtotal"); - display_item.amount.value = base::ASCIIToUTF16("1.00"); - display_item.amount.currency = base::ASCIIToUTF16("USD"); + display_item.label = "Subtotal"; + display_item.amount.value = "1.00"; + display_item.amount.currency = "USD"; web_payment_request.details.display_items.push_back(display_item); payments::PaymentShippingOption shipping_option; - shipping_option.id = base::ASCIIToUTF16("123456"); - shipping_option.label = base::ASCIIToUTF16("1-Day"); - shipping_option.amount.value = base::ASCIIToUTF16("0.99"); - shipping_option.amount.currency = base::ASCIIToUTF16("USD"); + shipping_option.id = "123456"; + shipping_option.label = "1-Day"; + shipping_option.amount.value = "0.99"; + shipping_option.amount.currency = "USD"; shipping_option.selected = true; web_payment_request.details.shipping_options.push_back(shipping_option); payments::PaymentShippingOption shipping_option2; - shipping_option2.id = base::ASCIIToUTF16("654321"); - shipping_option2.label = base::ASCIIToUTF16("10-Days"); - shipping_option2.amount.value = base::ASCIIToUTF16("0.01"); - shipping_option2.amount.currency = base::ASCIIToUTF16("USD"); + shipping_option2.id = "654321"; + shipping_option2.label = "10-Days"; + shipping_option2.amount.value = "0.01"; + shipping_option2.amount.currency = "USD"; shipping_option2.selected = false; web_payment_request.details.shipping_options.push_back(shipping_option2); web_payment_request.options.request_shipping = true; diff --git a/ios/chrome/browser/payments/payment_request_unittest.mm b/ios/chrome/browser/payments/payment_request_unittest.mm index 70c89863fa8a42..2d278e22e9935d 100644 --- a/ios/chrome/browser/payments/payment_request_unittest.mm +++ b/ios/chrome/browser/payments/payment_request_unittest.mm @@ -59,7 +59,7 @@ PaymentDetails CreateDetailsWithShippingOption() { PaymentDetails details; std::vector shipping_options; PaymentShippingOption option1; - option1.id = base::UTF8ToUTF16("option:1"); + option1.id = "option:1"; option1.selected = true; shipping_options.push_back(std::move(option1)); details.shipping_options = std::move(shipping_options); @@ -92,7 +92,7 @@ PaymentDetails CreateDetailsWithShippingOption() { web::PaymentRequest web_payment_request; autofill::TestPersonalDataManager personal_data_manager; - web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("USD"); + web_payment_request.details.total.amount.currency = "USD"; TestPaymentRequest payment_request1(web_payment_request, chrome_browser_state_.get(), &web_state_, &personal_data_manager); @@ -102,7 +102,7 @@ TestPaymentRequest payment_request1(web_payment_request, EXPECT_EQ(base::UTF8ToUTF16("$55.00"), currency_formatter->Format("55.00")); EXPECT_EQ("USD", currency_formatter->formatted_currency_code()); - web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("JPY"); + web_payment_request.details.total.amount.currency = "JPY"; TestPaymentRequest payment_request2(web_payment_request, chrome_browser_state_.get(), &web_state_, &personal_data_manager); @@ -111,9 +111,8 @@ TestPaymentRequest payment_request2(web_payment_request, EXPECT_EQ(base::UTF8ToUTF16("¥55"), currency_formatter->Format("55.00")); EXPECT_EQ("JPY", currency_formatter->formatted_currency_code()); - web_payment_request.details.total.amount.currency_system = - base::ASCIIToUTF16("NOT_ISO4217"); - web_payment_request.details.total.amount.currency = base::ASCIIToUTF16("USD"); + web_payment_request.details.total.amount.currency_system = "NOT_ISO4217"; + web_payment_request.details.total.amount.currency = "USD"; TestPaymentRequest payment_request3(web_payment_request, chrome_browser_state_.get(), &web_state_, &personal_data_manager); @@ -378,15 +377,15 @@ TestPaymentRequest payment_request(web_payment_request, PaymentDetails details; std::vector shipping_options; PaymentShippingOption option1; - option1.id = base::UTF8ToUTF16("option:1"); + option1.id = "option:1"; option1.selected = false; shipping_options.push_back(std::move(option1)); PaymentShippingOption option2; - option2.id = base::UTF8ToUTF16("option:2"); + option2.id = "option:2"; option2.selected = true; shipping_options.push_back(std::move(option2)); PaymentShippingOption option3; - option3.id = base::UTF8ToUTF16("option:3"); + option3.id = "option:3"; option3.selected = true; shipping_options.push_back(std::move(option3)); details.shipping_options = std::move(shipping_options); @@ -396,8 +395,7 @@ TestPaymentRequest payment_request(web_payment_request, chrome_browser_state_.get(), &web_state_, &personal_data_manager); // The last one marked "selected" should be selected. - EXPECT_EQ(base::UTF8ToUTF16("option:3"), - payment_request.selected_shipping_option()->id); + EXPECT_EQ("option:3", payment_request.selected_shipping_option()->id); // Simulate an update that no longer has any shipping options. There is no // longer a selected shipping option. diff --git a/ios/chrome/browser/payments/payment_request_util.mm b/ios/chrome/browser/payments/payment_request_util.mm index 83b1eb067ebb63..fcb81f14ceabc1 100644 --- a/ios/chrome/browser/payments/payment_request_util.mm +++ b/ios/chrome/browser/payments/payment_request_util.mm @@ -98,7 +98,7 @@ NSString* GetShippingAddressSelectorErrorMessage( const payments::PaymentRequest& payment_request) { if (!payment_request.payment_details().error.empty()) - return base::SysUTF16ToNSString(payment_request.payment_details().error); + return base::SysUTF8ToNSString(payment_request.payment_details().error); switch (payment_request.shipping_type()) { case payments::PaymentShippingType::SHIPPING: @@ -116,7 +116,7 @@ NSString* GetShippingOptionSelectorErrorMessage( const payments::PaymentRequest& payment_request) { if (!payment_request.payment_details().error.empty()) - return base::SysUTF16ToNSString(payment_request.payment_details().error); + return base::SysUTF8ToNSString(payment_request.payment_details().error); switch (payment_request.shipping_type()) { case payments::PaymentShippingType::SHIPPING: diff --git a/ios/chrome/browser/ui/payments/js_payment_request_manager.mm b/ios/chrome/browser/ui/payments/js_payment_request_manager.mm index 180cad97d9acb5..4bb5e2b989aa42 100644 --- a/ios/chrome/browser/ui/payments/js_payment_request_manager.mm +++ b/ios/chrome/browser/ui/payments/js_payment_request_manager.mm @@ -145,7 +145,7 @@ - (void)updateShippingOption: [NSString stringWithFormat: @"__gCrWeb['paymentRequestManager']." @"updateShippingOptionAndDispatchEvent(%@)", - JSONEscape(base::SysUTF16ToNSString(shippingOption.id))]; + JSONEscape(base::SysUTF8ToNSString(shippingOption.id))]; [self executeScript:script completionHandler:completionHanlder]; } diff --git a/ios/chrome/browser/ui/payments/payment_items_display_mediator.mm b/ios/chrome/browser/ui/payments/payment_items_display_mediator.mm index e9095dbe77dfae..bcecf1ca4d3f74 100644 --- a/ios/chrome/browser/ui/payments/payment_items_display_mediator.mm +++ b/ios/chrome/browser/ui/payments/payment_items_display_mediator.mm @@ -57,14 +57,14 @@ - (BOOL)canPay { - (CollectionViewItem*)totalItem { PriceItem* totalItem = [[PriceItem alloc] init]; totalItem.item = - base::SysUTF16ToNSString(_paymentRequest->payment_details().total.label); + base::SysUTF8ToNSString(_paymentRequest->payment_details().total.label); payments::CurrencyFormatter* currencyFormatter = _paymentRequest->GetOrCreateCurrencyFormatter(); totalItem.price = base::SysUTF16ToNSString(l10n_util::GetStringFUTF16( IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, base::UTF8ToUTF16(currencyFormatter->formatted_currency_code()), - currencyFormatter->Format(base::UTF16ToASCII( - _paymentRequest->payment_details().total.amount.value)))); + currencyFormatter->Format( + _paymentRequest->payment_details().total.amount.value))); return totalItem; } @@ -76,11 +76,11 @@ - (CollectionViewItem*)totalItem { for (const auto& paymentItem : paymentItems) { PriceItem* item = [[PriceItem alloc] init]; - item.item = base::SysUTF16ToNSString(paymentItem.label); + item.item = base::SysUTF8ToNSString(paymentItem.label); payments::CurrencyFormatter* currencyFormatter = _paymentRequest->GetOrCreateCurrencyFormatter(); - item.price = base::SysUTF16ToNSString(currencyFormatter->Format( - base::UTF16ToASCII(paymentItem.amount.value))); + item.price = base::SysUTF16ToNSString( + currencyFormatter->Format(paymentItem.amount.value)); [lineItems addObject:item]; } diff --git a/ios/chrome/browser/ui/payments/payment_request_coordinator_unittest.mm b/ios/chrome/browser/ui/payments/payment_request_coordinator_unittest.mm index 41377afd70567b..bc865c6a368636 100644 --- a/ios/chrome/browser/ui/payments/payment_request_coordinator_unittest.mm +++ b/ios/chrome/browser/ui/payments/payment_request_coordinator_unittest.mm @@ -185,10 +185,10 @@ id delegate_mock([[PaymentRequestCoordinatorDelegateMock alloc] [coordinator setPaymentRequest:payment_request()]; payments::PaymentShippingOption shipping_option; - shipping_option.id = base::ASCIIToUTF16("123456"); - shipping_option.label = base::ASCIIToUTF16("1-Day"); - shipping_option.amount.value = base::ASCIIToUTF16("0.99"); - shipping_option.amount.currency = base::ASCIIToUTF16("USD"); + shipping_option.id = "123456"; + shipping_option.label = "1-Day"; + shipping_option.amount.value = "0.99"; + shipping_option.amount.currency = "USD"; // Mock the coordinator delegate. id delegate = [OCMockObject diff --git a/ios/chrome/browser/ui/payments/payment_request_mediator.mm b/ios/chrome/browser/ui/payments/payment_request_mediator.mm index 9a86bbb4546522..307c44865e6b0a 100644 --- a/ios/chrome/browser/ui/payments/payment_request_mediator.mm +++ b/ios/chrome/browser/ui/payments/payment_request_mediator.mm @@ -107,15 +107,15 @@ - (BOOL)requestContactInfo { - (CollectionViewItem*)paymentSummaryItem { PriceItem* item = [[PriceItem alloc] init]; - item.item = base::SysUTF16ToNSString( + item.item = base::SysUTF8ToNSString( self.paymentRequest->payment_details().total.label); payments::CurrencyFormatter* currencyFormatter = self.paymentRequest->GetOrCreateCurrencyFormatter(); item.price = base::SysUTF16ToNSString(l10n_util::GetStringFUTF16( IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, base::UTF8ToUTF16(currencyFormatter->formatted_currency_code()), - currencyFormatter->Format(base::UTF16ToASCII( - self.paymentRequest->payment_details().total.amount.value)))); + currencyFormatter->Format( + self.paymentRequest->payment_details().total.amount.value))); item.notification = self.totalValueChanged ? l10n_util::GetNSString(IDS_PAYMENTS_UPDATED_LABEL) : nil; @@ -161,11 +161,11 @@ - (CollectionViewItem*)shippingOptionItem { self.paymentRequest->selected_shipping_option(); if (option) { PaymentsTextItem* item = [[PaymentsTextItem alloc] init]; - item.text = base::SysUTF16ToNSString(option->label); + item.text = base::SysUTF8ToNSString(option->label); payments::CurrencyFormatter* currencyFormatter = self.paymentRequest->GetOrCreateCurrencyFormatter(); item.detailText = base::SysUTF16ToNSString( - currencyFormatter->Format(base::UTF16ToASCII(option->amount.value))); + currencyFormatter->Format(option->amount.value)); item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator; return item; } diff --git a/ios/chrome/browser/ui/payments/shipping_option_selection_mediator.mm b/ios/chrome/browser/ui/payments/shipping_option_selection_mediator.mm index c75af2956e4a4c..216e8c690f7d10 100644 --- a/ios/chrome/browser/ui/payments/shipping_option_selection_mediator.mm +++ b/ios/chrome/browser/ui/payments/shipping_option_selection_mediator.mm @@ -99,11 +99,11 @@ - (void)loadItems { payments::PaymentShippingOption* shippingOption = shippingOptions[index]; DCHECK(shippingOption); PaymentsTextItem* item = [[PaymentsTextItem alloc] init]; - item.text = base::SysUTF16ToNSString(shippingOption->label); + item.text = base::SysUTF8ToNSString(shippingOption->label); payments::CurrencyFormatter* currencyFormatter = _paymentRequest->GetOrCreateCurrencyFormatter(); - item.detailText = base::SysUTF16ToNSString(currencyFormatter->Format( - base::UTF16ToASCII(shippingOption->amount.value))); + item.detailText = base::SysUTF16ToNSString( + currencyFormatter->Format(shippingOption->amount.value)); if (_paymentRequest->selected_shipping_option() == shippingOption) _selectedItemIndex = index; diff --git a/ios/web/payments/payment_request.cc b/ios/web/payments/payment_request.cc index 83baf6354240ba..9ee95fa9dc74f5 100644 --- a/ios/web/payments/payment_request.cc +++ b/ios/web/payments/payment_request.cc @@ -6,7 +6,6 @@ #include "base/json/json_reader.h" #include "base/memory/ptr_util.h" -#include "base/strings/utf_string_conversions.h" #include "base/values.h" namespace { @@ -72,13 +71,11 @@ bool PaymentOptions::FromDictionaryValue(const base::DictionaryValue& value) { value.GetBoolean(kPaymentOptionsRequestShipping, &this->request_shipping); - base::string16 shipping_type; + std::string shipping_type; value.GetString(kPaymentOptionsShippingType, &shipping_type); - if (shipping_type == - base::ASCIIToUTF16(kPaymentOptionsShippingTypeDelivery)) { + if (shipping_type == kPaymentOptionsShippingTypeDelivery) { this->shipping_type = payments::PaymentShippingType::DELIVERY; - } else if (shipping_type == - base::ASCIIToUTF16(kPaymentOptionsShippingTypePickup)) { + } else if (shipping_type == kPaymentOptionsShippingTypePickup) { this->shipping_type = payments::PaymentShippingType::PICKUP; } else { this->shipping_type = payments::PaymentShippingType::SHIPPING; diff --git a/ios/web/payments/payment_request_unittest.cc b/ios/web/payments/payment_request_unittest.cc index 9c2a17f5857194..efe7e6fa66c003 100644 --- a/ios/web/payments/payment_request_unittest.cc +++ b/ios/web/payments/payment_request_unittest.cc @@ -66,10 +66,10 @@ TEST(PaymentRequestTest, ParsingFullyPopulatedRequestDictionarySucceeds) { // Add the expected values to expected_request. expected_request.payment_request_id = "123456789"; expected_request.details.id = "12345"; - expected_request.details.total.label = base::ASCIIToUTF16("TOTAL"); - expected_request.details.total.amount.currency = base::ASCIIToUTF16("GBP"); - expected_request.details.total.amount.value = base::ASCIIToUTF16("6.66"); - expected_request.details.error = base::ASCIIToUTF16("Error in details"); + expected_request.details.total.label = "TOTAL"; + expected_request.details.total.amount.currency = "GBP"; + expected_request.details.total.amount.value = "6.66"; + expected_request.details.error = "Error in details"; payments::PaymentMethodData method_data; std::vector supported_methods; @@ -213,7 +213,7 @@ TEST(PaymentRequestTest, PopulatedResponseDictionary) { payment_response.shipping_address = base::MakeUnique(); payment_response.shipping_address->postal_code = base::ASCIIToUTF16("94115"); - payment_response.shipping_option = base::ASCIIToUTF16("666"); + payment_response.shipping_option = "666"; payment_response.payer_name = base::ASCIIToUTF16("Jane Doe"); payment_response.payer_email = base::ASCIIToUTF16("jane@example.com"); payment_response.payer_phone = base::ASCIIToUTF16("1234-567-890"); @@ -287,11 +287,11 @@ TEST(PaymentRequestTest, PaymentRequestEquality) { request2.shipping_address = address1; EXPECT_EQ(request1, request2); - request1.shipping_option = base::ASCIIToUTF16("2-Day"); + request1.shipping_option = "2-Day"; EXPECT_NE(request1, request2); - request2.shipping_option = base::ASCIIToUTF16("3-Day"); + request2.shipping_option = "3-Day"; EXPECT_NE(request1, request2); - request2.shipping_option = base::ASCIIToUTF16("2-Day"); + request2.shipping_option = "2-Day"; EXPECT_EQ(request1, request2); payments::PaymentMethodData method_datum; @@ -307,11 +307,11 @@ TEST(PaymentRequestTest, PaymentRequestEquality) { EXPECT_EQ(request1, request2); payments::PaymentDetails details1; - details1.total.label = base::ASCIIToUTF16("Total"); + details1.total.label = "Total"; request1.details = details1; EXPECT_NE(request1, request2); payments::PaymentDetails details2; - details2.total.amount.value = base::ASCIIToUTF16("0.01"); + details2.total.amount.value = "0.01"; request2.details = details2; EXPECT_NE(request1, request2); request2.details = details1; diff --git a/ios/web/public/payments/payment_request.h b/ios/web/public/payments/payment_request.h index 9db32a73c2308c..19e9dd4f23aff3 100644 --- a/ios/web/public/payments/payment_request.h +++ b/ios/web/public/payments/payment_request.h @@ -96,7 +96,7 @@ class PaymentRequest { // Properties set in order to communicate user choices back to the page. payments::PaymentAddress shipping_address; - base::string16 shipping_option; + std::string shipping_option; // Properties set via the constructor for communicating from the page to the // browser UI. @@ -137,7 +137,7 @@ class PaymentResponse { // If the request_shipping flag was set to true in the PaymentOptions passed // to the PaymentRequest constructor, this will be the id attribute of the // selected shipping option. - base::string16 shipping_option; + std::string shipping_option; // If the request_payer_name flag was set to true in the PaymentOptions passed // to the PaymentRequest constructor, this will be the name provided by the