| 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 13 matching lines...) Expand all Loading... |
| 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<std::unique_ptr<FormStructure>>& form_structures) { | 29 const std::vector<std::unique_ptr<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 // Context of the page is not secure or target URL is valid but not | 32 // Context of the page is not secure or target URL is valid but not |
| 33 // secure. | 33 // secure. |
| 34 !(autofill_manager_->client()->IsContextSecure( | 34 !(autofill_manager_->client()->IsContextSecure() && |
| 35 form_structures.front()->source_url()) && | |
| 36 (!form_structures.front()->target_url().is_valid() || | 35 (!form_structures.front()->target_url().is_valid() || |
| 37 !form_structures.front()->target_url().SchemeIs("http")))) { | 36 !form_structures.front()->target_url().SchemeIs("http")))) { |
| 38 return false; | 37 return false; |
| 39 } | 38 } |
| 40 | 39 |
| 41 for (auto& cur_form : base::Reversed(form_structures)) { | 40 for (auto& cur_form : base::Reversed(form_structures)) { |
| 42 if (cur_form->IsCompleteCreditCardForm()) { | 41 if (cur_form->IsCompleteCreditCardForm()) { |
| 43 credit_card_form_data_.reset(new FormData(cur_form->ToFormData())); | 42 credit_card_form_data_.reset(new FormData(cur_form->ToFormData())); |
| 44 break; | 43 break; |
| 45 } | 44 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 63 void AutofillAssistant::OnFullCardRequestSucceeded(const CreditCard& card, | 62 void AutofillAssistant::OnFullCardRequestSucceeded(const CreditCard& card, |
| 64 const base::string16& cvc) { | 63 const base::string16& cvc) { |
| 65 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_, | 64 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_, |
| 66 credit_card_form_data_->fields[0], card, | 65 credit_card_form_data_->fields[0], card, |
| 67 cvc); | 66 cvc); |
| 68 } | 67 } |
| 69 | 68 |
| 70 void AutofillAssistant::OnFullCardRequestFailed() {} | 69 void AutofillAssistant::OnFullCardRequestFailed() {} |
| 71 | 70 |
| 72 } // namespace autofill | 71 } // namespace autofill |
| OLD | NEW |