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

Unified Diff: components/autofill/core/browser/autofill_manager.cc

Issue 2676513007: Do not show Scan or Sign In options when credit card form is non-secure (Closed)
Patch Set: Add unit tests Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_manager.cc
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index 72cf42156b3eb55a299558fdbe890ff651ddb29b..87c8d54fafac90ade40c4a2c5c679f8442fe2279 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -309,6 +309,9 @@ bool AutofillManager::ShouldShowScanCreditCard(const FormData& form,
if (!is_card_number_field && !is_scannable_name_on_card_field)
return false;
+ if (IsFormNonSecure(form))
+ return false;
+
static const int kShowScanCreditCardMaxValueLength = 6;
return field.value.size() <= kShowScanCreditCardMaxValueLength;
}
@@ -329,6 +332,9 @@ bool AutofillManager::ShouldShowCreditCardSigninPromo(
!client_->ShouldShowSigninPromo())
return false;
+ if (IsFormNonSecure(form))
+ return false;
+
// The last step is checking if we are under the limit of impressions.
int impression_count = client_->GetPrefs()->GetInteger(
prefs::kAutofillCreditCardSigninPromoImpressionCount);
@@ -527,6 +533,11 @@ void AutofillManager::OnTextFieldDidChange(const FormData& form,
UpdateInitialInteractionTimestamp(timestamp);
}
+bool AutofillManager::IsFormNonSecure(const FormData& form) const {
+ return !client_->IsContextSecure(form.origin) ||
+ (form.action.is_valid() && form.action.SchemeIs("http"));
+}
+
void AutofillManager::OnQueryFormFieldAutofill(int query_id,
const FormData& form,
const FormFieldData& field,
@@ -563,11 +574,8 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id,
}
std::vector<Suggestion> suggestions;
- const bool is_context_secure =
- !form_structure ||
- (client_->IsContextSecure(form_structure->source_url()) &&
- (!form_structure->target_url().is_valid() ||
- !form_structure->target_url().SchemeIs("http")));
+ const bool is_context_secure = !IsFormNonSecure(form);
+
const bool is_http_warning_enabled =
security_state::IsHttpWarningInFormEnabled();
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698