Commit 7d1a2988 authored by Jeffrey Cohen's avatar Jeffrey Cohen Committed by Commit Bot

Use feature flag `kAutofillEnableCompanyName` to remove company names from autofill html

Bug: 864612
Change-Id: Ic7ee974224264eb15089c1915c660957592c4fc0
Reviewed-on: https://chromium-review.googlesource.com/1180418
Commit-Queue: Jeffrey Cohen <jeffreycohen@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586747}
parent 40d8c93b
......@@ -17,6 +17,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/autofill/autofill_uitest_util.h"
......@@ -37,6 +38,7 @@
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager_observer.h"
#include "components/autofill/core/browser/validation.h"
#include "components/autofill/core/common/autofill_features.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
......@@ -225,6 +227,45 @@ 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.
......
......@@ -92,9 +92,23 @@ Polymer({
// Default to the last country used if no country code is provided.
const countryCode = this.countryCode_ || this.countries_[0].countryCode;
this.countryInfo.getAddressFormat(countryCode).then(format => {
this.addressWrapper_ = format.components.map(
component => component.row.map(
c => new settings.address.AddressComponentUI(this.address, c)));
let filteredComponent =
format.components.map(component => component.row.filter(c => {
return (
loadTimeData.getBoolean('EnableCompanyName') ||
c.field !== chrome.autofillPrivate.AddressField.COMPANY_NAME);
}));
this.addressWrapper_ =
filteredComponent
.filter(component => {
return (component && component.length > 0);
})
.map(component => {
return component.map(c => {
return new settings.address.AddressComponentUI(
this.address, c);
});
});
// Flush dom before resize and savability updates.
Polymer.dom.flush();
......
......@@ -29,6 +29,7 @@
#include "chrome/grit/locale_settings.h"
#include "components/autofill/core/browser/payments/payments_service_url.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/content_settings/core/common/features.h"
#include "components/google/core/common/google_util.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
......@@ -1484,6 +1485,10 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source) {
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
html_source->AddBoolean("EnableCompanyName",
base::FeatureList::IsEnabled(
autofill::features::kAutofillEnableCompanyName));
}
void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
......
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