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 #include "chrome/browser/ui/views/payments/payment_request_dialog.h" | 5 #include "chrome/browser/ui/views/payments/payment_request_dialog.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 ui::ModalType PaymentRequestDialog::GetModalType() const { | 64 ui::ModalType PaymentRequestDialog::GetModalType() const { |
65 return ui::MODAL_TYPE_CHILD; | 65 return ui::MODAL_TYPE_CHILD; |
66 } | 66 } |
67 | 67 |
68 bool PaymentRequestDialog::Cancel() { | 68 bool PaymentRequestDialog::Cancel() { |
69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
70 impl_->Cancel(); | 70 impl_->Cancel(); |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
| 74 bool PaymentRequestDialog::ShouldShowCloseButton() const { |
| 75 // Don't show the normal close button on the dialog. This is because the |
| 76 // typical dialog header doesn't allow displaying anything other that the |
| 77 // title and the close button. This is insufficient for the PaymentRequest |
| 78 // dialog, which must sometimes show the back arrow next to the title. |
| 79 // Moreover, the title (and back arrow) should animate with the view they're |
| 80 // attached to. |
| 81 return false; |
| 82 } |
| 83 |
| 84 int PaymentRequestDialog::GetDialogButtons() const { |
| 85 // The buttons should animate along with the different dialog sheets since |
| 86 // each sheet presents a different set of buttons. Because of this, hide the |
| 87 // usual dialog buttons. |
| 88 return ui::DIALOG_BUTTON_NONE; |
| 89 } |
| 90 |
74 void PaymentRequestDialog::GoBack() { | 91 void PaymentRequestDialog::GoBack() { |
75 view_stack_.Pop(); | 92 view_stack_.Pop(); |
76 } | 93 } |
77 | 94 |
78 void PaymentRequestDialog::ShowOrderSummary() { | 95 void PaymentRequestDialog::ShowOrderSummary() { |
79 view_stack_.Push( | 96 view_stack_.Push( |
80 CreateViewAndInstallController<OrderSummaryViewController>( | 97 CreateViewAndInstallController<OrderSummaryViewController>( |
81 &controller_map_, impl_, this), | 98 &controller_map_, impl_, this), |
82 true); | 99 true); |
83 } | 100 } |
84 | 101 |
| 102 void PaymentRequestDialog::CloseDialog() { |
| 103 GetWidget()->Close(); |
| 104 } |
| 105 |
85 void PaymentRequestDialog::ShowInitialPaymentSheet() { | 106 void PaymentRequestDialog::ShowInitialPaymentSheet() { |
86 view_stack_.Push( | 107 view_stack_.Push( |
87 CreateViewAndInstallController<PaymentSheetViewController>( | 108 CreateViewAndInstallController<PaymentSheetViewController>( |
88 &controller_map_, impl_, this), | 109 &controller_map_, impl_, this), |
89 false); | 110 false); |
90 } | 111 } |
91 | 112 |
92 gfx::Size PaymentRequestDialog::GetPreferredSize() const { | 113 gfx::Size PaymentRequestDialog::GetPreferredSize() const { |
93 return gfx::Size(450, 450); | 114 return gfx::Size(450, 450); |
94 } | 115 } |
95 | 116 |
96 void PaymentRequestDialog::ViewHierarchyChanged( | 117 void PaymentRequestDialog::ViewHierarchyChanged( |
97 const ViewHierarchyChangedDetails& details) { | 118 const ViewHierarchyChangedDetails& details) { |
98 // When a view that is associated with a controller is removed from this | 119 // When a view that is associated with a controller is removed from this |
99 // view's descendants, dispose of the controller. | 120 // view's descendants, dispose of the controller. |
100 if (!details.is_add && | 121 if (!details.is_add && |
101 controller_map_.find(details.child) != controller_map_.end()) { | 122 controller_map_.find(details.child) != controller_map_.end()) { |
102 DCHECK(!details.move_view); | 123 DCHECK(!details.move_view); |
103 controller_map_.erase(details.child); | 124 controller_map_.erase(details.child); |
104 } | 125 } |
105 } | 126 } |
106 | 127 |
107 } // namespace payments | 128 } // namespace payments |
OLD | NEW |