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

Side by Side Diff: components/autofill/core/browser/payments/full_card_request.cc

Issue 2794613002: Remove FullCardRequest's dependency on AutofillClient. (Closed)
Patch Set: Address comments. 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 "components/autofill/core/browser/payments/full_card_request.h" 5 #include "components/autofill/core/browser/payments/full_card_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "components/autofill/core/browser/autofill_metrics.h" 11 #include "components/autofill/core/browser/autofill_metrics.h"
12 #include "components/autofill/core/browser/credit_card.h" 12 #include "components/autofill/core/browser/credit_card.h"
13 #include "components/autofill/core/browser/personal_data_manager.h" 13 #include "components/autofill/core/browser/personal_data_manager.h"
14 #include "components/autofill/core/common/autofill_clock.h" 14 #include "components/autofill/core/common/autofill_clock.h"
15 15
16 namespace autofill { 16 namespace autofill {
17 namespace payments { 17 namespace payments {
18 18
19 FullCardRequest::FullCardRequest(AutofillClient* autofill_client, 19 FullCardRequest::FullCardRequest(RiskDataLoader* risk_data_loader,
20 payments::PaymentsClient* payments_client, 20 payments::PaymentsClient* payments_client,
21 PersonalDataManager* personal_data_manager) 21 PersonalDataManager* personal_data_manager)
22 : autofill_client_(autofill_client), 22 : risk_data_loader_(risk_data_loader),
23 payments_client_(payments_client), 23 payments_client_(payments_client),
24 personal_data_manager_(personal_data_manager), 24 personal_data_manager_(personal_data_manager),
25 result_delegate_(nullptr), 25 result_delegate_(nullptr),
26 ui_delegate_(nullptr), 26 ui_delegate_(nullptr),
27 should_unmask_card_(false), 27 should_unmask_card_(false),
28 weak_ptr_factory_(this) { 28 weak_ptr_factory_(this) {
29 DCHECK(autofill_client_); 29 DCHECK(risk_data_loader_);
30 DCHECK(payments_client_); 30 DCHECK(payments_client_);
31 DCHECK(personal_data_manager_); 31 DCHECK(personal_data_manager_);
32 } 32 }
33 33
34 FullCardRequest::~FullCardRequest() {} 34 FullCardRequest::~FullCardRequest() {}
35 35
36 void FullCardRequest::GetFullCard(const CreditCard& card, 36 void FullCardRequest::GetFullCard(const CreditCard& card,
37 AutofillClient::UnmaskCardReason reason, 37 AutofillClient::UnmaskCardReason reason,
38 base::WeakPtr<ResultDelegate> result_delegate, 38 base::WeakPtr<ResultDelegate> result_delegate,
39 base::WeakPtr<UIDelegate> ui_delegate) { 39 base::WeakPtr<UIDelegate> ui_delegate) {
(...skipping 15 matching lines...) Expand all
55 should_unmask_card_ = card.record_type() == CreditCard::MASKED_SERVER_CARD || 55 should_unmask_card_ = card.record_type() == CreditCard::MASKED_SERVER_CARD ||
56 (card.record_type() == CreditCard::FULL_SERVER_CARD && 56 (card.record_type() == CreditCard::FULL_SERVER_CARD &&
57 card.ShouldUpdateExpiration(AutofillClock::Now())); 57 card.ShouldUpdateExpiration(AutofillClock::Now()));
58 if (should_unmask_card_) 58 if (should_unmask_card_)
59 payments_client_->Prepare(); 59 payments_client_->Prepare();
60 60
61 ui_delegate_->ShowUnmaskPrompt(request_->card, reason, 61 ui_delegate_->ShowUnmaskPrompt(request_->card, reason,
62 weak_ptr_factory_.GetWeakPtr()); 62 weak_ptr_factory_.GetWeakPtr());
63 63
64 if (should_unmask_card_) { 64 if (should_unmask_card_) {
65 autofill_client_->LoadRiskData( 65 risk_data_loader_->LoadRiskData(
66 base::Bind(&FullCardRequest::OnDidGetUnmaskRiskData, 66 base::Bind(&FullCardRequest::OnDidGetUnmaskRiskData,
67 weak_ptr_factory_.GetWeakPtr())); 67 weak_ptr_factory_.GetWeakPtr()));
68 } 68 }
69 } 69 }
70 70
71 bool FullCardRequest::IsGettingFullCard() const { 71 bool FullCardRequest::IsGettingFullCard() const {
72 return !!request_; 72 return !!request_;
73 } 73 }
74 74
75 void FullCardRequest::OnUnmaskResponse(const UnmaskResponse& response) { 75 void FullCardRequest::OnUnmaskResponse(const UnmaskResponse& response) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 weak_ptr_factory_.InvalidateWeakPtrs(); 167 weak_ptr_factory_.InvalidateWeakPtrs();
168 payments_client_->CancelRequest(); 168 payments_client_->CancelRequest();
169 result_delegate_ = nullptr; 169 result_delegate_ = nullptr;
170 ui_delegate_ = nullptr; 170 ui_delegate_ = nullptr;
171 request_.reset(); 171 request_.reset();
172 should_unmask_card_ = false; 172 should_unmask_card_ = false;
173 } 173 }
174 174
175 } // namespace payments 175 } // namespace payments
176 } // namespace autofill 176 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/payments/full_card_request.h ('k') | components/autofill/core/browser/risk_data_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698