| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // Caller should not take ownership of the result. | 42 // Caller should not take ownership of the result. |
| 43 PaymentRequestDialogView* dialog() { return dialog_; } | 43 PaymentRequestDialogView* dialog() { return dialog_; } |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 // 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 |
| 47 // 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 |
| 48 // 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 |
| 49 // 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 |
| 50 // 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 |
| 51 // 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 |
| 52 // enabled state). | 52 // enabled state). See comment on CreatePaymentView for an illustration of the |
| 53 // layout. |
| 53 virtual std::unique_ptr<views::Button> CreatePrimaryButton(); | 54 virtual std::unique_ptr<views::Button> CreatePrimaryButton(); |
| 54 | 55 |
| 56 // Creates and returns the view to be displayed next to the "Pay" and "Cancel" |
| 57 // buttons. May return an empty std::unique_ptr (nullptr) to indicate that no |
| 58 // extra view is to be displayed.The caller takes ownership of the view but |
| 59 // the view is guaranteed to be outlived by the controller so subclasses may |
| 60 // retain a raw pointer to the returned view (for example to control its |
| 61 // enabled state). See comment on CreatePaymentView for an illustration of the |
| 62 // layout. |
| 63 virtual std::unique_ptr<views::View> CreateExtraView(); |
| 64 |
| 55 // views::VectorIconButtonDelegate: | 65 // views::VectorIconButtonDelegate: |
| 56 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 66 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 57 | 67 |
| 58 // Creates a view to be displayed in the PaymentRequestDialog. | 68 // Creates a view to be displayed in the PaymentRequestDialog. |
| 59 // |header_view| is the view displayed on top of the dialog, containing title, | 69 // |header_view| is the view displayed on top of the dialog, containing title, |
| 60 // (optional) back button, and close buttons. | 70 // (optional) back button, and close buttons. |
| 61 // |content_view| is displayed between |header_view| and the pay/cancel | 71 // |content_view| is displayed between |header_view| and the pay/cancel |
| 62 // buttons. Also adds the footer, returned by CreateFooterView(), which is | 72 // buttons. Also adds the footer, returned by CreateFooterView(), which is |
| 63 // clamped to the bottom of the containing view. The returned view takes | 73 // clamped to the bottom of the containing view. The returned view takes |
| 64 // ownership of |header_view|, |content_view|, and the footer. | 74 // ownership of |header_view|, |content_view|, and the footer. |
| 65 // +---------------------------+ | 75 // +---------------------------+ |
| 66 // | HEADER VIEW | | 76 // | HEADER VIEW | |
| 67 // +---------------------------+ | 77 // +---------------------------+ |
| 68 // | CONTENT | | 78 // | CONTENT | |
| 69 // | VIEW | | 79 // | VIEW | |
| 70 // +---------------------------+ | 80 // +---------------------------+ |
| 71 // | | CANCEL | PAY | <-- footer | 81 // | EXTRA VIEW | PAY | CANCEL | <-- footer |
| 72 // +---------------------------+ | 82 // +---------------------------+ |
| 73 std::unique_ptr<views::View> CreatePaymentView( | 83 std::unique_ptr<views::View> CreatePaymentView( |
| 74 std::unique_ptr<views::View> header_view, | 84 std::unique_ptr<views::View> header_view, |
| 75 std::unique_ptr<views::View> content_view); | 85 std::unique_ptr<views::View> content_view); |
| 76 | 86 |
| 77 // Creates the row of button containing the Pay, cancel, and extra buttons. | 87 // Creates the row of button containing the Pay, cancel, and extra buttons. |
| 78 // |controller| is installed as the listener for button events. | 88 // |controller| is installed as the listener for button events. |
| 79 std::unique_ptr<views::View> CreateFooterView(); | 89 std::unique_ptr<views::View> CreateFooterView(); |
| 80 | 90 |
| 81 private: | 91 private: |
| 82 // Not owned. Will outlive this. | 92 // Not owned. Will outlive this. |
| 83 PaymentRequest* request_; | 93 PaymentRequest* request_; |
| 84 // Not owned. Will outlive this. | 94 // Not owned. Will outlive this. |
| 85 PaymentRequestDialogView* dialog_; | 95 PaymentRequestDialogView* dialog_; |
| 86 | 96 |
| 87 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); | 97 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); |
| 88 }; | 98 }; |
| 89 | 99 |
| 90 } // namespace payments | 100 } // namespace payments |
| 91 | 101 |
| 92 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ | 102 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ |
| OLD | NEW |