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

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

Issue 2528503002: [WebPayments] Implement state transitions in desktop WebPayments dialog. (Closed)
Patch Set: Factor out ViewStack and animations Created 4 years 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.cc
diff --git a/chrome/browser/ui/views/payments/payment_request_dialog.cc b/chrome/browser/ui/views/payments/payment_request_dialog.cc
index 04f6d69fd020e445bfc09fdaf5db74f6eecfc172..60a5a770b712b2a16da1290eba39b2583b808036 100644
--- a/chrome/browser/ui/views/payments/payment_request_dialog.cc
+++ b/chrome/browser/ui/views/payments/payment_request_dialog.cc
@@ -2,9 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/ui/views/payments/payment_request_dialog.h"
+
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/payments/payment_request_impl.h"
-#include "chrome/browser/ui/views/payments/payment_request_dialog.h"
+#include "chrome/browser/ui/views/payments/order_summary_state.h"
+#include "chrome/browser/ui/views/payments/payment_sheet_state.h"
+#include "chrome/browser/ui/views/payments/view_stack.h"
#include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/browser_thread.h"
#include "ui/views/layout/fill_layout.h"
@@ -21,11 +25,16 @@ void ShowPaymentRequestDialog(payments::PaymentRequestImpl* impl) {
namespace payments {
PaymentRequestDialog::PaymentRequestDialog(PaymentRequestImpl* impl)
- : impl_(impl),
- label_(new views::Label(base::ASCIIToUTF16("Payments dialog"))) {
+ : impl_(impl) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
SetLayoutManager(new views::FillLayout());
- AddChildView(label_.get());
+
+ std::unique_ptr<PaymentSheetState> initial_state =
+ base::MakeUnique<PaymentSheetState>();
+ initial_state->AddObserver(this);
+ view_stack_.reset(new ViewStack(std::move(initial_state)));
sky 2016/12/12 01:54:32 Can you elaborate on why ViewStack can't operate s
anthonyvd 2016/12/12 17:01:56 I felt like encapsulating event handling in the st
+ view_stack_->set_owned_by_client();
+ AddChildView(view_stack_.get());
}
PaymentRequestDialog::~PaymentRequestDialog() {}
@@ -35,9 +44,7 @@ ui::ModalType PaymentRequestDialog::GetModalType() const {
}
gfx::Size PaymentRequestDialog::GetPreferredSize() const {
- gfx::Size ps = label_->GetPreferredSize();
- ps.Enlarge(200, 200);
- return ps;
+ return gfx::Size(300, 300);
}
bool PaymentRequestDialog::Cancel() {
@@ -46,4 +53,15 @@ bool PaymentRequestDialog::Cancel() {
return true;
}
+void PaymentRequestDialog::OnOrderSummaryClicked() {
+ std::unique_ptr<OrderSummaryState> order_summary =
+ base::MakeUnique<OrderSummaryState>();
+ order_summary->AddObserver(this);
+ view_stack_->PushState(std::move(order_summary));
+}
+
+void PaymentRequestDialog::OnBackClicked() {
+ view_stack_->PopState();
+}
+
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698