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

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: Add comments. 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 // Clears the content part of the view represented by this view controller and
47 // calls FillContentView again to re-populate it with updated views.
48 void UpdateContentView();
49
46 // Creates and returns the primary action button for this sheet. It's 50 // 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 51 // 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 52 // 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 53 // 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 54 // 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 55 // retain a raw pointer to the returned button (for example to control its
52 // enabled state). 56 // enabled state).
53 virtual std::unique_ptr<views::Button> CreatePrimaryButton(); 57 virtual std::unique_ptr<views::Button> CreatePrimaryButton();
54 58
59 // Returns whether this sheet should display a back arrow in the header next
60 // to the title.
61 virtual bool ShouldShowHeaderBackArrow();
62
63 // Returns the title to be displayed in this sheet's header.
64 virtual base::string16 GetSheetTitle() = 0;
65
66 // Implemented by subclasses to populate |content_view| with the views that
67 // should be displayed in their content area (between the header and the
68 // footer). This may be called at view creation time as well as anytime
69 // UpdateContentView is called.
70 virtual void FillContentView(views::View* content_view) = 0;
71
55 // Creates and returns the view to be displayed next to the "Pay" and "Cancel" 72 // 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 73 // 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 74 // 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 75 // 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 76 // 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 77 // 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. 78 // borders) is taken care of by the caller, so can be set to 0.
62 // +---------------------------+ 79 // +---------------------------+
63 // | EXTRA VIEW | PAY | CANCEL | 80 // | EXTRA VIEW | PAY | CANCEL |
64 // +---------------------------+ 81 // +---------------------------+
65 virtual std::unique_ptr<views::View> CreateExtraFooterView(); 82 virtual std::unique_ptr<views::View> CreateExtraFooterView();
66 83
67 // views::ButtonListener: 84 // views::ButtonListener:
68 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 85 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
69 86
87 // Creates the row of button containing the Pay, cancel, and extra buttons.
88 // |controller| is installed as the listener for button events.
89 std::unique_ptr<views::View> CreateFooterView();
90
91 private:
70 // Creates a view to be displayed in the PaymentRequestDialog. 92 // Creates a view to be displayed in the PaymentRequestDialog.
71 // |header_view| is the view displayed on top of the dialog, containing title, 93 // |header_view| is the view displayed on top of the dialog, containing title,
72 // (optional) back button, and close buttons. 94 // (optional) back button, and close buttons.
73 // |content_view| is displayed between |header_view| and the pay/cancel 95 // |content_view| is displayed between |header_view| and the pay/cancel
74 // buttons. Also adds the footer, returned by CreateFooterView(), which is 96 // buttons. Also adds the footer, returned by CreateFooterView(), which is
75 // clamped to the bottom of the containing view. The returned view takes 97 // clamped to the bottom of the containing view. The returned view takes
76 // ownership of |header_view|, |content_view|, and the footer. 98 // ownership of |header_view|, |content_view|, and the footer.
77 // +---------------------------+ 99 // +---------------------------+
78 // | HEADER VIEW | 100 // | HEADER VIEW |
79 // +---------------------------+ 101 // +---------------------------+
80 // | CONTENT | 102 // | CONTENT |
81 // | VIEW | 103 // | VIEW |
82 // +---------------------------+ 104 // +---------------------------+
83 // | EXTRA VIEW | PAY | CANCEL | <-- footer 105 // | EXTRA VIEW | PAY | CANCEL | <-- footer
84 // +---------------------------+ 106 // +---------------------------+
85 std::unique_ptr<views::View> CreatePaymentView( 107 std::unique_ptr<views::View> CreatePaymentView();
86 std::unique_ptr<views::View> header_view,
87 std::unique_ptr<views::View> content_view);
88 108
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. 109 // All these are not owned. Will outlive this.
95 PaymentRequestSpec* spec_; 110 PaymentRequestSpec* spec_;
96 PaymentRequestState* state_; 111 PaymentRequestState* state_;
97 PaymentRequestDialogView* dialog_; 112 PaymentRequestDialogView* dialog_;
98 113
114 // This view is owned by its encompassing ScrollView.
115 views::View* content_view_;
116
99 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); 117 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController);
100 }; 118 };
101 119
102 } // namespace payments 120 } // namespace payments
103 121
104 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ 122 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698