Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_sheet_controller.h

Issue 2768133002: [Web Payments] Refactor sheet display to allow updating view content (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 // views shown in the PaymentRequestDialog. 24 // views shown in the PaymentRequestDialog.
25 class PaymentRequestSheetController : public views::ButtonListener { 25 class PaymentRequestSheetController : public views::ButtonListener {
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 // |state| and |spec| are also not owned by this and are guaranteed to outlive 29 // |state| and |spec| are also not owned by this and are guaranteed to outlive
30 // dialog. Neither |state|, |spec| or |dialog| should be null. 30 // dialog. Neither |state|, |spec| or |dialog| should be null.
31 PaymentRequestSheetController(PaymentRequestSpec* spec, 31 PaymentRequestSheetController(PaymentRequestSpec* spec,
32 PaymentRequestState* state, 32 PaymentRequestState* state,
33 PaymentRequestDialogView* dialog); 33 PaymentRequestDialogView* dialog);
34 ~PaymentRequestSheetController() override {} 34 ~PaymentRequestSheetController() override;
35 35
36 virtual std::unique_ptr<views::View> CreateView() = 0; 36 std::unique_ptr<views::View> CreateView();
37 37
38 PaymentRequestSpec* spec() { return spec_; } 38 PaymentRequestSpec* spec() { return spec_; }
39 PaymentRequestState* state() { return state_; } 39 PaymentRequestState* state() { return state_; }
40 40
41 // The dialog that contains and owns this object. 41 // The dialog that contains and owns this object.
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 void UpdateContentView();
Mathieu 2017/03/23 11:36:45 let's add a comment, here and below
anthonyvd 2017/03/23 16:18:11 Done.
47
46 // Creates and returns the primary action button for this sheet. It's 48 // 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 49 // 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 50 // 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 51 // 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 52 // 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 53 // retain a raw pointer to the returned button (for example to control its
52 // enabled state). 54 // enabled state).
53 virtual std::unique_ptr<views::Button> CreatePrimaryButton(); 55 virtual std::unique_ptr<views::Button> CreatePrimaryButton();
54 56
57 virtual bool ShouldShowHeaderBackArrow();
58 virtual base::string16 GetSheetTitle() = 0;
59
60 virtual void FillContentView(views::View* content_view) = 0;
61
55 // Creates and returns the view to be displayed next to the "Pay" and "Cancel" 62 // Creates and returns the view to be displayed next to the "Pay" and "Cancel"
56 // buttons. May return an empty std::unique_ptr (nullptr) to indicate that no 63 // buttons. May return an empty std::unique_ptr (nullptr) to indicate that no
57 // extra view is to be displayed.The caller takes ownership of the view but 64 // extra view is to be displayed.The caller takes ownership of the view but
58 // the view is guaranteed to be outlived by the controller so subclasses may 65 // the view is guaranteed to be outlived by the controller so subclasses may
59 // retain a raw pointer to the returned view (for example to control its 66 // retain a raw pointer to the returned view (for example to control its
60 // enabled state). The horizontal and vertical insets (to the left and bottom 67 // enabled state). The horizontal and vertical insets (to the left and bottom
61 // borders) is taken care of by the caller, so can be set to 0. 68 // borders) is taken care of by the caller, so can be set to 0.
62 // +---------------------------+ 69 // +---------------------------+
63 // | EXTRA VIEW | PAY | CANCEL | 70 // | EXTRA VIEW | PAY | CANCEL |
64 // +---------------------------+ 71 // +---------------------------+
65 virtual std::unique_ptr<views::View> CreateExtraFooterView(); 72 virtual std::unique_ptr<views::View> CreateExtraFooterView();
66 73
67 // views::ButtonListener: 74 // views::ButtonListener:
68 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 75 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
69 76
77 // Creates the row of button containing the Pay, cancel, and extra buttons.
78 // |controller| is installed as the listener for button events.
79 std::unique_ptr<views::View> CreateFooterView();
80
81 private:
70 // Creates a view to be displayed in the PaymentRequestDialog. 82 // Creates a view to be displayed in the PaymentRequestDialog.
71 // |header_view| is the view displayed on top of the dialog, containing title, 83 // |header_view| is the view displayed on top of the dialog, containing title,
72 // (optional) back button, and close buttons. 84 // (optional) back button, and close buttons.
73 // |content_view| is displayed between |header_view| and the pay/cancel 85 // |content_view| is displayed between |header_view| and the pay/cancel
74 // buttons. Also adds the footer, returned by CreateFooterView(), which is 86 // buttons. Also adds the footer, returned by CreateFooterView(), which is
75 // clamped to the bottom of the containing view. The returned view takes 87 // clamped to the bottom of the containing view. The returned view takes
76 // ownership of |header_view|, |content_view|, and the footer. 88 // ownership of |header_view|, |content_view|, and the footer.
77 // +---------------------------+ 89 // +---------------------------+
78 // | HEADER VIEW | 90 // | HEADER VIEW |
79 // +---------------------------+ 91 // +---------------------------+
80 // | CONTENT | 92 // | CONTENT |
81 // | VIEW | 93 // | VIEW |
82 // +---------------------------+ 94 // +---------------------------+
83 // | EXTRA VIEW | PAY | CANCEL | <-- footer 95 // | EXTRA VIEW | PAY | CANCEL | <-- footer
84 // +---------------------------+ 96 // +---------------------------+
85 std::unique_ptr<views::View> CreatePaymentView( 97 std::unique_ptr<views::View> CreatePaymentView();
86 std::unique_ptr<views::View> header_view,
87 std::unique_ptr<views::View> content_view);
88 98
89 // Creates the row of button containing the Pay, cancel, and extra buttons.
90 // |controller| is installed as the listener for button events.
91 std::unique_ptr<views::View> CreateFooterView();
92
93 private:
94 // All these are not owned. Will outlive this. 99 // All these are not owned. Will outlive this.
95 PaymentRequestSpec* spec_; 100 PaymentRequestSpec* spec_;
96 PaymentRequestState* state_; 101 PaymentRequestState* state_;
97 PaymentRequestDialogView* dialog_; 102 PaymentRequestDialogView* dialog_;
103 std::unique_ptr<views::View> content_view_;
98 104
99 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); 105 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController);
100 }; 106 };
101 107
102 } // namespace payments 108 } // namespace payments
103 109
104 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ 110 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698