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

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

Issue 2026353002: [Autofill] Credit Card Assist Infobar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 4 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/autofill/core/browser/assist_manager.h"
6
7 #include "base/containers/adapters.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "components/autofill/core/browser/autofill_experiments.h"
10 #include "components/autofill/core/browser/autofill_manager.h"
11 #include "components/autofill/core/browser/credit_card.h"
12 #include "components/autofill/core/browser/form_structure.h"
13 #include "components/autofill/core/common/autofill_constants.h"
14
15 namespace autofill {
16
17 AssistManager::AssistManager(AutofillManager* autofill_manager)
18 : credit_card_form_data_(nullptr),
19 autofill_manager_(autofill_manager),
20 weak_ptr_factory_(this) {}
21
22 AssistManager::~AssistManager() {}
23
24 void AssistManager::Reset() {
25 credit_card_form_data_.reset();
26 }
please use gerrit instead 2016/07/27 17:02:26 The order of methods here does not match the order
Mathieu 2016/07/27 21:35:52 Good catch!
27
28 bool AssistManager::CanShowCreditCardAssist(
29 const std::vector<FormStructure*>& form_structures) {
30 #if !defined(OS_ANDROID)
31 return false;
32 #else
33 if (!IsAutofillCreditCardAssistEnabled() || credit_card_form_data_)
34 return false;
35
36 for (FormStructure* cur_form : base::Reversed(form_structures)) {
37 if (cur_form->IsCompleteCreditCardForm()) {
38 credit_card_form_data_.reset(new FormData(cur_form->ToFormData()));
39 break;
40 }
41 }
42 return !!credit_card_form_data_;
43 #endif
44 }
45
46 void AssistManager::ShowAssistForCreditCard(const CreditCard& card) {
47 DCHECK(credit_card_form_data_);
48 autofill_manager_->client()->ConfirmCreditCardFillAssist(
49 card, base::Bind(&AssistManager::OnUserDidAcceptCreditCardFill,
50 weak_ptr_factory_.GetWeakPtr(), card));
51 }
52
53 void AssistManager::OnUserDidAcceptCreditCardFill(const CreditCard& card) {
54 // TODO(crbug.com/630656): Trigger CVC dialog flow for card filling.
please use gerrit instead 2016/07/27 17:02:26 Example of how to trigger the CVC dialog for your
Mathieu 2016/07/27 21:35:52 Thanks!
55 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_,
56 credit_card_form_data_->fields[0], card,
57 base::ASCIIToUTF16(""));
58 }
59
60 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698