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

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

Issue 2862913002: [Web Payments] Let subsheets define the initial focus (Closed)
Patch Set: Created 3 years, 7 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 15 matching lines...) Expand all
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 // Creates a view to be displayed in the PaymentRequestDialog. The header view
37 // is the view displayed on top of the dialog, containing title, (optional)
Mathieu 2017/05/04 19:32:34 nit: extra leading space
anthonyvd 2017/05/04 20:56:59 Done.
38 // back button, and close buttons.
39 // The content view is displayed between the header view and the pay/cancel
40 // buttons. Also adds the footer, returned by CreateFooterView(), which is
41 // clamped to the bottom of the containing view. The returned view takes
42 // ownership of the header, the content, and the footer.
43 // +---------------------------+
44 // | HEADER VIEW |
45 // +---------------------------+
46 // | CONTENT |
47 // | VIEW |
48 // +---------------------------+
49 // | EXTRA VIEW | PAY | CANCEL | <-- footer
50 // +---------------------------+
36 std::unique_ptr<views::View> CreateView(); 51 std::unique_ptr<views::View> CreateView();
37 52
38 PaymentRequestSpec* spec() { return spec_; } 53 PaymentRequestSpec* spec() { return spec_; }
39 PaymentRequestState* state() { return state_; } 54 PaymentRequestState* state() { return state_; }
40 55
41 // The dialog that contains and owns this object. 56 // The dialog that contains and owns this object.
42 // Caller should not take ownership of the result. 57 // Caller should not take ownership of the result.
43 PaymentRequestDialogView* dialog() { return dialog_; } 58 PaymentRequestDialogView* dialog() { return dialog_; }
44 59
45 protected: 60 protected:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 109
95 // Returns the view that should be initially focused on this sheet. Typically, 110 // 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 111 // 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 112 // 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 113 // 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 114 // called after the view has been completely created through calls to
100 // CreatePaymentView and related functions. 115 // CreatePaymentView and related functions.
101 virtual views::View* GetFirstFocusedView(); 116 virtual views::View* GetFirstFocusedView();
102 117
103 private: 118 private:
104 // Creates a view to be displayed in the PaymentRequestDialog.
105 // |header_view| is the view displayed on top of the dialog, containing title,
106 // (optional) back button, and close buttons.
107 // |content_view| is displayed between |header_view| and the pay/cancel
108 // buttons. Also adds the footer, returned by CreateFooterView(), which is
109 // clamped to the bottom of the containing view. The returned view takes
110 // ownership of |header_view|, |content_view|, and the footer.
111 // +---------------------------+
112 // | HEADER VIEW |
113 // +---------------------------+
114 // | CONTENT |
115 // | VIEW |
116 // +---------------------------+
117 // | EXTRA VIEW | PAY | CANCEL | <-- footer
118 // +---------------------------+
119 std::unique_ptr<views::View> CreatePaymentView();
120
121 // All these are not owned. Will outlive this. 119 // All these are not owned. Will outlive this.
122 PaymentRequestSpec* spec_; 120 PaymentRequestSpec* spec_;
123 PaymentRequestState* state_; 121 PaymentRequestState* state_;
124 PaymentRequestDialogView* dialog_; 122 PaymentRequestDialogView* dialog_;
125 123
126 // This view is owned by its encompassing ScrollView. 124 // This view is owned by its encompassing ScrollView.
127 views::View* pane_; 125 views::View* pane_;
128 views::View* content_view_; 126 views::View* content_view_;
129 127
130 // Hold on to the ScrollView because it must be explicitly laid out in some 128 // Hold on to the ScrollView because it must be explicitly laid out in some
131 // cases. 129 // cases.
132 std::unique_ptr<views::ScrollView> scroll_; 130 std::unique_ptr<views::ScrollView> scroll_;
133 131
134 // Hold on to the primary and secondary buttons to use them as initial focus 132 // 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. 133 // targets when subclasses don't want to focus anything else.
136 std::unique_ptr<views::Button> primary_button_; 134 std::unique_ptr<views::Button> primary_button_;
137 std::unique_ptr<views::Button> secondary_button_; 135 std::unique_ptr<views::Button> secondary_button_;
138 136
139 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); 137 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController);
140 }; 138 };
141 139
142 } // namespace payments 140 } // namespace payments
143 141
144 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ 142 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698