Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_dialog_view.cc

Issue 2768093006: [Payments] Desktop: Error message in the dialog. (Closed)
Patch Set: Test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/credit_card_editor_view_controller.h" 11 #include "chrome/browser/ui/views/payments/credit_card_editor_view_controller.h"
12 #include "chrome/browser/ui/views/payments/error_message_view_controller.h"
12 #include "chrome/browser/ui/views/payments/order_summary_view_controller.h" 13 #include "chrome/browser/ui/views/payments/order_summary_view_controller.h"
13 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h" 14 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h"
14 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h" 15 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h"
15 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h" 16 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h"
16 #include "chrome/browser/ui/views/payments/shipping_address_editor_view_controll er.h" 17 #include "chrome/browser/ui/views/payments/shipping_address_editor_view_controll er.h"
17 #include "chrome/browser/ui/views/payments/shipping_option_view_controller.h" 18 #include "chrome/browser/ui/views/payments/shipping_option_view_controller.h"
18 #include "components/constrained_window/constrained_window_views.h" 19 #include "components/constrained_window/constrained_window_views.h"
19 #include "components/payments/content/payment_request.h" 20 #include "components/payments/content/payment_request.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "ui/views/layout/fill_layout.h" 22 #include "ui/views/layout/fill_layout.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return false; 89 return false;
89 } 90 }
90 91
91 int PaymentRequestDialogView::GetDialogButtons() const { 92 int PaymentRequestDialogView::GetDialogButtons() const {
92 // The buttons should animate along with the different dialog sheets since 93 // The buttons should animate along with the different dialog sheets since
93 // each sheet presents a different set of buttons. Because of this, hide the 94 // each sheet presents a different set of buttons. Because of this, hide the
94 // usual dialog buttons. 95 // usual dialog buttons.
95 return ui::DIALOG_BUTTON_NONE; 96 return ui::DIALOG_BUTTON_NONE;
96 } 97 }
97 98
99 void PaymentRequestDialogView::ShowDialog() {
100 constrained_window::ShowWebModalDialogViews(this, request_->web_contents());
101 }
102
103 void PaymentRequestDialogView::CloseDialog() {
104 // This calls PaymentRequestDialogView::Cancel() before closing.
105 // ViewHierarchyChanged() also gets called after Cancel().
106 GetWidget()->Close();
107 }
108
109 void PaymentRequestDialogView::ShowErrorMessage() {
110 view_stack_.Push(CreateViewAndInstallController(
111 base::MakeUnique<ErrorMessageViewController>(
112 request_->spec(), request_->state(), this),
113 &controller_map_),
114 /* animate = */ false);
115 if (observer_for_testing_)
116 observer_for_testing_->OnErrorMessageShown();
117 }
118
98 void PaymentRequestDialogView::Pay() { 119 void PaymentRequestDialogView::Pay() {
99 request_->Pay(); 120 request_->Pay();
100 } 121 }
101 122
102 void PaymentRequestDialogView::GoBack() { 123 void PaymentRequestDialogView::GoBack() {
103 view_stack_.Pop(); 124 view_stack_.Pop();
104 125
105 if (observer_for_testing_) 126 if (observer_for_testing_)
106 observer_for_testing_->OnBackNavigation(); 127 observer_for_testing_->OnBackNavigation();
107 } 128 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 /* animate = */ true); 195 /* animate = */ true);
175 if (observer_for_testing_) 196 if (observer_for_testing_)
176 observer_for_testing_->OnShippingAddressEditorOpened(); 197 observer_for_testing_->OnShippingAddressEditorOpened();
177 } 198 }
178 199
179 void PaymentRequestDialogView::EditorViewUpdated() { 200 void PaymentRequestDialogView::EditorViewUpdated() {
180 if (observer_for_testing_) 201 if (observer_for_testing_)
181 observer_for_testing_->OnEditorViewUpdated(); 202 observer_for_testing_->OnEditorViewUpdated();
182 } 203 }
183 204
184 void PaymentRequestDialogView::ShowDialog() {
185 constrained_window::ShowWebModalDialogViews(this, request_->web_contents());
186 }
187
188 void PaymentRequestDialogView::CloseDialog() {
189 // This calls PaymentRequestDialogView::Cancel() before closing.
190 // ViewHierarchyChanged() also gets called after Cancel().
191 GetWidget()->Close();
192 }
193
194 void PaymentRequestDialogView::ShowInitialPaymentSheet() { 205 void PaymentRequestDialogView::ShowInitialPaymentSheet() {
195 view_stack_.Push(CreateViewAndInstallController( 206 view_stack_.Push(CreateViewAndInstallController(
196 base::MakeUnique<PaymentSheetViewController>( 207 base::MakeUnique<PaymentSheetViewController>(
197 request_->spec(), request_->state(), this), 208 request_->spec(), request_->state(), this),
198 &controller_map_), 209 &controller_map_),
199 /* animate = */ false); 210 /* animate = */ false);
200 if (observer_for_testing_) 211 if (observer_for_testing_)
201 observer_for_testing_->OnDialogOpened(); 212 observer_for_testing_->OnDialogOpened();
202 } 213 }
203 214
204 gfx::Size PaymentRequestDialogView::GetPreferredSize() const { 215 gfx::Size PaymentRequestDialogView::GetPreferredSize() const {
205 return gfx::Size(450, 450); 216 return gfx::Size(450, 450);
206 } 217 }
207 218
208 void PaymentRequestDialogView::ViewHierarchyChanged( 219 void PaymentRequestDialogView::ViewHierarchyChanged(
209 const ViewHierarchyChangedDetails& details) { 220 const ViewHierarchyChangedDetails& details) {
210 if (being_closed_) 221 if (being_closed_)
211 return; 222 return;
212 223
213 // When a view that is associated with a controller is removed from this 224 // When a view that is associated with a controller is removed from this
214 // view's descendants, dispose of the controller. 225 // view's descendants, dispose of the controller.
215 if (!details.is_add && 226 if (!details.is_add &&
216 controller_map_.find(details.child) != controller_map_.end()) { 227 controller_map_.find(details.child) != controller_map_.end()) {
217 DCHECK(!details.move_view); 228 DCHECK(!details.move_view);
218 controller_map_.erase(details.child); 229 controller_map_.erase(details.child);
219 } 230 }
220 } 231 }
221 232
222 } // namespace payments 233 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698