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

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

Issue 2715213005: [Payments] Add the pay button, and control its enabled state (Closed)
Patch Set: tweak Created 3 years, 10 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_request_dialog_view.cc
diff --git a/chrome/browser/ui/views/payments/payment_request_dialog_view.cc b/chrome/browser/ui/views/payments/payment_request_dialog_view.cc
index d6a122e5ad73950e18d6ad7ab4cffd4a46c5285c..c84a20a22cc786af0dc31d39d2e108b00178644e 100644
--- a/chrome/browser/ui/views/payments/payment_request_dialog_view.cc
+++ b/chrome/browser/ui/views/payments/payment_request_dialog_view.cc
@@ -143,12 +143,25 @@ void PaymentRequestDialogView::CloseDialog() {
GetWidget()->Close();
}
+void PaymentRequestDialogView::UpdatePayButtonState(bool enabled) {
anthonyvd 2017/02/28 17:16:32 I don't think this pattern is the way to go: 1. T
Mathieu 2017/02/28 19:42:39 OMG yes, it's much better with observers. Good cat
+ // It's theoretically possible that the dialog is closed and PaymentRequest
+ // still calls this.
+ if (payment_sheet_view_)
+ return;
+
+ const auto it = controller_map_.find(payment_sheet_view_);
+ DCHECK(it != controller_map_.end());
+ PaymentSheetViewController* sheet_controller =
+ static_cast<PaymentSheetViewController*>(it->second.get());
+ sheet_controller->UpdatePayButtonState(enabled);
+}
+
void PaymentRequestDialogView::ShowInitialPaymentSheet() {
- view_stack_.Push(
- CreateViewAndInstallController(
- base::MakeUnique<PaymentSheetViewController>(request_, this),
- &controller_map_),
- /* animate = */ false);
+ std::unique_ptr<views::View> sheet_view = CreateViewAndInstallController(
+ base::MakeUnique<PaymentSheetViewController>(request_, this),
+ &controller_map_);
+ payment_sheet_view_ = sheet_view.get();
+ view_stack_.Push(std::move(sheet_view), /* animate = */ false);
if (observer_for_testing_)
observer_for_testing_->OnDialogOpened();
}
@@ -164,6 +177,9 @@ void PaymentRequestDialogView::ViewHierarchyChanged(
if (!details.is_add &&
controller_map_.find(details.child) != controller_map_.end()) {
DCHECK(!details.move_view);
+ if (details.child == payment_sheet_view_)
+ payment_sheet_view_ = nullptr;
+
controller_map_.erase(details.child);
}
}

Powered by Google App Engine
This is Rietveld 408576698