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

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: BUILD 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 181 }
180 182
181 void PaymentRequestDialogView::ShowShippingOptionSheet() { 183 void PaymentRequestDialogView::ShowShippingOptionSheet() {
182 view_stack_.Push(CreateViewAndInstallController( 184 view_stack_.Push(CreateViewAndInstallController(
183 base::MakeUnique<ShippingOptionViewController>( 185 base::MakeUnique<ShippingOptionViewController>(
184 request_->spec(), request_->state(), this), 186 request_->spec(), request_->state(), this),
185 &controller_map_), 187 &controller_map_),
186 /* animate = */ true); 188 /* animate = */ true);
187 } 189 }
188 190
191 void PaymentRequestDialogView::ShowCvcUnmaskPrompt(
192 const autofill::CreditCard& credit_card,
193 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate>
194 result_delegate,
195 content::WebContents* web_contents) {
196 view_stack_.Push(CreateViewAndInstallController(
197 base::MakeUnique<CvcUnmaskViewController>(
198 request_->spec(), request_->state(), this,
199 credit_card, result_delegate, web_contents),
200 &controller_map_),
201 /* animate = */ true);
202 if (observer_for_testing_)
203 observer_for_testing_->OnCvcPromptShown();
204 }
205
189 void PaymentRequestDialogView::ShowCreditCardEditor() { 206 void PaymentRequestDialogView::ShowCreditCardEditor() {
190 view_stack_.Push(CreateViewAndInstallController( 207 view_stack_.Push(CreateViewAndInstallController(
191 base::MakeUnique<CreditCardEditorViewController>( 208 base::MakeUnique<CreditCardEditorViewController>(
192 request_->spec(), request_->state(), this), 209 request_->spec(), request_->state(), this),
193 &controller_map_), 210 &controller_map_),
194 /* animate = */ true); 211 /* animate = */ true);
195 if (observer_for_testing_) 212 if (observer_for_testing_)
196 observer_for_testing_->OnCreditCardEditorOpened(); 213 observer_for_testing_->OnCreditCardEditorOpened();
197 } 214 }
198 215
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // When a view that is associated with a controller is removed from this 250 // When a view that is associated with a controller is removed from this
234 // view's descendants, dispose of the controller. 251 // view's descendants, dispose of the controller.
235 if (!details.is_add && 252 if (!details.is_add &&
236 controller_map_.find(details.child) != controller_map_.end()) { 253 controller_map_.find(details.child) != controller_map_.end()) {
237 DCHECK(!details.move_view); 254 DCHECK(!details.move_view);
238 controller_map_.erase(details.child); 255 controller_map_.erase(details.child);
239 } 256 }
240 } 257 }
241 258
242 } // namespace payments 259 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698