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