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

Side by Side Diff: components/autofill/core/browser/autofill_assistant.cc

Issue 2254353002: Prompt for CVC in credit card assist. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better callback names Created 4 years, 3 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/autofill_assistant.h" 5 #include "components/autofill/core/browser/autofill_assistant.h"
6 6
7 #include "base/containers/adapters.h" 7 #include "base/containers/adapters.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "components/autofill/core/browser/autofill_experiments.h" 9 #include "components/autofill/core/browser/autofill_experiments.h"
10 #include "components/autofill/core/browser/autofill_manager.h" 10 #include "components/autofill/core/browser/autofill_manager.h"
11 #include "components/autofill/core/browser/credit_card.h" 11 #include "components/autofill/core/browser/credit_card.h"
12 #include "components/autofill/core/browser/form_structure.h" 12 #include "components/autofill/core/browser/form_structure.h"
13 #include "components/autofill/core/common/autofill_constants.h" 13 #include "components/autofill/core/common/autofill_constants.h"
14 14
15 namespace autofill { 15 namespace autofill {
16 16
17 AutofillAssistant::AutofillAssistant(AutofillManager* autofill_manager) 17 AutofillAssistant::AutofillAssistant(AutofillManager* autofill_manager)
18 : credit_card_form_data_(nullptr), 18 : credit_card_form_data_(nullptr),
19 autofill_manager_(autofill_manager), 19 autofill_manager_(autofill_manager),
20 weak_ptr_factory_(this) {} 20 weak_ptr_factory_(this) {}
21 21
22 AutofillAssistant::~AutofillAssistant() {} 22 AutofillAssistant::~AutofillAssistant() {}
23 23
24 void AutofillAssistant::Reset() { 24 void AutofillAssistant::Reset() {
25 credit_card_form_data_.reset(); 25 credit_card_form_data_.reset();
26 } 26 }
27 27
28 bool AutofillAssistant::CanShowCreditCardAssist( 28 bool AutofillAssistant::CanShowCreditCardAssist(
29 const std::vector<FormStructure*>& form_structures) { 29 const std::vector<FormStructure*>& form_structures) {
30 if (form_structures.empty() || 30 if (form_structures.empty() || credit_card_form_data_ != nullptr ||
31 credit_card_form_data_ != nullptr ||
32 !IsAutofillCreditCardAssistEnabled() || 31 !IsAutofillCreditCardAssistEnabled() ||
33 !autofill_manager_->client()->IsContextSecure( 32 !autofill_manager_->client()->IsContextSecure(
34 form_structures.front()->source_url())) { 33 form_structures.front()->source_url())) {
35 return false; 34 return false;
36 } 35 }
37 36
38 for (FormStructure* cur_form : base::Reversed(form_structures)) { 37 for (FormStructure* cur_form : base::Reversed(form_structures)) {
39 if (cur_form->IsCompleteCreditCardForm()) { 38 if (cur_form->IsCompleteCreditCardForm()) {
40 credit_card_form_data_.reset(new FormData(cur_form->ToFormData())); 39 credit_card_form_data_.reset(new FormData(cur_form->ToFormData()));
41 break; 40 break;
42 } 41 }
43 } 42 }
44 return credit_card_form_data_ != nullptr; 43 return credit_card_form_data_ != nullptr;
45 } 44 }
46 45
47 void AutofillAssistant::ShowAssistForCreditCard(const CreditCard& card) { 46 void AutofillAssistant::ShowAssistForCreditCard(const CreditCard& card) {
48 DCHECK(credit_card_form_data_); 47 DCHECK(credit_card_form_data_);
49 autofill_manager_->client()->ConfirmCreditCardFillAssist( 48 autofill_manager_->client()->ConfirmCreditCardFillAssist(
50 card, base::Bind(&AutofillAssistant::OnUserDidAcceptCreditCardFill, 49 card, base::Bind(&AutofillAssistant::OnUserDidAcceptCreditCardFill,
51 weak_ptr_factory_.GetWeakPtr(), card)); 50 weak_ptr_factory_.GetWeakPtr(), card));
52 } 51 }
53 52
54 void AutofillAssistant::OnUserDidAcceptCreditCardFill(const CreditCard& card) { 53 void AutofillAssistant::OnUserDidAcceptCreditCardFill(const CreditCard& card) {
55 // TODO(crbug.com/630656): Trigger CVC dialog flow for card filling. 54 autofill_manager_->GetOrCreateFullCardRequest()->GetFullCard(
55 card, AutofillClient::UNMASK_FOR_AUTOFILL,
56 weak_ptr_factory_.GetWeakPtr());
57 }
58
59 void AutofillAssistant::OnFullCardRequestSucceeded(const CreditCard& card,
60 const base::string16& cvc) {
56 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_, 61 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_,
57 credit_card_form_data_->fields[0], card, 62 credit_card_form_data_->fields[0], card,
58 base::string16()); 63 cvc);
59 } 64 }
60 65
66 void AutofillAssistant::OnFullCardRequestFailed() {}
67
61 } // namespace autofill 68 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_assistant.h ('k') | components/autofill/core/browser/autofill_assistant_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698