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

Side by Side Diff: ios/chrome/browser/ui/payments/full_card_requester.mm

Issue 2959133002: [Payment Request] unit tests for the FullCardRequester (Closed)
Patch Set: Created 3 years, 5 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "ios/chrome/browser/ui/payments/full_card_requester.h" 5 #include "ios/chrome/browser/ui/payments/full_card_requester.h"
6 6
7 #include "components/autofill/core/browser/autofill_manager.h" 7 #include "components/autofill/core/browser/autofill_manager.h"
8 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h"
9 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 8 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
10 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h" 9 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h"
11 #include "ios/chrome/browser/ui/payments/payment_request_coordinator.h"
12 10
13 #if !defined(__has_feature) || !__has_feature(objc_arc) 11 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support." 12 #error "This file requires ARC support."
15 #endif 13 #endif
16 14
17 namespace { 15 namespace {
18 16
19 // The unmask prompt UI for Payment Request. 17 // The unmask prompt UI for Payment Request.
20 class PRCardUnmaskPromptViewBridge 18 class PRCardUnmaskPromptViewBridge
21 : public autofill::CardUnmaskPromptViewBridge { 19 : public autofill::CardUnmaskPromptViewBridge {
(...skipping 15 matching lines...) Expand all
37 completion:nil]; 35 completion:nil];
38 }; 36 };
39 37
40 private: 38 private:
41 __weak UIViewController* base_view_controller_; 39 __weak UIViewController* base_view_controller_;
42 DISALLOW_COPY_AND_ASSIGN(PRCardUnmaskPromptViewBridge); 40 DISALLOW_COPY_AND_ASSIGN(PRCardUnmaskPromptViewBridge);
43 }; 41 };
44 42
45 } // namespace 43 } // namespace
46 44
47 FullCardRequester::FullCardRequester(PaymentRequestCoordinator* owner, 45 FullCardRequester::FullCardRequester(id<FullCardRequesterConsumer> consumer,
48 UIViewController* base_view_controller, 46 UIViewController* base_view_controller,
49 ios::ChromeBrowserState* browser_state) 47 ios::ChromeBrowserState* browser_state)
50 : owner_(owner), 48 : consumer_(consumer),
51 base_view_controller_(base_view_controller), 49 base_view_controller_(base_view_controller),
52 unmask_controller_(browser_state->GetPrefs(), 50 unmask_controller_(browser_state->GetPrefs(),
53 browser_state->IsOffTheRecord()) {} 51 browser_state->IsOffTheRecord()) {}
54 52
55 void FullCardRequester::GetFullCard( 53 void FullCardRequester::GetFullCard(
56 autofill::CreditCard* card, 54 autofill::CreditCard* card,
57 autofill::AutofillManager* autofill_manager) { 55 autofill::AutofillManager* autofill_manager) {
58 DCHECK(card); 56 DCHECK(card);
59 DCHECK(autofill_manager); 57 DCHECK(autofill_manager);
60 autofill_manager->GetOrCreateFullCardRequest()->GetFullCard( 58 autofill_manager->GetOrCreateFullCardRequest()->GetFullCard(
61 *card, autofill::AutofillClient::UNMASK_FOR_PAYMENT_REQUEST, AsWeakPtr(), 59 *card, autofill::AutofillClient::UNMASK_FOR_PAYMENT_REQUEST, AsWeakPtr(),
62 AsWeakPtr()); 60 AsWeakPtr());
63 } 61 }
64 62
65 void FullCardRequester::OnFullCardRequestSucceeded( 63 void FullCardRequester::OnFullCardRequestSucceeded(
66 const autofill::CreditCard& card, 64 const autofill::CreditCard& card,
67 const base::string16& verificationCode) { 65 const base::string16& verificationCode) {
68 [owner_ fullCardRequestDidSucceedWithCard:card 66 [consumer_ fullCardRequestDidSucceedWithCard:card
69 verificationCode:verificationCode]; 67 verificationCode:verificationCode];
70 } 68 }
71 69
72 void FullCardRequester::OnFullCardRequestFailed() { 70 void FullCardRequester::OnFullCardRequestFailed() {
73 // No action is required here. PRCardUnmaskPromptViewBridge manages its own 71 // No action is required here. PRCardUnmaskPromptViewBridge manages its own
74 // life cycle. When the prompt is explicitly dismissed via tapping the close 72 // life cycle. When the prompt is explicitly dismissed via tapping the close
75 // button (either in presence or absence of an error), the unmask prompt 73 // button (either in presence or absence of an error), the unmask prompt
76 // dialog pops itself and the user is back to the Payment Request UI. 74 // dialog pops itself and the user is back to the Payment Request UI.
77 } 75 }
78 76
79 void FullCardRequester::ShowUnmaskPrompt( 77 void FullCardRequester::ShowUnmaskPrompt(
80 const autofill::CreditCard& card, 78 const autofill::CreditCard& card,
81 autofill::AutofillClient::UnmaskCardReason reason, 79 autofill::AutofillClient::UnmaskCardReason reason,
82 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) { 80 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) {
83 unmask_controller_.ShowPrompt( 81 unmask_controller_.ShowPrompt(
84 // PRCardUnmaskPromptViewBridge manages its own lifetime. 82 // PRCardUnmaskPromptViewBridge manages its own lifetime.
85 new PRCardUnmaskPromptViewBridge(&unmask_controller_, 83 new PRCardUnmaskPromptViewBridge(&unmask_controller_,
86 base_view_controller_), 84 base_view_controller_),
87 card, reason, delegate); 85 card, reason, delegate);
88 } 86 }
89 87
90 void FullCardRequester::OnUnmaskVerificationResult( 88 void FullCardRequester::OnUnmaskVerificationResult(
91 autofill::AutofillClient::PaymentsRpcResult result) { 89 autofill::AutofillClient::PaymentsRpcResult result) {
92 unmask_controller_.OnVerificationResult(result); 90 unmask_controller_.OnVerificationResult(result);
93 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698