| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <memory> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "chrome/browser/ui/views/payments/view_stack.h" | |
| 13 #include "ui/views/window/dialog_delegate.h" | |
| 14 | |
| 15 namespace payments { | |
| 16 | |
| 17 class PaymentRequest; | |
| 18 class PaymentRequestSheetController; | |
| 19 | |
| 20 // Maps views owned by PaymentRequestDialog::view_stack_ to their controller. | |
| 21 // PaymentRequestDialog is responsible for listening for those views being | |
| 22 // removed from the hierarchy and delete the associated controllers. | |
| 23 using ControllerMap = | |
| 24 std::map<views::View*, std::unique_ptr<PaymentRequestSheetController>>; | |
| 25 | |
| 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 | |
| 28 // the WebPayments flow and managing the transition between those states. | |
| 29 class PaymentRequestDialog : public views::DialogDelegateView { | |
| 30 public: | |
| 31 class ObserverForTest { | |
| 32 public: | |
| 33 virtual void OnDialogOpened() = 0; | |
| 34 }; | |
| 35 | |
| 36 // Build a Dialog around the PaymentRequest object. |observer| is used to | |
| 37 // be notified of dialog events as they happen (but may be NULL) and should | |
| 38 // outlive this object. | |
| 39 PaymentRequestDialog(PaymentRequest* request, | |
| 40 PaymentRequestDialog::ObserverForTest* observer); | |
| 41 ~PaymentRequestDialog() override; | |
| 42 | |
| 43 // views::WidgetDelegate | |
| 44 ui::ModalType GetModalType() const override; | |
| 45 | |
| 46 // views::DialogDelegate | |
| 47 bool Cancel() override; | |
| 48 bool ShouldShowCloseButton() const override; | |
| 49 int GetDialogButtons() const override; | |
| 50 | |
| 51 void GoBack(); | |
| 52 void ShowOrderSummary(); | |
| 53 void ShowPaymentMethodSheet(); | |
| 54 void CloseDialog(); | |
| 55 | |
| 56 static void ShowWebModalPaymentDialog(PaymentRequestDialog* dialog, | |
| 57 PaymentRequest* request); | |
| 58 | |
| 59 private: | |
| 60 void ShowInitialPaymentSheet(); | |
| 61 | |
| 62 // views::View | |
| 63 gfx::Size GetPreferredSize() const override; | |
| 64 void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details) | |
| 65 override; | |
| 66 | |
| 67 // Non-owned reference to the PaymentRequest that initiated this dialog. Since | |
| 68 // the PaymentRequest object always outlives this one, the pointer should | |
| 69 // always be valid even though there is no direct ownership relationship | |
| 70 // between the two. | |
| 71 PaymentRequest* request_; | |
| 72 // May be null. | |
| 73 ObserverForTest* observer_; | |
| 74 ControllerMap controller_map_; | |
| 75 ViewStack view_stack_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(PaymentRequestDialog); | |
| 78 }; | |
| 79 | |
| 80 } // namespace payments | |
| 81 | |
| 82 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_DIALOG_H_ | |
| OLD | NEW |