| 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 12 matching lines...) Expand all Loading... |
| 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() || credit_card_form_data_ != nullptr || | 30 if (form_structures.empty() || credit_card_form_data_ != nullptr || |
| 31 !IsAutofillCreditCardAssistEnabled() || | 31 !IsAutofillCreditCardAssistEnabled() || |
| 32 !autofill_manager_->client()->IsContextSecure( | 32 !autofill_manager_->client()->IsContextSecure( |
| 33 form_structures.front()->source_url())) { | 33 form_structures.front()->source_url()) || |
| 34 !form_structures.front()->target_url().SchemeIs("https")) { |
| 34 return false; | 35 return false; |
| 35 } | 36 } |
| 36 | 37 |
| 37 for (FormStructure* cur_form : base::Reversed(form_structures)) { | 38 for (FormStructure* cur_form : base::Reversed(form_structures)) { |
| 38 if (cur_form->IsCompleteCreditCardForm()) { | 39 if (cur_form->IsCompleteCreditCardForm()) { |
| 39 credit_card_form_data_.reset(new FormData(cur_form->ToFormData())); | 40 credit_card_form_data_.reset(new FormData(cur_form->ToFormData())); |
| 40 break; | 41 break; |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 return credit_card_form_data_ != nullptr; | 44 return credit_card_form_data_ != nullptr; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 59 void AutofillAssistant::OnFullCardRequestSucceeded(const CreditCard& card, | 60 void AutofillAssistant::OnFullCardRequestSucceeded(const CreditCard& card, |
| 60 const base::string16& cvc) { | 61 const base::string16& cvc) { |
| 61 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_, | 62 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_, |
| 62 credit_card_form_data_->fields[0], card, | 63 credit_card_form_data_->fields[0], card, |
| 63 cvc); | 64 cvc); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void AutofillAssistant::OnFullCardRequestFailed() {} | 67 void AutofillAssistant::OnFullCardRequestFailed() {} |
| 67 | 68 |
| 68 } // namespace autofill | 69 } // namespace autofill |
| OLD | NEW |