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

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

Issue 2779283002: [Web Payments] Implement the CVC Unmask dialog. (Closed)
Patch Set: Make CvcUnmaskViewController the UIDelegate for FullCardRequest. 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/cvc_unmask_view_controller.h"
12 #include "chrome/browser/ui/views/payments/error_message_view_controller.h" 13 #include "chrome/browser/ui/views/payments/error_message_view_controller.h"
13 #include "chrome/browser/ui/views/payments/order_summary_view_controller.h" 14 #include "chrome/browser/ui/views/payments/order_summary_view_controller.h"
14 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h" 15 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h"
15 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 16 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
16 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h" 17 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h"
17 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h" 18 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h"
18 #include "chrome/browser/ui/views/payments/shipping_address_editor_view_controll er.h" 19 #include "chrome/browser/ui/views/payments/shipping_address_editor_view_controll er.h"
19 #include "chrome/browser/ui/views/payments/shipping_option_view_controller.h" 20 #include "chrome/browser/ui/views/payments/shipping_option_view_controller.h"
20 #include "components/constrained_window/constrained_window_views.h" 21 #include "components/constrained_window/constrained_window_views.h"
21 #include "components/payments/content/payment_request.h" 22 #include "components/payments/content/payment_request.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "ui/views/layout/fill_layout.h" 24 #include "ui/views/layout/fill_layout.h"
24 25
25 namespace chrome { 26 namespace chrome {
26 27
27 payments::PaymentRequestDialog* CreatePaymentRequestDialog( 28 payments::PaymentRequestDialog* CreatePaymentRequestDialog(
28 payments::PaymentRequest* request) { 29 payments::PaymentRequest* request) {
29 return new payments::PaymentRequestDialogView(request, 30 return new payments::PaymentRequestDialogView(request,
30 /* no observer */ nullptr); 31 /* no observer */ nullptr);
31 } 32 }
32 33
33 } // namespace chrome 34 } // namespace chrome
34 35
35 namespace payments { 36 namespace payments {
37
36 namespace { 38 namespace {
37 39
38 // This function creates an instance of a PaymentRequestSheetController 40 // This function creates an instance of a PaymentRequestSheetController
39 // subclass of concrete type |Controller|, passing it non-owned pointers to 41 // subclass of concrete type |Controller|, passing it non-owned pointers to
40 // |dialog| and the |request| that initiated that dialog. |map| should be owned 42 // |dialog| and the |request| that initiated that dialog. |map| should be owned
41 // by |dialog|. 43 // by |dialog|.
42 std::unique_ptr<views::View> CreateViewAndInstallController( 44 std::unique_ptr<views::View> CreateViewAndInstallController(
43 std::unique_ptr<PaymentRequestSheetController> controller, 45 std::unique_ptr<PaymentRequestSheetController> controller,
44 payments::ControllerMap* map) { 46 payments::ControllerMap* map) {
45 std::unique_ptr<views::View> view = controller->CreateView(); 47 std::unique_ptr<views::View> view = controller->CreateView();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 173 }
172 174
173 void PaymentRequestDialogView::ShowShippingOptionSheet() { 175 void PaymentRequestDialogView::ShowShippingOptionSheet() {
174 view_stack_.Push(CreateViewAndInstallController( 176 view_stack_.Push(CreateViewAndInstallController(
175 base::MakeUnique<ShippingOptionViewController>( 177 base::MakeUnique<ShippingOptionViewController>(
176 request_->spec(), request_->state(), this), 178 request_->spec(), request_->state(), this),
177 &controller_map_), 179 &controller_map_),
178 /* animate = */ true); 180 /* animate = */ true);
179 } 181 }
180 182
183 void PaymentRequestDialogView::ShowCvcUnmaskPrompt(
184 const autofill::CreditCard& credit_card,
185 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate>
186 result_delegate) {
187 view_stack_.Push(
188 CreateViewAndInstallController(base::MakeUnique<CvcUnmaskViewController>(
189 request_->spec(), request_->state(),
190 this, credit_card, result_delegate),
191 &controller_map_),
192 /* animate = */ true);
193 }
194
181 void PaymentRequestDialogView::ShowCreditCardEditor() { 195 void PaymentRequestDialogView::ShowCreditCardEditor() {
182 view_stack_.Push(CreateViewAndInstallController( 196 view_stack_.Push(CreateViewAndInstallController(
183 base::MakeUnique<CreditCardEditorViewController>( 197 base::MakeUnique<CreditCardEditorViewController>(
184 request_->spec(), request_->state(), this), 198 request_->spec(), request_->state(), this),
185 &controller_map_), 199 &controller_map_),
186 /* animate = */ true); 200 /* animate = */ true);
187 if (observer_for_testing_) 201 if (observer_for_testing_)
188 observer_for_testing_->OnCreditCardEditorOpened(); 202 observer_for_testing_->OnCreditCardEditorOpened();
189 } 203 }
190 204
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // When a view that is associated with a controller is removed from this 239 // When a view that is associated with a controller is removed from this
226 // view's descendants, dispose of the controller. 240 // view's descendants, dispose of the controller.
227 if (!details.is_add && 241 if (!details.is_add &&
228 controller_map_.find(details.child) != controller_map_.end()) { 242 controller_map_.find(details.child) != controller_map_.end()) {
229 DCHECK(!details.move_view); 243 DCHECK(!details.move_view);
230 controller_map_.erase(details.child); 244 controller_map_.erase(details.child);
231 } 245 }
232 } 246 }
233 247
234 } // namespace payments 248 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698