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

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

Issue 2528503002: [WebPayments] Implement state transitions in desktop WebPayments dialog. (Closed)
Patch Set: Handle Layout while animating 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..e85c4290ae350c9d913620b28ede05e542399b2f 100644
--- a/chrome/browser/ui/views/payments/payment_request_dialog.cc
+++ b/chrome/browser/ui/views/payments/payment_request_dialog.cc
@@ -2,30 +2,97 @@
// 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/grit/generated_resources.h"
#include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/browser_thread.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/views/controls/button/md_text_button.h"
+#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
+#include "ui/views/layout/grid_layout.h"
+
+namespace {
+
+// The tag for the button that navigates back to the payment sheet.
+constexpr int kBackButtonTag = 0;
+
+// The tag for the button that navigates to the Order Summary sheet.
+constexpr int kOrderSummaryTag = 1;
+
+std::unique_ptr<views::View> CreateOrderSummaryView(
+ views::ButtonListener* button_listener) {
+ std::unique_ptr<views::View> view = base::MakeUnique<views::View>();
+
+ views::GridLayout* layout = new views::GridLayout(view.get());
+ view->SetLayoutManager(layout);
+ views::ColumnSet* columns = layout->AddColumnSet(0);
+ columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
+ 0, views::GridLayout::USE_PREF, 0, 0);
+
+ layout->StartRow(0, 0);
+ layout->AddView(new views::Label(
+ l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_TITLE)));
+
+ layout->StartRow(0, 0);
+ views::LabelButton* back_button =
+ views::MdTextButton::CreateSecondaryUiBlueButton(
+ button_listener, base::ASCIIToUTF16("Back"));
+ back_button->set_tag(kBackButtonTag);
+ layout->AddView(back_button);
+
+ return view;
+}
+
+std::unique_ptr<views::View> CreatePaymentSheetView(
+ views::ButtonListener* button_listener) {
+ std::unique_ptr<views::View> view = base::MakeUnique<views::View>();
+
+ views::GridLayout* layout = new views::GridLayout(view.get());
+ view->SetLayoutManager(layout);
+ views::ColumnSet* columns = layout->AddColumnSet(0);
+ columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
+ 0, views::GridLayout::USE_PREF, 0, 0);
+
+ layout->StartRow(0, 0);
+ layout->AddView(new views::Label(
+ l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE)));
+
+ layout->StartRow(0, 0);
+ views::LabelButton* order_summary_button =
+ views::MdTextButton::CreateSecondaryUiBlueButton(
+ button_listener, base::ASCIIToUTF16("Order Summary"));
+ order_summary_button->set_tag(kOrderSummaryTag);
+ layout->AddView(order_summary_button);
+
+ return view;
+}
+
+} // namespace
namespace chrome {
void ShowPaymentRequestDialog(payments::PaymentRequestImpl* impl) {
- constrained_window::ShowWebModalDialogViews(
- new payments::PaymentRequestDialog(impl), impl->web_contents());
+ constrained_window::ShowWebModalDialogViews(
+ new payments::PaymentRequestDialog(impl), impl->web_contents());
}
-}
+} // namespace chrome
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());
+
+ view_stack_.set_owned_by_client();
+ AddChildView(&view_stack_);
+
+ ShowInitialPaymentSheet();
}
PaymentRequestDialog::~PaymentRequestDialog() {}
@@ -35,9 +102,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 +111,25 @@ bool PaymentRequestDialog::Cancel() {
return true;
}
+void PaymentRequestDialog::ShowInitialPaymentSheet() {
+ view_stack_.Push(CreatePaymentSheetView(this), false);
+}
+
+void PaymentRequestDialog::ShowOrderSummary() {
+ view_stack_.Push(CreateOrderSummaryView(this), true);
+}
+
+void PaymentRequestDialog::GoBack() {
+ view_stack_.Pop();
+}
+
+void PaymentRequestDialog::ButtonPressed(
+ views::Button* sender, const ui::Event& event) {
+ if (sender->tag() == kBackButtonTag) {
+ GoBack();
+ } else if (sender->tag() == kOrderSummaryTag) {
+ ShowOrderSummary();
+ }
+}
+
} // namespace payments
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_dialog.h ('k') | chrome/browser/ui/views/payments/view_stack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698