| 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_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_VIEW_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 "components/payments/content/payment_request_dialog.h" | 13 #include "components/payments/content/payment_request_dialog.h" |
| 14 #include "components/payments/content/payment_request_spec.h" |
| 14 #include "ui/views/window/dialog_delegate.h" | 15 #include "ui/views/window/dialog_delegate.h" |
| 15 | 16 |
| 16 namespace payments { | 17 namespace payments { |
| 17 | 18 |
| 18 class PaymentRequest; | 19 class PaymentRequest; |
| 19 class PaymentRequestSheetController; | 20 class PaymentRequestSheetController; |
| 20 | 21 |
| 21 // Maps views owned by PaymentRequestDialogView::view_stack_ to their | 22 // Maps views owned by PaymentRequestDialogView::view_stack_ to their |
| 22 // controller. PaymentRequestDialogView is responsible for listening for those | 23 // controller. PaymentRequestDialogView is responsible for listening for those |
| 23 // views being removed from the hierarchy and delete the associated controllers. | 24 // views being removed from the hierarchy and delete the associated controllers. |
| 24 using ControllerMap = | 25 using ControllerMap = |
| 25 std::map<views::View*, std::unique_ptr<PaymentRequestSheetController>>; | 26 std::map<views::View*, std::unique_ptr<PaymentRequestSheetController>>; |
| 26 | 27 |
| 27 // The dialog delegate that represents a desktop WebPayments dialog. This class | 28 // The dialog delegate that represents a desktop WebPayments dialog. This class |
| 28 // 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 |
| 29 // the WebPayments flow and managing the transition between those states. | 30 // the WebPayments flow and managing the transition between those states. |
| 30 class PaymentRequestDialogView : public views::DialogDelegateView, | 31 class PaymentRequestDialogView : public views::DialogDelegateView, |
| 31 public PaymentRequestDialog { | 32 public PaymentRequestDialog, |
| 33 public PaymentRequestSpec::Observer { |
| 32 public: | 34 public: |
| 33 class ObserverForTest { | 35 class ObserverForTest { |
| 34 public: | 36 public: |
| 35 virtual void OnDialogOpened() = 0; | 37 virtual void OnDialogOpened() = 0; |
| 36 | 38 |
| 37 virtual void OnContactInfoOpened() = 0; | 39 virtual void OnContactInfoOpened() = 0; |
| 38 | 40 |
| 39 virtual void OnOrderSummaryOpened() = 0; | 41 virtual void OnOrderSummaryOpened() = 0; |
| 40 | 42 |
| 41 virtual void OnPaymentMethodOpened() = 0; | 43 virtual void OnPaymentMethodOpened() = 0; |
| 42 | 44 |
| 43 virtual void OnShippingSectionOpened() = 0; | 45 virtual void OnShippingSectionOpened() = 0; |
| 44 | 46 |
| 45 virtual void OnCreditCardEditorOpened() = 0; | 47 virtual void OnCreditCardEditorOpened() = 0; |
| 46 | 48 |
| 47 virtual void OnShippingAddressEditorOpened() = 0; | 49 virtual void OnShippingAddressEditorOpened() = 0; |
| 48 | 50 |
| 49 virtual void OnBackNavigation() = 0; | 51 virtual void OnBackNavigation() = 0; |
| 50 | 52 |
| 51 virtual void OnEditorViewUpdated() = 0; | 53 virtual void OnEditorViewUpdated() = 0; |
| 52 | 54 |
| 53 virtual void OnErrorMessageShown() = 0; | 55 virtual void OnErrorMessageShown() = 0; |
| 56 |
| 57 virtual void OnSpecDoneUpdating() = 0; |
| 54 }; | 58 }; |
| 55 | 59 |
| 56 // Build a Dialog around the PaymentRequest object. |observer| is used to | 60 // Build a Dialog around the PaymentRequest object. |observer| is used to |
| 57 // be notified of dialog events as they happen (but may be NULL) and should | 61 // be notified of dialog events as they happen (but may be NULL) and should |
| 58 // outlive this object. | 62 // outlive this object. |
| 59 PaymentRequestDialogView(PaymentRequest* request, | 63 PaymentRequestDialogView(PaymentRequest* request, |
| 60 PaymentRequestDialogView::ObserverForTest* observer); | 64 PaymentRequestDialogView::ObserverForTest* observer); |
| 61 ~PaymentRequestDialogView() override; | 65 ~PaymentRequestDialogView() override; |
| 62 | 66 |
| 63 // views::WidgetDelegate | 67 // views::WidgetDelegate: |
| 64 ui::ModalType GetModalType() const override; | 68 ui::ModalType GetModalType() const override; |
| 65 | 69 |
| 66 // views::DialogDelegate | 70 // views::DialogDelegate: |
| 67 bool Cancel() override; | 71 bool Cancel() override; |
| 68 bool ShouldShowCloseButton() const override; | 72 bool ShouldShowCloseButton() const override; |
| 69 int GetDialogButtons() const override; | 73 int GetDialogButtons() const override; |
| 70 | 74 |
| 71 // payments::PaymentRequestDialog | 75 // payments::PaymentRequestDialog: |
| 72 void ShowDialog() override; | 76 void ShowDialog() override; |
| 73 void CloseDialog() override; | 77 void CloseDialog() override; |
| 74 void ShowErrorMessage() override; | 78 void ShowErrorMessage() override; |
| 75 | 79 |
| 80 // PaymentRequestSpec::Observer: |
| 81 void OnInvalidSpecProvided() override {} |
| 82 void OnSpecUpdated() override; |
| 83 |
| 76 void Pay(); | 84 void Pay(); |
| 77 void GoBack(); | 85 void GoBack(); |
| 78 void ShowContactProfileSheet(); | 86 void ShowContactProfileSheet(); |
| 79 void ShowOrderSummary(); | 87 void ShowOrderSummary(); |
| 80 void ShowShippingProfileSheet(); | 88 void ShowShippingProfileSheet(); |
| 81 void ShowPaymentMethodSheet(); | 89 void ShowPaymentMethodSheet(); |
| 82 void ShowShippingOptionSheet(); | 90 void ShowShippingOptionSheet(); |
| 83 void ShowCreditCardEditor(); | 91 void ShowCreditCardEditor(); |
| 84 void ShowShippingAddressEditor(); | 92 void ShowShippingAddressEditor(); |
| 85 void EditorViewUpdated(); | 93 void EditorViewUpdated(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 108 // Used when the dialog is being closed to avoid re-entrancy into the | 116 // Used when the dialog is being closed to avoid re-entrancy into the |
| 109 // controller_map_. | 117 // controller_map_. |
| 110 bool being_closed_; | 118 bool being_closed_; |
| 111 | 119 |
| 112 DISALLOW_COPY_AND_ASSIGN(PaymentRequestDialogView); | 120 DISALLOW_COPY_AND_ASSIGN(PaymentRequestDialogView); |
| 113 }; | 121 }; |
| 114 | 122 |
| 115 } // namespace payments | 123 } // namespace payments |
| 116 | 124 |
| 117 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_VIEW_H_ | 125 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_VIEW_H_ |
| OLD | NEW |