| 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 16 matching lines...) Expand all Loading... |
| 27 public: | 27 public: |
| 28 // Objects of this class are owned by |dialog|, so it's a non-owned pointer | 28 // Objects of this class are owned by |dialog|, so it's a non-owned pointer |
| 29 // that should be valid throughout this object's lifetime. | 29 // that should be valid throughout this object's lifetime. |
| 30 // |state| and |spec| are also not owned by this and are guaranteed to outlive | 30 // |state| and |spec| are also not owned by this and are guaranteed to outlive |
| 31 // dialog. Neither |state|, |spec| or |dialog| should be null. | 31 // dialog. Neither |state|, |spec| or |dialog| should be null. |
| 32 PaymentRequestSheetController(PaymentRequestSpec* spec, | 32 PaymentRequestSheetController(PaymentRequestSpec* spec, |
| 33 PaymentRequestState* state, | 33 PaymentRequestState* state, |
| 34 PaymentRequestDialogView* dialog); | 34 PaymentRequestDialogView* dialog); |
| 35 ~PaymentRequestSheetController() override; | 35 ~PaymentRequestSheetController() override; |
| 36 | 36 |
| 37 // Creates a view to be displayed in the PaymentRequestDialog. The header view |
| 38 // is the view displayed on top of the dialog, containing title, (optional) |
| 39 // back button, and close buttons. |
| 40 // The content view is displayed between the header view and the pay/cancel |
| 41 // buttons. Also adds the footer, returned by CreateFooterView(), which is |
| 42 // clamped to the bottom of the containing view. The returned view takes |
| 43 // ownership of the header, the content, and the footer. |
| 44 // +---------------------------+ |
| 45 // | HEADER VIEW | |
| 46 // +---------------------------+ |
| 47 // | CONTENT | |
| 48 // | VIEW | |
| 49 // +---------------------------+ |
| 50 // | EXTRA VIEW | PAY | CANCEL | <-- footer |
| 51 // +---------------------------+ |
| 37 std::unique_ptr<views::View> CreateView(); | 52 std::unique_ptr<views::View> CreateView(); |
| 38 | 53 |
| 39 PaymentRequestSpec* spec() { return spec_; } | 54 PaymentRequestSpec* spec() { return spec_; } |
| 40 PaymentRequestState* state() { return state_; } | 55 PaymentRequestState* state() { return state_; } |
| 41 | 56 |
| 42 // The dialog that contains and owns this object. | 57 // The dialog that contains and owns this object. |
| 43 // Caller should not take ownership of the result. | 58 // Caller should not take ownership of the result. |
| 44 PaymentRequestDialogView* dialog() { return dialog_; } | 59 PaymentRequestDialogView* dialog() { return dialog_; } |
| 45 | 60 |
| 46 protected: | 61 protected: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // start off on a different view (a textfield for example). This will only be | 114 // start off on a different view (a textfield for example). This will only be |
| 100 // called after the view has been completely created through calls to | 115 // called after the view has been completely created through calls to |
| 101 // CreatePaymentView and related functions. | 116 // CreatePaymentView and related functions. |
| 102 virtual views::View* GetFirstFocusedView(); | 117 virtual views::View* GetFirstFocusedView(); |
| 103 | 118 |
| 104 // Returns true if the subclass wants the content sheet to have an id, and | 119 // Returns true if the subclass wants the content sheet to have an id, and |
| 105 // sets |sheet_id| to the desired value. | 120 // sets |sheet_id| to the desired value. |
| 106 virtual bool GetSheetId(DialogViewID* sheet_id); | 121 virtual bool GetSheetId(DialogViewID* sheet_id); |
| 107 | 122 |
| 108 private: | 123 private: |
| 109 // Creates a view to be displayed in the PaymentRequestDialog. | |
| 110 // |header_view| is the view displayed on top of the dialog, containing title, | |
| 111 // (optional) back button, and close buttons. | |
| 112 // |content_view| is displayed between |header_view| and the pay/cancel | |
| 113 // buttons. Also adds the footer, returned by CreateFooterView(), which is | |
| 114 // clamped to the bottom of the containing view. The returned view takes | |
| 115 // ownership of |header_view|, |content_view|, and the footer. | |
| 116 // +---------------------------+ | |
| 117 // | HEADER VIEW | | |
| 118 // +---------------------------+ | |
| 119 // | CONTENT | | |
| 120 // | VIEW | | |
| 121 // +---------------------------+ | |
| 122 // | EXTRA VIEW | PAY | CANCEL | <-- footer | |
| 123 // +---------------------------+ | |
| 124 std::unique_ptr<views::View> CreatePaymentView(); | |
| 125 | |
| 126 // Called when the Enter accelerator is pressed. Perform the action associated | 124 // Called when the Enter accelerator is pressed. Perform the action associated |
| 127 // with the primary button and returns true if it's enabled, returns false | 125 // with the primary button and returns true if it's enabled, returns false |
| 128 // otherwise. | 126 // otherwise. |
| 129 bool PerformPrimaryButtonAction(); | 127 bool PerformPrimaryButtonAction(); |
| 130 | 128 |
| 131 // All these are not owned. Will outlive this. | 129 // All these are not owned. Will outlive this. |
| 132 PaymentRequestSpec* spec_; | 130 PaymentRequestSpec* spec_; |
| 133 PaymentRequestState* state_; | 131 PaymentRequestState* state_; |
| 134 PaymentRequestDialogView* dialog_; | 132 PaymentRequestDialogView* dialog_; |
| 135 | 133 |
| 136 // This view is owned by its encompassing ScrollView. | 134 // This view is owned by its encompassing ScrollView. |
| 137 views::View* pane_; | 135 views::View* pane_; |
| 138 views::View* content_view_; | 136 views::View* content_view_; |
| 139 | 137 |
| 140 // Hold on to the ScrollView because it must be explicitly laid out in some | 138 // Hold on to the ScrollView because it must be explicitly laid out in some |
| 141 // cases. | 139 // cases. |
| 142 std::unique_ptr<views::ScrollView> scroll_; | 140 std::unique_ptr<views::ScrollView> scroll_; |
| 143 | 141 |
| 144 // Hold on to the primary and secondary buttons to use them as initial focus | 142 // Hold on to the primary and secondary buttons to use them as initial focus |
| 145 // targets when subclasses don't want to focus anything else. | 143 // targets when subclasses don't want to focus anything else. |
| 146 std::unique_ptr<views::Button> primary_button_; | 144 std::unique_ptr<views::Button> primary_button_; |
| 147 std::unique_ptr<views::Button> secondary_button_; | 145 std::unique_ptr<views::Button> secondary_button_; |
| 148 | 146 |
| 149 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); | 147 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); |
| 150 }; | 148 }; |
| 151 | 149 |
| 152 } // namespace payments | 150 } // namespace payments |
| 153 | 151 |
| 154 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 152 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| OLD | NEW |