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

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

Issue 2528503002: [WebPayments] Implement state transitions in desktop WebPayments dialog. (Closed)
Patch Set: Change the ViewStack interface to take std::unique_ptr<views::View> directly. 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..f9de607d433cbd4651521014944aa1287a38f874 100644
--- a/chrome/browser/ui/views/payments/payment_request_dialog.cc
+++ b/chrome/browser/ui/views/payments/payment_request_dialog.cc
@@ -2,12 +2,77 @@
// 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/view_stack.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 {
@@ -16,16 +81,18 @@ void ShowPaymentRequestDialog(payments::PaymentRequestImpl* impl) {
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_.reset(new ViewStack(CreatePaymentSheetView(this)));
+ view_stack_->set_owned_by_client();
+ AddChildView(view_stack_.get());
}
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,21 @@ bool PaymentRequestDialog::Cancel() {
return true;
}
+void PaymentRequestDialog::ButtonPressed(
+ views::Button* sender, const ui::Event& event) {
+ if (sender->tag() == kBackButtonTag) {
+ GoBack();
+ } else if (sender->tag() == kOrderSummaryTag) {
+ ShowOrderSummary();
+ }
+}
+
+void PaymentRequestDialog::ShowOrderSummary() {
+ view_stack_->Push(CreateOrderSummaryView(this));
+}
+
+void PaymentRequestDialog::GoBack() {
+ view_stack_->Pop();
+}
+
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698