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

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: Move a comment. Created 3 years, 11 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..f86e2d8d9fe479e3e9ee993537ad803646070793 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,41 @@ class PaymentRequestSheetController {
// Caller should not take ownership of the result.
PaymentRequestDialogView* dialog() { return dialog_; }
+ // 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 to indicate that no primary button should
sky 2017/02/03 02:36:50 optional: I would say null rather than empty std::
anthonyvd 2017/02/03 16:50:57 Clarified that empty std::unique_ptr here means nu
+ // 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();
sky 2017/02/03 02:36:49 Can this be protected?
anthonyvd 2017/02/03 16:50:57 Sure can, done!
+
+ protected:
+ // 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