Commit fd95cbb9 authored by anthonyvd's avatar anthonyvd Committed by Commit bot

[Web Payments] Use shippingType to choose the Payment Sheet shipping strings.

BUG=700499

Review-Url: https://codereview.chromium.org/2742643004
Cr-Commit-Position: refs/heads/master@{#456207}
parent 4e8a5913
......@@ -15,7 +15,9 @@
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/strings/grit/components_strings.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font_list.h"
......@@ -246,4 +248,34 @@ std::unique_ptr<views::Label> CreateBoldLabel(const base::string16& text) {
return label;
}
base::string16 GetShippingAddressSectionString(
payments::mojom::PaymentShippingType shipping_type) {
switch (shipping_type) {
case payments::mojom::PaymentShippingType::DELIVERY:
return l10n_util::GetStringUTF16(IDS_PAYMENTS_DELIVERY_ADDRESS_LABEL);
case payments::mojom::PaymentShippingType::PICKUP:
return l10n_util::GetStringUTF16(IDS_PAYMENTS_PICKUP_ADDRESS_LABEL);
case payments::mojom::PaymentShippingType::SHIPPING:
return l10n_util::GetStringUTF16(IDS_PAYMENTS_SHIPPING_ADDRESS_LABEL);
}
// MSVC doesn't compile with only the above switch statement because it can't
// see that all control paths return a value.
return l10n_util::GetStringUTF16(IDS_PAYMENTS_SHIPPING_ADDRESS_LABEL);
}
base::string16 GetShippingOptionSectionString(
payments::mojom::PaymentShippingType shipping_type) {
switch (shipping_type) {
case payments::mojom::PaymentShippingType::DELIVERY:
return l10n_util::GetStringUTF16(IDS_PAYMENTS_DELIVERY_OPTION_LABEL);
case payments::mojom::PaymentShippingType::PICKUP:
return l10n_util::GetStringUTF16(IDS_PAYMENTS_PICKUP_OPTION_LABEL);
case payments::mojom::PaymentShippingType::SHIPPING:
return l10n_util::GetStringUTF16(IDS_PAYMENTS_SHIPPING_OPTION_LABEL);
}
// MSVC doesn't compile with only the above switch statement because it can't
// see that all control paths return a value.
return l10n_util::GetStringUTF16(IDS_PAYMENTS_SHIPPING_OPTION_LABEL);
}
} // namespace payments
......@@ -9,6 +9,7 @@
#include <string>
#include "base/strings/string16.h"
#include "components/payments/content/payment_request.mojom.h"
namespace autofill {
class AutofillProfile;
......@@ -88,6 +89,11 @@ std::unique_ptr<views::Border> CreatePaymentRequestRowBorder();
// Creates a label with a bold font.
std::unique_ptr<views::Label> CreateBoldLabel(const base::string16& text);
base::string16 GetShippingAddressSectionString(
payments::mojom::PaymentShippingType shipping_type);
base::string16 GetShippingOptionSectionString(
payments::mojom::PaymentShippingType shipping_type);
} // namespace payments
#endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_VIEWS_UTIL_H_
......@@ -414,7 +414,7 @@ PaymentSheetViewController::CreateShippingSectionContent() {
std::unique_ptr<views::Button> PaymentSheetViewController::CreateShippingRow() {
std::unique_ptr<views::Button> section = CreatePaymentSheetRow(
this,
l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_SHIPPING_SECTION_NAME),
GetShippingAddressSectionString(request()->options()->shipping_type),
CreateShippingSectionContent(), std::unique_ptr<views::View>(nullptr),
widest_name_column_view_width_);
section->set_tag(
......@@ -528,10 +528,8 @@ PaymentSheetViewController::CreateShippingOptionContent() {
std::unique_ptr<views::Button>
PaymentSheetViewController::CreateShippingOptionRow() {
// TODO(anthonyvd): Use the correct IDS_PAYMENTS_*_OPTION_LABEL string based
// on the data passed by the website.
std::unique_ptr<views::Button> section = CreatePaymentSheetRow(
this, l10n_util::GetStringUTF16(IDS_PAYMENTS_SHIPPING_OPTION_LABEL),
this, GetShippingOptionSectionString(request()->options()->shipping_type),
CreateShippingOptionContent(), std::unique_ptr<views::View>(nullptr),
widest_name_column_view_width_);
section->set_tag(static_cast<int>(
......
......@@ -145,6 +145,7 @@ class PaymentRequest : public mojom::PaymentRequest,
}
payments::mojom::PaymentDetails* details() { return details_.get(); }
payments::mojom::PaymentOptions* options() { return options_.get(); }
const std::vector<std::string>& supported_card_networks() {
return supported_card_networks_;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment