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

Unified Diff: chrome/browser/ui/views/payments/payment_sheet_view_controller.cc

Issue 2789093002: [Payments] Desktop: implement shipping address/option change (Closed)
Patch Set: compile fix Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/payment_sheet_view_controller.cc
diff --git a/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc b/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc
index 073718c8a63fd05d1ac47608b930a8b66e30bc6f..0d5cd6f760989a6b15df457aa9dc1188d8265269 100644
--- a/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc
+++ b/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc
@@ -194,13 +194,19 @@ PaymentSheetViewController::PaymentSheetViewController(
: PaymentRequestSheetController(spec, state, dialog),
pay_button_(nullptr),
widest_name_column_view_width_(ComputeWidestNameColumnViewWidth()) {
+ spec->AddObserver(this);
state->AddObserver(this);
}
PaymentSheetViewController::~PaymentSheetViewController() {
+ spec()->RemoveObserver(this);
state()->RemoveObserver(this);
}
+void PaymentSheetViewController::OnSpecUpdated() {
+ UpdateContentView();
+}
+
void PaymentSheetViewController::OnSelectedInformationChanged() {
UpdatePayButtonState(state()->is_ready_to_pay());
UpdateContentView();
@@ -240,8 +246,14 @@ void PaymentSheetViewController::FillContentView(views::View* content_view) {
if (spec()->request_shipping()) {
layout->StartRow(0, 0);
layout->AddView(CreateShippingRow().release());
- layout->StartRow(0, 0);
- layout->AddView(CreateShippingOptionRow().release());
+ // It's possible for requestShipping to be true and for there to be no
+ // shipping options yet (they will come in updateWith).
+ // TODO(crbug.com/707353): Put a better placeholder row, instead of no row.
+ std::unique_ptr<views::Button> shipping_row = CreateShippingOptionRow();
+ if (shipping_row) {
+ layout->StartRow(0, 0);
+ layout->AddView(shipping_row.release());
+ }
}
layout->StartRow(0, 0);
layout->AddView(CreatePaymentMethodRow().release());
@@ -383,9 +395,9 @@ std::unique_ptr<views::View>
PaymentSheetViewController::CreateShippingSectionContent() {
auto* profile = state()->selected_shipping_profile();
- return profile ? payments::GetShippingAddressLabel(
- AddressStyleType::SUMMARY,
- state()->GetApplicationLocale(), *profile)
+ return profile ? GetShippingAddressLabel(AddressStyleType::SUMMARY,
+ state()->GetApplicationLocale(),
+ *profile)
: base::MakeUnique<views::Label>(base::string16());
}
@@ -486,8 +498,11 @@ PaymentSheetViewController::CreateContactInfoRow() {
std::unique_ptr<views::Button>
PaymentSheetViewController::CreateShippingOptionRow() {
- payments::mojom::PaymentShippingOption* selected_option =
- state()->selected_shipping_option();
+ mojom::PaymentShippingOption* selected_option =
+ spec()->selected_shipping_option();
+ if (!selected_option)
+ return nullptr;
+
std::unique_ptr<views::View> option_label = CreateShippingOptionLabel(
selected_option, selected_option ? spec()->GetFormattedCurrencyAmount(
selected_option->amount->value)

Powered by Google App Engine
This is Rietveld 408576698