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

Unified Diff: chrome/browser/ui/views/payments/payment_request_sheet_controller.h

Issue 2668063003: [Web Payments] Add Cancel button to all sheets (Closed)
Patch Set: Rebase 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_sheet_controller.h
diff --git a/chrome/browser/ui/views/payments/payment_request_sheet_controller.h b/chrome/browser/ui/views/payments/payment_request_sheet_controller.h
index 6b0ff5d5d1440d541f7c36ebf72986375fa16616..a3d2497752e9139cbd9d1b7edaffecd3063bcba9 100644
--- a/chrome/browser/ui/views/payments/payment_request_sheet_controller.h
+++ b/chrome/browser/ui/views/payments/payment_request_sheet_controller.h
@@ -7,10 +7,11 @@
#include <memory>
-#include "base/logging.h"
#include "base/macros.h"
+#include "ui/views/controls/button/vector_icon_button_delegate.h"
namespace views {
+class Button;
class View;
}
@@ -21,19 +22,15 @@ class PaymentRequest;
// The base class for objects responsible for the creation and event handling in
// views shown in the PaymentRequestDialog.
-class PaymentRequestSheetController {
+class PaymentRequestSheetController : public views::VectorIconButtonDelegate {
public:
// Objects of this class are owned by |dialog|, so it's a non-owned pointer
// that should be valid throughout this object's lifetime.
// |request| is also not owned by this and is guaranteed to outlive dialog.
// Neither |request| or |dialog| should be null.
PaymentRequestSheetController(PaymentRequest* request,
- PaymentRequestDialogView* dialog)
- : request_(request), dialog_(dialog) {
- DCHECK(request_);
- DCHECK(dialog_);
- }
- virtual ~PaymentRequestSheetController() {}
+ PaymentRequestDialogView* dialog);
+ ~PaymentRequestSheetController() override {}
virtual std::unique_ptr<views::View> CreateView() = 0;
@@ -45,6 +42,42 @@ class PaymentRequestSheetController {
// Caller should not take ownership of the result.
PaymentRequestDialogView* dialog() { return dialog_; }
+ protected:
+ // Creates and returns the primary action button for this sheet. It's
+ // typically a blue button with the "Pay" or "Done" labels. Subclasses may
+ // return an empty std::unique_ptr (nullptr) to indicate that no primary
+ // button should be displayed. The caller takes ownership of the button but
+ // the view is guaranteed to be outlived by the controller so subclasses may
+ // retain a raw pointer to the returned button (for example to control its
+ // enabled state).
+ virtual std::unique_ptr<views::Button> CreatePrimaryButton();
+
+ // views::VectorIconButtonDelegate:
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override;
+
+ // Creates a view to be displayed in the PaymentRequestDialog.
+ // |header_view| is the view displayed on top of the dialog, containing title,
+ // (optional) back button, and close buttons.
+ // |content_view| is displayed between |header_view| and the pay/cancel
+ // buttons. Also adds the footer, returned by CreateFooterView(), which is
+ // clamped to the bottom of the containing view. The returned view takes
+ // ownership of |header_view|, |content_view|, and the footer.
+ // +---------------------------+
+ // | HEADER VIEW |
+ // +---------------------------+
+ // | CONTENT |
+ // | VIEW |
+ // +---------------------------+
+ // | | CANCEL | PAY | <-- footer
+ // +---------------------------+
+ std::unique_ptr<views::View> CreatePaymentView(
+ std::unique_ptr<views::View> header_view,
+ std::unique_ptr<views::View> content_view);
+
+ // Creates the row of button containing the Pay, cancel, and extra buttons.
+ // |controller| is installed as the listener for button events.
+ std::unique_ptr<views::View> CreateFooterView();
+
private:
// Not owned. Will outlive this.
PaymentRequest* request_;

Powered by Google App Engine
This is Rietveld 408576698