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

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

Issue 2579513002: [WebPayments] Factor out sheet-specific logic in Controllers. (Closed)
Patch Set: Address comments. Created 4 years 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_DIALOG_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_H_
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_H_
7 7
8 #include <map>
9 #include <memory>
10
11 #include "base/macros.h"
8 #include "chrome/browser/ui/views/payments/view_stack.h" 12 #include "chrome/browser/ui/views/payments/view_stack.h"
9 #include "ui/views/controls/button/button.h"
10 #include "ui/views/window/dialog_delegate.h" 13 #include "ui/views/window/dialog_delegate.h"
11 14
12 class ViewStack; 15 class ViewStack;
13 16
14 namespace payments { 17 namespace payments {
15 18
16 class PaymentRequestImpl; 19 class PaymentRequestImpl;
20 class PaymentRequestSheetController;
21
22 // Maps views owned by PaymentRequestDialog::view_stack_ to their controller.
23 // PaymentRequestDialog is responsible for listening for those views being
24 // removed from the hierarchy and delete the associated controllers.
25 using ControllerMap =
26 std::map<views::View*, std::unique_ptr<PaymentRequestSheetController>>;
17 27
18 // The dialog delegate that represents a desktop WebPayments dialog. This class 28 // The dialog delegate that represents a desktop WebPayments dialog. This class
19 // is responsible for displaying the view associated with the current state of 29 // is responsible for displaying the view associated with the current state of
20 // the WebPayments flow and managing the transition between those states. 30 // the WebPayments flow and managing the transition between those states.
21 class PaymentRequestDialog : public views::DialogDelegateView, 31 class PaymentRequestDialog : public views::DialogDelegateView {
22 public views::ButtonListener {
23 public: 32 public:
24 explicit PaymentRequestDialog(PaymentRequestImpl* impl); 33 explicit PaymentRequestDialog(PaymentRequestImpl* impl);
25 ~PaymentRequestDialog() override; 34 ~PaymentRequestDialog() override;
26 35
27 // views::WidgetDelegate 36 // views::WidgetDelegate
28 ui::ModalType GetModalType() const override; 37 ui::ModalType GetModalType() const override;
29 38
30 // views::View
31 gfx::Size GetPreferredSize() const override;
32
33 // views::DialogDelegate 39 // views::DialogDelegate
34 bool Cancel() override; 40 bool Cancel() override;
35 41
42 void GoBack();
43 void ShowOrderSummary();
44
36 private: 45 private:
37 void ShowInitialPaymentSheet(); 46 void ShowInitialPaymentSheet();
38 void ShowOrderSummary();
39 void GoBack();
40 47
41 // views::ButtonListener: 48 // views::View
42 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 49 gfx::Size GetPreferredSize() const override;
50 void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details)
51 override;
43 52
44 // Non-owned reference to the PaymentRequestImpl that initiated this dialog. 53 // Non-owned reference to the PaymentRequestImpl that initiated this dialog.
45 // Since the PaymentRequestImpl object always outlives this one, the pointer 54 // Since the PaymentRequestImpl object always outlives this one, the pointer
46 // should always be valid even though there is no direct ownership 55 // should always be valid even though there is no direct ownership
47 // relationship between the two. 56 // relationship between the two.
48 PaymentRequestImpl* impl_; 57 PaymentRequestImpl* impl_;
58 ControllerMap controller_map_;
49 ViewStack view_stack_; 59 ViewStack view_stack_;
50 60
51 DISALLOW_COPY_AND_ASSIGN(PaymentRequestDialog); 61 DISALLOW_COPY_AND_ASSIGN(PaymentRequestDialog);
52 }; 62 };
53 63
54 } // namespace payments 64 } // namespace payments
55 65
56 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_H_ 66 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698