Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 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 (!IsAutofillCreditCardAssistEnabled() || credit_card_form_data_) | 30 if (!IsAutofillCreditCardAssistEnabled() || credit_card_form_data_) |
| 31 return false; | 31 return false; |
| 32 | 32 |
| 33 for (FormStructure* cur_form : base::Reversed(form_structures)) { | 33 for (FormStructure* cur_form : base::Reversed(form_structures)) { |
| 34 if (cur_form->IsCompleteCreditCardForm()) { | 34 if (cur_form->IsCompleteCreditCardForm()) { |
| 35 credit_card_form_data_.reset(new FormData(cur_form->ToFormData())); | 35 const FormData& cur_form_data = cur_form->ToFormData(); |
|
sebsg
2016/08/19 14:23:01
Since forms sometimes have a lot of fields, I thin
Roger McFarlane (Chromium)
2016/08/19 15:23:41
Done.
| |
| 36 if (autofill_manager_->client()->IsContextSecure(cur_form_data.origin)) | |
| 37 credit_card_form_data_.reset(new FormData(cur_form_data)); | |
| 36 break; | 38 break; |
| 37 } | 39 } |
| 38 } | 40 } |
| 39 return !!credit_card_form_data_; | 41 return credit_card_form_data_ != nullptr; |
| 40 } | 42 } |
| 41 | 43 |
| 42 void AutofillAssistant::ShowAssistForCreditCard(const CreditCard& card) { | 44 void AutofillAssistant::ShowAssistForCreditCard(const CreditCard& card) { |
| 43 DCHECK(credit_card_form_data_); | 45 DCHECK(credit_card_form_data_); |
| 44 autofill_manager_->client()->ConfirmCreditCardFillAssist( | 46 autofill_manager_->client()->ConfirmCreditCardFillAssist( |
| 45 card, base::Bind(&AutofillAssistant::OnUserDidAcceptCreditCardFill, | 47 card, base::Bind(&AutofillAssistant::OnUserDidAcceptCreditCardFill, |
| 46 weak_ptr_factory_.GetWeakPtr(), card)); | 48 weak_ptr_factory_.GetWeakPtr(), card)); |
| 47 } | 49 } |
| 48 | 50 |
| 49 void AutofillAssistant::OnUserDidAcceptCreditCardFill(const CreditCard& card) { | 51 void AutofillAssistant::OnUserDidAcceptCreditCardFill(const CreditCard& card) { |
| 50 // TODO(crbug.com/630656): Trigger CVC dialog flow for card filling. | 52 // TODO(crbug.com/630656): Trigger CVC dialog flow for card filling. |
| 51 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_, | 53 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_, |
| 52 credit_card_form_data_->fields[0], card, | 54 credit_card_form_data_->fields[0], card, |
| 53 base::string16()); | 55 base::string16()); |
| 54 } | 56 } |
| 55 | 57 |
| 56 } // namespace autofill | 58 } // namespace autofill |
| OLD | NEW |