| 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" |
| 11 #include "chrome/browser/ui/views/payments/order_summary_view_controller.h" | 11 #include "chrome/browser/ui/views/payments/order_summary_view_controller.h" |
| 12 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h" | 12 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h" |
| 13 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h" | 13 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h" |
| 14 #include "chrome/browser/ui/views/payments/shipping_list_view_controller.h" |
| 14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 15 #include "components/constrained_window/constrained_window_views.h" | 16 #include "components/constrained_window/constrained_window_views.h" |
| 16 #include "components/payments/payment_request.h" | 17 #include "components/payments/payment_request.h" |
| 17 #include "components/payments/payment_request_dialog.h" | |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/views/layout/fill_layout.h" | 20 #include "ui/views/layout/fill_layout.h" |
| 21 | 21 |
| 22 namespace chrome { | 22 namespace chrome { |
| 23 | 23 |
| 24 payments::PaymentRequestDialog* CreatePaymentRequestDialog( | 24 payments::PaymentRequestDialog* CreatePaymentRequestDialog( |
| 25 payments::PaymentRequest* request) { | 25 payments::PaymentRequest* request) { |
| 26 return new payments::PaymentRequestDialogView(request, | 26 return new payments::PaymentRequestDialogView(request, |
| 27 /* no observer */ nullptr); | 27 /* no observer */ nullptr); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 return ui::DIALOG_BUTTON_NONE; | 94 return ui::DIALOG_BUTTON_NONE; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void PaymentRequestDialogView::GoBack() { | 97 void PaymentRequestDialogView::GoBack() { |
| 98 view_stack_.Pop(); | 98 view_stack_.Pop(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void PaymentRequestDialogView::ShowOrderSummary() { | 101 void PaymentRequestDialogView::ShowOrderSummary() { |
| 102 view_stack_.Push(CreateViewAndInstallController<OrderSummaryViewController>( | 102 view_stack_.Push(CreateViewAndInstallController<OrderSummaryViewController>( |
| 103 &controller_map_, request_, this), | 103 &controller_map_, request_, this), |
| 104 true); | 104 /* animate = */ true); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void PaymentRequestDialogView::ShowPaymentMethodSheet() { | 107 void PaymentRequestDialogView::ShowPaymentMethodSheet() { |
| 108 view_stack_.Push(CreateViewAndInstallController<PaymentMethodViewController>( | 108 view_stack_.Push(CreateViewAndInstallController<PaymentMethodViewController>( |
| 109 &controller_map_, request_, this), | 109 &controller_map_, request_, this), |
| 110 true); | 110 /* animate = */ true); |
| 111 } |
| 112 |
| 113 void PaymentRequestDialogView::ShowShippingListSheet() { |
| 114 view_stack_.Push(CreateViewAndInstallController<ShippingListViewController>( |
| 115 &controller_map_, request_, this), |
| 116 /* animate = */ true); |
| 111 } | 117 } |
| 112 | 118 |
| 113 void PaymentRequestDialogView::ShowDialog() { | 119 void PaymentRequestDialogView::ShowDialog() { |
| 114 constrained_window::ShowWebModalDialogViews(this, request_->web_contents()); | 120 constrained_window::ShowWebModalDialogViews(this, request_->web_contents()); |
| 115 } | 121 } |
| 116 | 122 |
| 117 void PaymentRequestDialogView::CloseDialog() { | 123 void PaymentRequestDialogView::CloseDialog() { |
| 118 // This calls PaymentRequestDialogView::Cancel() before closing. | 124 // This calls PaymentRequestDialogView::Cancel() before closing. |
| 119 GetWidget()->Close(); | 125 GetWidget()->Close(); |
| 120 } | 126 } |
| 121 | 127 |
| 122 void PaymentRequestDialogView::ShowInitialPaymentSheet() { | 128 void PaymentRequestDialogView::ShowInitialPaymentSheet() { |
| 123 view_stack_.Push(CreateViewAndInstallController<PaymentSheetViewController>( | 129 view_stack_.Push(CreateViewAndInstallController<PaymentSheetViewController>( |
| 124 &controller_map_, request_, this), | 130 &controller_map_, request_, this), |
| 125 false); | 131 /* animate = */ false); |
| 126 if (observer_for_testing_) | 132 if (observer_for_testing_) |
| 127 observer_for_testing_->OnDialogOpened(); | 133 observer_for_testing_->OnDialogOpened(); |
| 128 } | 134 } |
| 129 | 135 |
| 130 gfx::Size PaymentRequestDialogView::GetPreferredSize() const { | 136 gfx::Size PaymentRequestDialogView::GetPreferredSize() const { |
| 131 return gfx::Size(450, 450); | 137 return gfx::Size(450, 450); |
| 132 } | 138 } |
| 133 | 139 |
| 134 void PaymentRequestDialogView::ViewHierarchyChanged( | 140 void PaymentRequestDialogView::ViewHierarchyChanged( |
| 135 const ViewHierarchyChangedDetails& details) { | 141 const ViewHierarchyChangedDetails& details) { |
| 136 // When a view that is associated with a controller is removed from this | 142 // When a view that is associated with a controller is removed from this |
| 137 // view's descendants, dispose of the controller. | 143 // view's descendants, dispose of the controller. |
| 138 if (!details.is_add && | 144 if (!details.is_add && |
| 139 controller_map_.find(details.child) != controller_map_.end()) { | 145 controller_map_.find(details.child) != controller_map_.end()) { |
| 140 DCHECK(!details.move_view); | 146 DCHECK(!details.move_view); |
| 141 controller_map_.erase(details.child); | 147 controller_map_.erase(details.child); |
| 142 } | 148 } |
| 143 } | 149 } |
| 144 | 150 |
| 145 } // namespace payments | 151 } // namespace payments |
| OLD | NEW |