Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 // that should be valid throughout this object's lifetime. | 28 // that should be valid throughout this object's lifetime. |
| 29 // |request| is also not owned by this and is guaranteed to outlive dialog. | 29 // |request| is also not owned by this and is guaranteed to outlive dialog. |
| 30 // Neither |request| or |dialog| should be null. | 30 // Neither |request| or |dialog| should be null. |
| 31 PaymentRequestSheetController(PaymentRequest* request, | 31 PaymentRequestSheetController(PaymentRequest* request, |
| 32 PaymentRequestDialogView* dialog); | 32 PaymentRequestDialogView* dialog); |
| 33 ~PaymentRequestSheetController() override {} | 33 ~PaymentRequestSheetController() override {} |
| 34 | 34 |
| 35 virtual std::unique_ptr<views::View> CreateView() = 0; | 35 virtual std::unique_ptr<views::View> CreateView() = 0; |
| 36 // A leading view to complement the button(s). See CreateFooterView for how | 36 // A leading view to complement the button(s). See CreateFooterView for how |
| 37 // this is used and what insets are already applied. | 37 // this is used and what insets are already applied. |
| 38 virtual std::unique_ptr<views::View> CreateLeadingFooterView(); | 38 virtual std::unique_ptr<views::View> CreateLeadingFooterView(); |
|
Mathieu
2017/02/23 00:39:07
Admittedly I should have made this protected, simi
| |
| 39 | 39 |
| 40 // The PaymentRequest object associated with this instance of the dialog. | 40 // The PaymentRequest object associated with this instance of the dialog. |
| 41 // Caller should not take ownership of the result. | 41 // Caller should not take ownership of the result. |
| 42 PaymentRequest* request() { return request_; } | 42 PaymentRequest* request() { return request_; } |
| 43 | 43 |
| 44 // The dialog that contains and owns this object. | 44 // The dialog that contains and owns this object. |
| 45 // Caller should not take ownership of the result. | 45 // Caller should not take ownership of the result. |
| 46 PaymentRequestDialogView* dialog() { return dialog_; } | 46 PaymentRequestDialogView* dialog() { return dialog_; } |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 // Creates and returns the primary action button for this sheet. It's | 49 // Creates and returns the primary action button for this sheet. It's |
| 50 // typically a blue button with the "Pay" or "Done" labels. Subclasses may | 50 // typically a blue button with the "Pay" or "Done" labels. Subclasses may |
| 51 // return an empty std::unique_ptr (nullptr) to indicate that no primary | 51 // return an empty std::unique_ptr (nullptr) to indicate that no primary |
| 52 // button should be displayed. The caller takes ownership of the button but | 52 // button should be displayed. The caller takes ownership of the button but |
| 53 // the view is guaranteed to be outlived by the controller so subclasses may | 53 // the view is guaranteed to be outlived by the controller so subclasses may |
| 54 // retain a raw pointer to the returned button (for example to control its | 54 // retain a raw pointer to the returned button (for example to control its |
| 55 // enabled state). | 55 // enabled state). |
| 56 virtual std::unique_ptr<views::Button> CreatePrimaryButton(); | 56 virtual std::unique_ptr<views::Button> CreatePrimaryButton(); |
| 57 | 57 |
| 58 // Creates and returns the view to be displayed next to the "Pay" and "Cancel" | |
| 59 // buttons. May return an empty std::unique_ptr (nullptr) to indicate that no | |
| 60 // extra view is to be displayed.The caller takes ownership of the view but | |
| 61 // the view is guaranteed to be outlived by the controller so subclasses may | |
| 62 // retain a raw pointer to the returned view (for example to control its | |
| 63 // enabled state). | |
| 64 // +---------------------------+ | |
| 65 // | EXTRA VIEW | PAY | CANCEL | | |
| 66 // +---------------------------+ | |
| 67 virtual std::unique_ptr<views::View> CreateExtraView(); | |
|
Mathieu
2017/02/23 00:39:07
We should keep one of CreateExtraView or CreateLea
| |
| 68 | |
| 58 // views::VectorIconButtonDelegate: | 69 // views::VectorIconButtonDelegate: |
| 59 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 70 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 60 | 71 |
| 61 // Creates a view to be displayed in the PaymentRequestDialog. | 72 // Creates a view to be displayed in the PaymentRequestDialog. |
| 62 // |header_view| is the view displayed on top of the dialog, containing title, | 73 // |header_view| is the view displayed on top of the dialog, containing title, |
| 63 // (optional) back button, and close buttons. | 74 // (optional) back button, and close buttons. |
| 64 // |content_view| is displayed between |header_view| and the pay/cancel | 75 // |content_view| is displayed between |header_view| and the pay/cancel |
| 65 // buttons. Also adds the footer, returned by CreateFooterView(), which is | 76 // buttons. Also adds the footer, returned by CreateFooterView(), which is |
| 66 // clamped to the bottom of the containing view. The returned view takes | 77 // clamped to the bottom of the containing view. The returned view takes |
| 67 // ownership of |header_view|, |content_view|, and the footer. | 78 // ownership of |header_view|, |content_view|, and the footer. |
| 68 // +---------------------------+ | 79 // +---------------------------+ |
| 69 // | HEADER VIEW | | 80 // | HEADER VIEW | |
| 70 // +---------------------------+ | 81 // +---------------------------+ |
| 71 // | CONTENT | | 82 // | CONTENT | |
| 72 // | VIEW | | 83 // | VIEW | |
| 73 // +---------------------------+ | 84 // +---------------------------+ |
| 74 // | | CANCEL | PAY | <-- footer | 85 // | EXTRA VIEW | PAY | CANCEL | <-- footer |
| 75 // +---------------------------+ | 86 // +---------------------------+ |
| 76 std::unique_ptr<views::View> CreatePaymentView( | 87 std::unique_ptr<views::View> CreatePaymentView( |
| 77 std::unique_ptr<views::View> header_view, | 88 std::unique_ptr<views::View> header_view, |
| 78 std::unique_ptr<views::View> content_view); | 89 std::unique_ptr<views::View> content_view); |
| 79 | 90 |
| 80 // Creates the row of button containing the Pay, cancel, and extra buttons. | 91 // Creates the row of button containing the Pay, cancel, and extra buttons. |
| 81 // |controller| is installed as the listener for button events. | 92 // |controller| is installed as the listener for button events. |
| 82 std::unique_ptr<views::View> CreateFooterView(); | 93 std::unique_ptr<views::View> CreateFooterView(); |
| 83 | 94 |
| 84 private: | 95 private: |
| 85 // Not owned. Will outlive this. | 96 // Not owned. Will outlive this. |
| 86 PaymentRequest* request_; | 97 PaymentRequest* request_; |
| 87 // Not owned. Will outlive this. | 98 // Not owned. Will outlive this. |
| 88 PaymentRequestDialogView* dialog_; | 99 PaymentRequestDialogView* dialog_; |
| 89 | 100 |
| 90 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); | 101 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); |
| 91 }; | 102 }; |
| 92 | 103 |
| 93 } // namespace payments | 104 } // namespace payments |
| 94 | 105 |
| 95 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 106 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| OLD | NEW |