Commit c5a96d11 authored by Christoph Schwering's avatar Christoph Schwering Committed by Commit Bot

[Autofill] Removed obsolete feature AutofillShowAutocompleteConsoleWarnings.

The feature is disabled by default and is not subject to an active
experiment.

It's not publicly documented, so there's little chance web developers
use is.

Bug: 1007974, 869912
Change-Id: I7233fd8a21e583247868433b049996dfde843bb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410403Reviewed-by: default avatarMatthias Körber <koerber@google.com>
Commit-Queue: Christoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/master@{#810283}
parent 3b4a4ace
...@@ -85,7 +85,6 @@ static_library("test_support") { ...@@ -85,7 +85,6 @@ static_library("test_support") {
source_set("unit_tests") { source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"form_cache_unittest.cc",
"prefilled_values_detector_unittest.cc", "prefilled_values_detector_unittest.cc",
"renderer_save_password_progress_logger_unittest.cc", "renderer_save_password_progress_logger_unittest.cc",
] ]
......
...@@ -55,38 +55,6 @@ namespace autofill { ...@@ -55,38 +55,6 @@ namespace autofill {
namespace { namespace {
static const char* kSupportedAutocompleteTypes[] = {"given-name",
"additional-name",
"family-name",
"name",
"honorific-suffix",
"email",
"tel-local",
"tel-area-code",
"tel-country-code",
"tel-national",
"tel",
"tel-extension",
"street-address",
"address-line1",
"address-line2",
"address-line3",
"address-level1",
"address-level2",
"address-level3",
"postal-code",
"country-name",
"cc-name",
"cc-given-name",
"cc-family-name",
"cc-number",
"cc-exp-month",
"cc-exp-year",
"cc-exp",
"cc-type",
"cc-csc",
"organization"};
blink::FormElementPiiType MapTypePredictionToFormElementPiiType( blink::FormElementPiiType MapTypePredictionToFormElementPiiType(
base::StringPiece type) { base::StringPiece type) {
if (type == "NO_SERVER_DATA" || type == "UNKNOWN_TYPE" || if (type == "NO_SERVER_DATA" || type == "UNKNOWN_TYPE" ||
...@@ -101,77 +69,6 @@ blink::FormElementPiiType MapTypePredictionToFormElementPiiType( ...@@ -101,77 +69,6 @@ blink::FormElementPiiType MapTypePredictionToFormElementPiiType(
return blink::FormElementPiiType::kOthers; return blink::FormElementPiiType::kOthers;
} }
// For a given |type| (a string representation of enum values), return the
// appropriate autocomplete value that should be suggested to the website
// developer.
const char* MapTypePredictionToAutocomplete(base::StringPiece type) {
if (type == "NAME_FIRST")
return kSupportedAutocompleteTypes[0];
if (type == "NAME_MIDDLE")
return kSupportedAutocompleteTypes[1];
if (type == "NAME_LAST")
return kSupportedAutocompleteTypes[2];
if (type == "NAME_FULL")
return kSupportedAutocompleteTypes[3];
if (type == "NAME_SUFFIX")
return kSupportedAutocompleteTypes[4];
if (type == "EMAIL_ADDRESS")
return kSupportedAutocompleteTypes[5];
if (type == "PHONE_HOME_NUMBER")
return kSupportedAutocompleteTypes[6];
if (type == "PHONE_HOME_CITY_CODE")
return kSupportedAutocompleteTypes[7];
if (type == "PHONE_HOME_COUNTRY_CODE")
return kSupportedAutocompleteTypes[8];
if (type == "PHONE_HOME_CITY_AND_NUMBER")
return kSupportedAutocompleteTypes[9];
if (type == "PHONE_HOME_WHOLE_NUMBER")
return kSupportedAutocompleteTypes[10];
if (type == "PHONE_HOME_EXTENSION")
return kSupportedAutocompleteTypes[11];
if (type == "ADDRESS_HOME_STREET_ADDRESS")
return kSupportedAutocompleteTypes[12];
if (type == "ADDRESS_HOME_LINE1")
return kSupportedAutocompleteTypes[13];
if (type == "ADDRESS_HOME_LINE2")
return kSupportedAutocompleteTypes[14];
if (type == "ADDRESS_HOME_LINE3")
return kSupportedAutocompleteTypes[15];
if (type == "ADDRESS_HOME_STATE")
return kSupportedAutocompleteTypes[16];
if (type == "ADDRESS_HOME_CITY")
return kSupportedAutocompleteTypes[17];
if (type == "ADDRESS_HOME_DEPENDENT_LOCALITY")
return kSupportedAutocompleteTypes[18];
if (type == "ADDRESS_HOME_ZIP")
return kSupportedAutocompleteTypes[19];
if (type == "ADDRESS_HOME_COUNTRY")
return kSupportedAutocompleteTypes[20];
if (type == "CREDIT_CARD_NAME_FULL")
return kSupportedAutocompleteTypes[21];
if (type == "CREDIT_CARD_NAME_FIRST")
return kSupportedAutocompleteTypes[22];
if (type == "CREDIT_CARD_NAME_LAST")
return kSupportedAutocompleteTypes[23];
if (type == "CREDIT_CARD_NUMBER")
return kSupportedAutocompleteTypes[24];
if (type == "CREDIT_CARD_EXP_MONTH")
return kSupportedAutocompleteTypes[25];
if (type == "CREDIT_CARD_EXP_2_DIGIT_YEAR" ||
type == "CREDIT_CARD_EXP_4_DIGIT_YEAR")
return kSupportedAutocompleteTypes[26];
if (type == "CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR" ||
type == "CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR")
return kSupportedAutocompleteTypes[27];
if (type == "CREDIT_CARD_TYPE")
return kSupportedAutocompleteTypes[28];
if (type == "CREDIT_CARD_VERIFICATION_CODE")
return kSupportedAutocompleteTypes[29];
if (type == "COMPANY_NAME")
return kSupportedAutocompleteTypes[30];
return "";
}
void LogDeprecationMessages(const WebFormControlElement& element) { void LogDeprecationMessages(const WebFormControlElement& element) {
std::string autocomplete_attribute = std::string autocomplete_attribute =
element.GetAttribute("autocomplete").Utf8(); element.GetAttribute("autocomplete").Utf8();
...@@ -468,21 +365,6 @@ bool FormCache::ShowPredictions(const FormDataPredictions& form, ...@@ -468,21 +365,6 @@ bool FormCache::ShowPredictions(const FormDataPredictions& form,
continue; continue;
const FormFieldDataPredictions& field = form.fields[i]; const FormFieldDataPredictions& field = form.fields[i];
// Possibly add a console warning for this field regarding the usage of
// autocomplete attributes.
const std::string predicted_autocomplete_attribute =
MapTypePredictionToAutocomplete(field.overall_type);
if (ShouldShowAutocompleteConsoleWarnings(
predicted_autocomplete_attribute,
element.GetAttribute("autocomplete").Utf8())) {
logger.Send(
base::StringPrintf("Input elements should have autocomplete "
"attributes (suggested: autocomplete='%s', "
"confirm at https://goo.gl/6KgkJg)",
predicted_autocomplete_attribute.c_str()),
PageFormAnalyserLogger::kVerbose, element);
}
element.SetFormElementPiiType( element.SetFormElementPiiType(
MapTypePredictionToFormElementPiiType(field.overall_type)); MapTypePredictionToFormElementPiiType(field.overall_type));
...@@ -569,38 +451,6 @@ void FormCache::SaveInitialValues( ...@@ -569,38 +451,6 @@ void FormCache::SaveInitialValues(
} }
} }
bool FormCache::ShouldShowAutocompleteConsoleWarnings(
const std::string& predicted_autocomplete,
const std::string& actual_autocomplete) {
if (!base::FeatureList::IsEnabled(
features::kAutofillShowAutocompleteConsoleWarnings)) {
return false;
}
// If we have no better prediction, do not show.
if (predicted_autocomplete.empty())
return false;
// We should show a warning if the actual autocomplete attribute is empty,
// or we recognize the autocomplete attribute, but we think it's the wrong
// one.
if (actual_autocomplete.empty())
return true;
// An autocomplete attribute can be multiple strings (e.g. "shipping name").
// Look at all the tokens.
for (base::StringPiece actual : base::SplitStringPiece(
actual_autocomplete, " ", base::WhitespaceHandling::TRIM_WHITESPACE,
base::SplitResult::SPLIT_WANT_NONEMPTY)) {
// If we recognize the value but it's not correct, show a warning.
if (base::Contains(kSupportedAutocompleteTypes, actual) &&
actual != predicted_autocomplete) {
return true;
}
}
return false;
}
void FormCache::PruneInitialValueCaches( void FormCache::PruneInitialValueCaches(
const std::set<FieldRendererId>& ids_to_retain) { const std::set<FieldRendererId>& ids_to_retain) {
auto should_not_retain = [&ids_to_retain](const auto& p) { auto should_not_retain = [&ids_to_retain](const auto& p) {
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/autofill/content/renderer/form_cache.h"
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/common/autofill_features.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {
class FormCacheTest : public testing::Test {
public:
FormCacheTest() {}
protected:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(FormCacheTest);
};
TEST_F(FormCacheTest, ShouldShowAutocompleteConsoleWarnings_Enabled) {
scoped_feature_list_.InitAndEnableFeature(
features::kAutofillShowAutocompleteConsoleWarnings);
FormCache form_cache(nullptr);
// If we have a prediction and the actual attribute is empty.
EXPECT_TRUE(
form_cache.ShouldShowAutocompleteConsoleWarnings("given-name", ""));
// There is a predicted type, and there is an recognized type that is not the
// same.
EXPECT_TRUE(
form_cache.ShouldShowAutocompleteConsoleWarnings("given-name", "name"));
// Multi-values: there is a predicted type, and there is an recognized type
// that is not the same.
EXPECT_TRUE(form_cache.ShouldShowAutocompleteConsoleWarnings(
"given-name", "shipping name"));
// Multi-values: there is a predicted type, and there is an recognized type
// that is not the same along with an unrecognized type.
EXPECT_TRUE(form_cache.ShouldShowAutocompleteConsoleWarnings("given-name",
"fake name"));
// No predicted type, no actual attribute.
EXPECT_FALSE(form_cache.ShouldShowAutocompleteConsoleWarnings("", ""));
// No predicted type, and there is a recognized type.
EXPECT_FALSE(
form_cache.ShouldShowAutocompleteConsoleWarnings("", "given-name"));
// No predicted type, and there is an unrecognized type.
EXPECT_FALSE(form_cache.ShouldShowAutocompleteConsoleWarnings("", "fake"));
// There is a predicted type, and there is an unrecognized type.
EXPECT_FALSE(
form_cache.ShouldShowAutocompleteConsoleWarnings("given-name", "fake"));
// Multi-values: there is a predicted type, and there is an recognized type
// that is the same.
EXPECT_FALSE(form_cache.ShouldShowAutocompleteConsoleWarnings(
"given-name", "shipping given-name"));
// Multi-values: there is a predicted type, and there is an unrecognized type.
EXPECT_FALSE(form_cache.ShouldShowAutocompleteConsoleWarnings(
"given-name", "shipping fake"));
}
TEST_F(FormCacheTest, ShouldShowAutocompleteConsoleWarnings_Disabled) {
scoped_feature_list_.InitAndDisableFeature(
features::kAutofillShowAutocompleteConsoleWarnings);
FormCache form_cache(nullptr);
// If we have a prediction and the actual attribute is empty.
EXPECT_FALSE(
form_cache.ShouldShowAutocompleteConsoleWarnings("given-name", ""));
// There is a predicted type, and there is an recognized type that is not the
// same.
EXPECT_FALSE(
form_cache.ShouldShowAutocompleteConsoleWarnings("given-name", "name"));
// Multi-values: there is a predicted type, and there is an recognized type
// that is not the same.
EXPECT_FALSE(form_cache.ShouldShowAutocompleteConsoleWarnings(
"given-name", "shipping name"));
}
} // namespace autofill
...@@ -247,12 +247,6 @@ const base::Feature kAutofillSectionUponRedundantNameInfo{ ...@@ -247,12 +247,6 @@ const base::Feature kAutofillSectionUponRedundantNameInfo{
const base::Feature kAutofillServerCommunication{ const base::Feature kAutofillServerCommunication{
"AutofillServerCommunication", base::FEATURE_ENABLED_BY_DEFAULT}; "AutofillServerCommunication", base::FEATURE_ENABLED_BY_DEFAULT};
// Controls whether we show warnings in the Dev console for misused autocomplete
// types.
const base::Feature kAutofillShowAutocompleteConsoleWarnings{
"AutofillShowAutocompleteConsoleWarnings",
base::FEATURE_DISABLED_BY_DEFAULT};
// Controls attaching the autofill type predictions to their respective // Controls attaching the autofill type predictions to their respective
// element in the DOM. // element in the DOM.
const base::Feature kAutofillShowTypePredictions{ const base::Feature kAutofillShowTypePredictions{
......
...@@ -64,7 +64,6 @@ extern const base::Feature kAutofillRichMetadataQueries; ...@@ -64,7 +64,6 @@ extern const base::Feature kAutofillRichMetadataQueries;
extern const base::Feature kAutofillSaveAndFillVPA; extern const base::Feature kAutofillSaveAndFillVPA;
extern const base::Feature kAutofillSectionUponRedundantNameInfo; extern const base::Feature kAutofillSectionUponRedundantNameInfo;
extern const base::Feature kAutofillServerCommunication; extern const base::Feature kAutofillServerCommunication;
extern const base::Feature kAutofillShowAutocompleteConsoleWarnings;
extern const base::Feature kAutofillShowTypePredictions; extern const base::Feature kAutofillShowTypePredictions;
extern const base::Feature kAutofillSkipComparingInferredLabels; extern const base::Feature kAutofillSkipComparingInferredLabels;
extern const base::Feature kAutofillSkipFillingFieldsWithChangedValues; extern const base::Feature kAutofillSkipFillingFieldsWithChangedValues;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment