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

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

Issue 2432063003: [Autofill] Offer credit card suggestions for some form action. (Closed)
Patch Set: added a test Created 4 years, 2 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
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_assistant_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 11 matching lines...) Expand all
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<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 !autofill_manager_->client()->IsContextSecure( 32 // Context of the page is not secure or target URL is valid but not
33 form_structures.front()->source_url()) || 33 // secure.
34 !form_structures.front()->target_url().SchemeIs("https")) { 34 !(autofill_manager_->client()->IsContextSecure(
35 form_structures.front()->source_url()) &&
36 (!form_structures.front()->target_url().is_valid() ||
37 !form_structures.front()->target_url().SchemeIs("http")))) {
35 return false; 38 return false;
36 } 39 }
37 40
38 for (auto& cur_form : base::Reversed(form_structures)) { 41 for (auto& cur_form : base::Reversed(form_structures)) {
39 if (cur_form->IsCompleteCreditCardForm()) { 42 if (cur_form->IsCompleteCreditCardForm()) {
40 credit_card_form_data_.reset(new FormData(cur_form->ToFormData())); 43 credit_card_form_data_.reset(new FormData(cur_form->ToFormData()));
41 break; 44 break;
42 } 45 }
43 } 46 }
44 return credit_card_form_data_ != nullptr; 47 return credit_card_form_data_ != nullptr;
(...skipping 15 matching lines...) Expand all
60 void AutofillAssistant::OnFullCardRequestSucceeded(const CreditCard& card, 63 void AutofillAssistant::OnFullCardRequestSucceeded(const CreditCard& card,
61 const base::string16& cvc) { 64 const base::string16& cvc) {
62 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_, 65 autofill_manager_->FillCreditCardForm(kNoQueryId, *credit_card_form_data_,
63 credit_card_form_data_->fields[0], card, 66 credit_card_form_data_->fields[0], card,
64 cvc); 67 cvc);
65 } 68 }
66 69
67 void AutofillAssistant::OnFullCardRequestFailed() {} 70 void AutofillAssistant::OnFullCardRequestFailed() {}
68 71
69 } // namespace autofill 72 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_assistant_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698