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

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

Issue 2748133004: [Payments] View controllers no longer have access to PaymentRequest (Closed)
Patch Set: Initial 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"
11 #include "ui/views/controls/button/vector_icon_button_delegate.h" 11 #include "ui/views/controls/button/vector_icon_button_delegate.h"
12 12
13 namespace views { 13 namespace views {
14 class Button; 14 class Button;
15 class View; 15 class View;
16 } 16 }
17 17
18 namespace payments { 18 namespace payments {
19 19
20 class PaymentRequestDialogView; 20 class PaymentRequestDialogView;
21 class PaymentRequest; 21 class PaymentRequestSpec;
22 class PaymentRequestState;
22 23
23 // The base class for objects responsible for the creation and event handling in 24 // The base class for objects responsible for the creation and event handling in
24 // views shown in the PaymentRequestDialog. 25 // views shown in the PaymentRequestDialog.
25 class PaymentRequestSheetController : public views::VectorIconButtonDelegate { 26 class PaymentRequestSheetController : public views::VectorIconButtonDelegate {
26 public: 27 public:
27 // Objects of this class are owned by |dialog|, so it's a non-owned pointer 28 // 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. 29 // that should be valid throughout this object's lifetime.
29 // |request| is also not owned by this and is guaranteed to outlive dialog. 30 // |state| and |spec| are also not owned by this and are guaranteed to outlive
30 // Neither |request| or |dialog| should be null. 31 // dialog. Neither |state|, |spec| or |dialog| should be null.
31 PaymentRequestSheetController(PaymentRequest* request, 32 PaymentRequestSheetController(PaymentRequestSpec* spec,
33 PaymentRequestState* state,
32 PaymentRequestDialogView* dialog); 34 PaymentRequestDialogView* dialog);
33 ~PaymentRequestSheetController() override {} 35 ~PaymentRequestSheetController() override {}
34 36
35 virtual std::unique_ptr<views::View> CreateView() = 0; 37 virtual std::unique_ptr<views::View> CreateView() = 0;
36 38
37 // The PaymentRequest object associated with this instance of the dialog. 39 PaymentRequestSpec* spec() { return spec_; }
38 // Caller should not take ownership of the result. 40 PaymentRequestState* state() { return state_; }
39 PaymentRequest* request() { return request_; }
40 41
41 // The dialog that contains and owns this object. 42 // The dialog that contains and owns this object.
42 // Caller should not take ownership of the result. 43 // Caller should not take ownership of the result.
43 PaymentRequestDialogView* dialog() { return dialog_; } 44 PaymentRequestDialogView* dialog() { return dialog_; }
44 45
45 protected: 46 protected:
46 // Creates and returns the primary action button for this sheet. It's 47 // 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 48 // 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 49 // 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 50 // button should be displayed. The caller takes ownership of the button but
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // +---------------------------+ 85 // +---------------------------+
85 std::unique_ptr<views::View> CreatePaymentView( 86 std::unique_ptr<views::View> CreatePaymentView(
86 std::unique_ptr<views::View> header_view, 87 std::unique_ptr<views::View> header_view,
87 std::unique_ptr<views::View> content_view); 88 std::unique_ptr<views::View> content_view);
88 89
89 // Creates the row of button containing the Pay, cancel, and extra buttons. 90 // Creates the row of button containing the Pay, cancel, and extra buttons.
90 // |controller| is installed as the listener for button events. 91 // |controller| is installed as the listener for button events.
91 std::unique_ptr<views::View> CreateFooterView(); 92 std::unique_ptr<views::View> CreateFooterView();
92 93
93 private: 94 private:
94 // Not owned. Will outlive this. 95 // All these are not owned. Will outlive this.
95 PaymentRequest* request_; 96 PaymentRequestSpec* spec_;
96 // Not owned. Will outlive this. 97 PaymentRequestState* state_;
97 PaymentRequestDialogView* dialog_; 98 PaymentRequestDialogView* dialog_;
98 99
99 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController); 100 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSheetController);
100 }; 101 };
101 102
102 } // namespace payments 103 } // namespace payments
103 104
104 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_ 105 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_SHEET_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698