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 15 matching lines...) Expand all Loading... |
26 public: | 26 public: |
27 // Objects of this class are owned by |dialog|, so it's a non-owned pointer | 27 // Objects of this class are owned by |dialog|, so it's a non-owned pointer |
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 | |
37 // this is used and what insets are already applied. | |
38 virtual std::unique_ptr<views::View> CreateLeadingFooterView(); | |
39 | 36 |
40 // The PaymentRequest object associated with this instance of the dialog. | 37 // The PaymentRequest object associated with this instance of the dialog. |
41 // Caller should not take ownership of the result. | 38 // Caller should not take ownership of the result. |
42 PaymentRequest* request() { return request_; } | 39 PaymentRequest* request() { return request_; } |
43 | 40 |
44 // The dialog that contains and owns this object. | 41 // The dialog that contains and owns this object. |
45 // Caller should not take ownership of the result. | 42 // Caller should not take ownership of the result. |
46 PaymentRequestDialogView* dialog() { return dialog_; } | 43 PaymentRequestDialogView* dialog() { return dialog_; } |
47 | 44 |
48 protected: | 45 protected: |
49 // Creates and returns the primary action button for this sheet. It's | 46 // 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 | 47 // 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 | 48 // 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 | 49 // 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 | 50 // 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 | 51 // retain a raw pointer to the returned button (for example to control its |
55 // enabled state). | 52 // enabled state). |
56 virtual std::unique_ptr<views::Button> CreatePrimaryButton(); | 53 virtual std::unique_ptr<views::Button> CreatePrimaryButton(); |
57 | 54 |
58 // Creates and returns the view to be displayed next to the "Pay" and "Cancel" | 55 // 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 | 56 // 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 | 57 // 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 | 58 // 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 | 59 // retain a raw pointer to the returned view (for example to control its |
63 // enabled state). | 60 // enabled state). |
64 // +---------------------------+ | 61 // +---------------------------+ |
65 // | EXTRA VIEW | PAY | CANCEL | | 62 // | EXTRA VIEW | PAY | CANCEL | |
66 // +---------------------------+ | 63 // +---------------------------+ |
67 virtual std::unique_ptr<views::View> CreateExtraView(); | 64 virtual std::unique_ptr<views::View> CreateExtraFooterView(); |
68 | 65 |
69 // views::VectorIconButtonDelegate: | 66 // views::VectorIconButtonDelegate: |
70 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 67 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
71 | 68 |
72 // Creates a view to be displayed in the PaymentRequestDialog. | 69 // Creates a view to be displayed in the PaymentRequestDialog. |
73 // |header_view| is the view displayed on top of the dialog, containing title, | 70 // |header_view| is the view displayed on top of the dialog, containing title, |
74 // (optional) back button, and close buttons. | 71 // (optional) back button, and close buttons. |
75 // |content_view| is displayed between |header_view| and the pay/cancel | 72 // |content_view| is displayed between |header_view| and the pay/cancel |
76 // buttons. Also adds the footer, returned by CreateFooterView(), which is | 73 // buttons. Also adds the footer, returned by CreateFooterView(), which is |
77 // clamped to the bottom of the containing view. The returned view takes | 74 // clamped to the bottom of the containing view. The returned view takes |
(...skipping 19 matching lines...) Expand all Loading... |
97 PaymentRequest* request_; | 94 PaymentRequest* request_; |
98 // Not owned. Will outlive this. | 95 // Not owned. Will outlive this. |
99 PaymentRequestDialogView* dialog_; | 96 PaymentRequestDialogView* dialog_; |
100 | 97 |
101 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); | 98 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); |
102 }; | 99 }; |
103 | 100 |
104 } // namespace payments | 101 } // namespace payments |
105 | 102 |
106 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 103 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
OLD | NEW |