| 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_view.h" | 5 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return false; | 87 return false; |
| 88 } | 88 } |
| 89 | 89 |
| 90 int PaymentRequestDialogView::GetDialogButtons() const { | 90 int PaymentRequestDialogView::GetDialogButtons() const { |
| 91 // The buttons should animate along with the different dialog sheets since | 91 // The buttons should animate along with the different dialog sheets since |
| 92 // each sheet presents a different set of buttons. Because of this, hide the | 92 // each sheet presents a different set of buttons. Because of this, hide the |
| 93 // usual dialog buttons. | 93 // usual dialog buttons. |
| 94 return ui::DIALOG_BUTTON_NONE; | 94 return ui::DIALOG_BUTTON_NONE; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void PaymentRequestDialogView::Pay() { |
| 98 request_->Pay(); |
| 99 } |
| 100 |
| 97 void PaymentRequestDialogView::GoBack() { | 101 void PaymentRequestDialogView::GoBack() { |
| 98 view_stack_.Pop(); | 102 view_stack_.Pop(); |
| 99 | 103 |
| 100 if (observer_for_testing_) | 104 if (observer_for_testing_) |
| 101 observer_for_testing_->OnBackNavigation(); | 105 observer_for_testing_->OnBackNavigation(); |
| 102 } | 106 } |
| 103 | 107 |
| 104 void PaymentRequestDialogView::ShowContactProfileSheet() { | 108 void PaymentRequestDialogView::ShowContactProfileSheet() { |
| 105 view_stack_.Push( | 109 view_stack_.Push( |
| 106 CreateViewAndInstallController( | 110 CreateViewAndInstallController( |
| 107 ProfileListViewController::GetContactProfileViewController(request_, | 111 ProfileListViewController::GetContactProfileViewController( |
| 108 this), | 112 request_->spec(), request_->state(), this), |
| 109 &controller_map_), | 113 &controller_map_), |
| 110 /* animate */ true); | 114 /* animate */ true); |
| 111 if (observer_for_testing_) | 115 if (observer_for_testing_) |
| 112 observer_for_testing_->OnContactInfoOpened(); | 116 observer_for_testing_->OnContactInfoOpened(); |
| 113 } | 117 } |
| 114 | 118 |
| 115 void PaymentRequestDialogView::ShowOrderSummary() { | 119 void PaymentRequestDialogView::ShowOrderSummary() { |
| 116 view_stack_.Push( | 120 view_stack_.Push(CreateViewAndInstallController( |
| 117 CreateViewAndInstallController( | 121 base::MakeUnique<OrderSummaryViewController>( |
| 118 base::MakeUnique<OrderSummaryViewController>(request_, this), | 122 request_->spec(), request_->state(), this), |
| 119 &controller_map_), | 123 &controller_map_), |
| 120 /* animate = */ true); | 124 /* animate = */ true); |
| 121 if (observer_for_testing_) | 125 if (observer_for_testing_) |
| 122 observer_for_testing_->OnOrderSummaryOpened(); | 126 observer_for_testing_->OnOrderSummaryOpened(); |
| 123 } | 127 } |
| 124 | 128 |
| 125 void PaymentRequestDialogView::ShowPaymentMethodSheet() { | 129 void PaymentRequestDialogView::ShowPaymentMethodSheet() { |
| 126 view_stack_.Push( | 130 view_stack_.Push(CreateViewAndInstallController( |
| 127 CreateViewAndInstallController( | 131 base::MakeUnique<PaymentMethodViewController>( |
| 128 base::MakeUnique<PaymentMethodViewController>(request_, this), | 132 request_->spec(), request_->state(), this), |
| 129 &controller_map_), | 133 &controller_map_), |
| 130 /* animate = */ true); | 134 /* animate = */ true); |
| 131 if (observer_for_testing_) | 135 if (observer_for_testing_) |
| 132 observer_for_testing_->OnPaymentMethodOpened(); | 136 observer_for_testing_->OnPaymentMethodOpened(); |
| 133 } | 137 } |
| 134 | 138 |
| 135 void PaymentRequestDialogView::ShowShippingProfileSheet() { | 139 void PaymentRequestDialogView::ShowShippingProfileSheet() { |
| 136 view_stack_.Push( | 140 view_stack_.Push( |
| 137 CreateViewAndInstallController( | 141 CreateViewAndInstallController( |
| 138 ProfileListViewController::GetShippingProfileViewController(request_, | 142 ProfileListViewController::GetShippingProfileViewController( |
| 139 this), | 143 request_->spec(), request_->state(), this), |
| 140 &controller_map_), | 144 &controller_map_), |
| 141 /* animate = */ true); | 145 /* animate = */ true); |
| 142 } | 146 } |
| 143 | 147 |
| 144 void PaymentRequestDialogView::ShowShippingOptionSheet() { | 148 void PaymentRequestDialogView::ShowShippingOptionSheet() { |
| 145 view_stack_.Push( | 149 view_stack_.Push(CreateViewAndInstallController( |
| 146 CreateViewAndInstallController( | 150 base::MakeUnique<ShippingOptionViewController>( |
| 147 base::MakeUnique<ShippingOptionViewController>(request_, this), | 151 request_->spec(), request_->state(), this), |
| 148 &controller_map_), | 152 &controller_map_), |
| 149 /* animate = */ true); | 153 /* animate = */ true); |
| 150 } | 154 } |
| 151 | 155 |
| 152 void PaymentRequestDialogView::ShowCreditCardEditor() { | 156 void PaymentRequestDialogView::ShowCreditCardEditor() { |
| 153 view_stack_.Push( | 157 view_stack_.Push(CreateViewAndInstallController( |
| 154 CreateViewAndInstallController( | 158 base::MakeUnique<CreditCardEditorViewController>( |
| 155 base::MakeUnique<CreditCardEditorViewController>(request_, this), | 159 request_->spec(), request_->state(), this), |
| 156 &controller_map_), | 160 &controller_map_), |
| 157 /* animate = */ true); | 161 /* animate = */ true); |
| 158 if (observer_for_testing_) | 162 if (observer_for_testing_) |
| 159 observer_for_testing_->OnCreditCardEditorOpened(); | 163 observer_for_testing_->OnCreditCardEditorOpened(); |
| 160 } | 164 } |
| 161 | 165 |
| 162 void PaymentRequestDialogView::ShowDialog() { | 166 void PaymentRequestDialogView::ShowDialog() { |
| 163 constrained_window::ShowWebModalDialogViews(this, request_->web_contents()); | 167 constrained_window::ShowWebModalDialogViews(this, request_->web_contents()); |
| 164 } | 168 } |
| 165 | 169 |
| 166 void PaymentRequestDialogView::CloseDialog() { | 170 void PaymentRequestDialogView::CloseDialog() { |
| 167 // This calls PaymentRequestDialogView::Cancel() before closing. | 171 // This calls PaymentRequestDialogView::Cancel() before closing. |
| 168 // ViewHierarchyChanged() also gets called after Cancel(). | 172 // ViewHierarchyChanged() also gets called after Cancel(). |
| 169 GetWidget()->Close(); | 173 GetWidget()->Close(); |
| 170 } | 174 } |
| 171 | 175 |
| 172 void PaymentRequestDialogView::ShowInitialPaymentSheet() { | 176 void PaymentRequestDialogView::ShowInitialPaymentSheet() { |
| 173 view_stack_.Push( | 177 view_stack_.Push(CreateViewAndInstallController( |
| 174 CreateViewAndInstallController( | 178 base::MakeUnique<PaymentSheetViewController>( |
| 175 base::MakeUnique<PaymentSheetViewController>(request_, this), | 179 request_->spec(), request_->state(), this), |
| 176 &controller_map_), | 180 &controller_map_), |
| 177 /* animate = */ false); | 181 /* animate = */ false); |
| 178 if (observer_for_testing_) | 182 if (observer_for_testing_) |
| 179 observer_for_testing_->OnDialogOpened(); | 183 observer_for_testing_->OnDialogOpened(); |
| 180 } | 184 } |
| 181 | 185 |
| 182 gfx::Size PaymentRequestDialogView::GetPreferredSize() const { | 186 gfx::Size PaymentRequestDialogView::GetPreferredSize() const { |
| 183 return gfx::Size(450, 450); | 187 return gfx::Size(450, 450); |
| 184 } | 188 } |
| 185 | 189 |
| 186 void PaymentRequestDialogView::ViewHierarchyChanged( | 190 void PaymentRequestDialogView::ViewHierarchyChanged( |
| 187 const ViewHierarchyChangedDetails& details) { | 191 const ViewHierarchyChangedDetails& details) { |
| 188 if (being_closed_) | 192 if (being_closed_) |
| 189 return; | 193 return; |
| 190 | 194 |
| 191 // When a view that is associated with a controller is removed from this | 195 // When a view that is associated with a controller is removed from this |
| 192 // view's descendants, dispose of the controller. | 196 // view's descendants, dispose of the controller. |
| 193 if (!details.is_add && | 197 if (!details.is_add && |
| 194 controller_map_.find(details.child) != controller_map_.end()) { | 198 controller_map_.find(details.child) != controller_map_.end()) { |
| 195 DCHECK(!details.move_view); | 199 DCHECK(!details.move_view); |
| 196 controller_map_.erase(details.child); | 200 controller_map_.erase(details.child); |
| 197 } | 201 } |
| 198 } | 202 } |
| 199 | 203 |
| 200 } // namespace payments | 204 } // namespace payments |
| OLD | NEW |