Commit 8a988099 authored by Jeffrey Cohen's avatar Jeffrey Cohen Committed by Commit Bot

Enable/Disable filling of COMPANY_NAME using flag

Instead of COMPANY_NAME returning an empty string when disabled, this CL
enable/disables the filling of COMPANY_NAME within the fill logic.

Bug: 864612
Change-Id: I9437e45a056d110d4e3c36ac92f8ac01338b8344
Reviewed-on: https://chromium-review.googlesource.com/1205106
Commit-Queue: Jeffrey Cohen <jeffreycohen@chromium.org>
Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Reviewed-by: default avatarRoger McFarlane <rogerm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590053}
parent bb7972c1
......@@ -227,45 +227,6 @@ class AutofillTest : public InProcessBrowserTest {
net::TestURLFetcherFactory url_fetcher_factory_;
};
class AutofillParamTest : public AutofillTest,
public testing::WithParamInterface<bool> {
protected:
AutofillParamTest() : enable_company_feature_state_(GetParam()) {
feature_list_.InitWithFeatureState(features::kAutofillEnableCompanyName,
enable_company_feature_state_);
}
const bool enable_company_feature_state_;
private:
base::test::ScopedFeatureList feature_list_;
};
// Test that Autofill respects CompanyName Feature state
IN_PROC_BROWSER_TEST_P(AutofillParamTest, CompanyNameTest) {
SCOPED_TRACE(enable_company_feature_state_ ? "Enabled" : "Disabled");
const char kCompanyName[] = "Google";
FormMap data;
data["NAME_FIRST"] = "Bob";
data["NAME_LAST"] = "Smith";
data["ADDRESS_HOME_LINE1"] = "1234 H St.";
data["ADDRESS_HOME_CITY"] = "Mountain View";
data["ADDRESS_HOME_STATE"] = "CA";
data["ADDRESS_HOME_ZIP"] = "94043";
data["COMPANY_NAME"] = kCompanyName;
std::string submit("document.forms[0].submit();");
FillFormAndSubmitWithHandler("duplicate_profiles_test.html", data, submit,
false, true);
EXPECT_EQ(
ASCIIToUTF16(enable_company_feature_state_ ? kCompanyName : ""),
personal_data_manager()->GetProfiles()[0]->GetRawInfo(COMPANY_NAME));
}
INSTANTIATE_TEST_CASE_P(, AutofillParamTest, testing::Bool());
// Test that Autofill aggregates a minimum valid profile.
// The minimum required address fields must be specified: First Name, Last Name,
// Address Line 1, City, Zip Code, and State.
......
......@@ -1304,6 +1304,11 @@ void AutofillManager::FillOrPreviewDataModelForm(
if (field_group_type == NO_GROUP)
continue;
if (field_group_type == COMPANY &&
!base::FeatureList::IsEnabled(features::kAutofillEnableCompanyName)) {
continue;
}
// On a refill, only fill fields from type groups that were present during
// the initial fill.
if (is_refill &&
......
......@@ -241,11 +241,7 @@ void CompanyInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
}
base::string16 CompanyInfo::GetRawInfo(ServerFieldType type) const {
if (type == COMPANY_NAME &&
base::FeatureList::IsEnabled(features::kAutofillEnableCompanyName))
return company_name_;
return base::string16();
return company_name_;
}
void CompanyInfo::SetRawInfo(ServerFieldType type,
......
......@@ -11,10 +11,8 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/autofill_features.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::ASCIIToUTF16;
......@@ -399,30 +397,4 @@ INSTANTIATE_TEST_CASE_P(
NamePartsAreEmptyTestCase{"", "Mitchell", "", "", false},
NamePartsAreEmptyTestCase{"", "", "Morrison", "", false}));
struct CompanyNameEnabledDisabledTest : public testing::TestWithParam<bool> {
CompanyNameEnabledDisabledTest() : feature_state(GetParam()) {
feature_list_.InitWithFeatureState(features::kAutofillEnableCompanyName,
feature_state);
}
const bool feature_state;
private:
base::test::ScopedFeatureList feature_list_;
};
TEST_P(CompanyNameEnabledDisabledTest, GetInfo) {
SCOPED_TRACE(feature_state ? "Enabled" : "Disabled");
const char kCompanyName[] = "Google";
CompanyInfo company;
company.SetInfo(AutofillType(COMPANY_NAME), ASCIIToUTF16(kCompanyName),
"en-US");
EXPECT_EQ(ASCIIToUTF16(feature_state ? kCompanyName : ""),
company.GetInfo(AutofillType(COMPANY_NAME), "en-US"));
}
INSTANTIATE_TEST_CASE_P(ContactInfoTest,
CompanyNameEnabledDisabledTest,
testing::Bool());
} // namespace autofill
......@@ -67,6 +67,7 @@ const base::Feature kAutofillDynamicForms{"AutofillDynamicForms",
const base::Feature kAutofillEnableAccountWalletStorage{
"AutofillEnableAccountWalletStorage", base::FEATURE_DISABLED_BY_DEFAULT};
// Controls whether we use COMPANY as part of Autofill
const base::Feature kAutofillEnableCompanyName{
"AutofillEnableCompanyName", base::FEATURE_ENABLED_BY_DEFAULT};
......
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