| 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" |
| 11 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 11 #include "ui/views/controls/button/button.h" | 12 #include "ui/views/controls/button/button.h" |
| 12 | 13 |
| 13 namespace views { | 14 namespace views { |
| 14 class View; | 15 class View; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace payments { | 18 namespace payments { |
| 18 | 19 |
| 19 class PaymentRequestDialogView; | 20 class PaymentRequestDialogView; |
| 20 class PaymentRequestSpec; | 21 class PaymentRequestSpec; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 std::unique_ptr<views::View> CreateFooterView(); | 94 std::unique_ptr<views::View> CreateFooterView(); |
| 94 | 95 |
| 95 // Returns the view that should be initially focused on this sheet. Typically, | 96 // Returns the view that should be initially focused on this sheet. Typically, |
| 96 // this returns the primary button if it's enabled or the secondary button | 97 // this returns the primary button if it's enabled or the secondary button |
| 97 // otherwise. Subclasses may return a different view if they need focus to | 98 // otherwise. Subclasses may return a different view if they need focus to |
| 98 // start off on a different view (a textfield for example). This will only be | 99 // start off on a different view (a textfield for example). This will only be |
| 99 // called after the view has been completely created through calls to | 100 // called after the view has been completely created through calls to |
| 100 // CreatePaymentView and related functions. | 101 // CreatePaymentView and related functions. |
| 101 virtual views::View* GetFirstFocusedView(); | 102 virtual views::View* GetFirstFocusedView(); |
| 102 | 103 |
| 104 // Returns true if the subclass wants the content sheet to have an id, and |
| 105 // sets |sheet_id| to the desired value. |
| 106 virtual bool GetSheetId(DialogViewID* sheet_id); |
| 107 |
| 103 private: | 108 private: |
| 104 // Creates a view to be displayed in the PaymentRequestDialog. | 109 // Creates a view to be displayed in the PaymentRequestDialog. |
| 105 // |header_view| is the view displayed on top of the dialog, containing title, | 110 // |header_view| is the view displayed on top of the dialog, containing title, |
| 106 // (optional) back button, and close buttons. | 111 // (optional) back button, and close buttons. |
| 107 // |content_view| is displayed between |header_view| and the pay/cancel | 112 // |content_view| is displayed between |header_view| and the pay/cancel |
| 108 // buttons. Also adds the footer, returned by CreateFooterView(), which is | 113 // buttons. Also adds the footer, returned by CreateFooterView(), which is |
| 109 // clamped to the bottom of the containing view. The returned view takes | 114 // clamped to the bottom of the containing view. The returned view takes |
| 110 // ownership of |header_view|, |content_view|, and the footer. | 115 // ownership of |header_view|, |content_view|, and the footer. |
| 111 // +---------------------------+ | 116 // +---------------------------+ |
| 112 // | HEADER VIEW | | 117 // | HEADER VIEW | |
| 113 // +---------------------------+ | 118 // +---------------------------+ |
| 114 // | CONTENT | | 119 // | CONTENT | |
| 115 // | VIEW | | 120 // | VIEW | |
| 116 // +---------------------------+ | 121 // +---------------------------+ |
| 117 // | EXTRA VIEW | PAY | CANCEL | <-- footer | 122 // | EXTRA VIEW | PAY | CANCEL | <-- footer |
| 118 // +---------------------------+ | 123 // +---------------------------+ |
| 119 std::unique_ptr<views::View> CreatePaymentView(); | 124 std::unique_ptr<views::View> CreatePaymentView(); |
| 120 | 125 |
| 126 // 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 |
| 128 // otherwise. |
| 129 bool PerformPrimaryButtonAction(); |
| 130 |
| 121 // All these are not owned. Will outlive this. | 131 // All these are not owned. Will outlive this. |
| 122 PaymentRequestSpec* spec_; | 132 PaymentRequestSpec* spec_; |
| 123 PaymentRequestState* state_; | 133 PaymentRequestState* state_; |
| 124 PaymentRequestDialogView* dialog_; | 134 PaymentRequestDialogView* dialog_; |
| 125 | 135 |
| 126 // This view is owned by its encompassing ScrollView. | 136 // This view is owned by its encompassing ScrollView. |
| 127 views::View* pane_; | 137 views::View* pane_; |
| 128 views::View* content_view_; | 138 views::View* content_view_; |
| 129 | 139 |
| 130 // Hold on to the ScrollView because it must be explicitly laid out in some | 140 // Hold on to the ScrollView because it must be explicitly laid out in some |
| 131 // cases. | 141 // cases. |
| 132 std::unique_ptr<views::ScrollView> scroll_; | 142 std::unique_ptr<views::ScrollView> scroll_; |
| 133 | 143 |
| 134 // Hold on to the primary and secondary buttons to use them as initial focus | 144 // Hold on to the primary and secondary buttons to use them as initial focus |
| 135 // targets when subclasses don't want to focus anything else. | 145 // targets when subclasses don't want to focus anything else. |
| 136 std::unique_ptr<views::Button> primary_button_; | 146 std::unique_ptr<views::Button> primary_button_; |
| 137 std::unique_ptr<views::Button> secondary_button_; | 147 std::unique_ptr<views::Button> secondary_button_; |
| 138 | 148 |
| 139 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); | 149 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); |
| 140 }; | 150 }; |
| 141 | 151 |
| 142 } // namespace payments | 152 } // namespace payments |
| 143 | 153 |
| 144 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 154 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| OLD | NEW |