Skip to content

Commit

Permalink
Merge-70 [AF] Clean up Autofill settings toggles.
Browse files Browse the repository at this point in the history
Remove the master toggle.
Add sublabels for the profile and credit card toggles.
Add row to inform users if an extention is managing the toggles.
Change the title from "Addresses" to "Addresses and more".

TBR=sebsg@chromium.org

(cherry picked from commit 2e8a676)

Bug: 860526, 877801
Change-Id: I2d0d156108667d9463263f4e490761a506bf9a13
Reviewed-on: https://chromium-review.googlesource.com/1196924
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: Michael Giuffrida <michaelpg@chromium.org>
Reviewed-by: Moe Ahmadi <mahmadi@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#588148}
Reviewed-on: https://chromium-review.googlesource.com/1207215
Reviewed-by: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/branch-heads/3538@{#53}
Cr-Branched-From: 79f7c91-refs/heads/master@{#587811}
  • Loading branch information
sebsg committed Sep 5, 2018
1 parent 9c00fb1 commit 19e310e
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 48 deletions.
7 changes: 0 additions & 7 deletions chrome/app/settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -624,16 +624,9 @@
<message name="IDS_SETTINGS_AUTOFILL" desc="Name for the autofill section and toggle.">
Autofill settings
</message>
<!-- TODO(https://crbug.com/854562): Rename this to "IDS_SETTINGS_AUTOFILL" once Autofill Home is fully launched. -->
<message name="IDS_SETTINGS_AUTOFILL_AUTOFILL_HOME" desc="Name for the addresses section used for Autofill Home.">
Addresses
</message>
<message name="IDS_SETTINGS_GOOGLE_PAYMENTS" desc="Label used to differentiate when an address or credit card entry comes from Google Pay. This should follow the casing of the 'Google Pay' brand. 'Google Pay' should not be translated as it is the product name.">
Google Pay
</message>
<message name="IDS_SETTINGS_AUTOFILL_TOGGLE_LABEL" desc="Label for a toggle that allows users to control whether forms should be autofilled with data such as addresses and credit cards, but not passwords.">
Autofill forms
</message>
<message name="IDS_SETTINGS_AUTOFILL_ADDRESSES_ADD_TITLE" desc="This is the title for the 'Add address' dialog. This dialog allows a user to create a new address.">
Add address
</message>
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/extensions/api/settings_private/prefs_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
// Miscellaneous
(*s_whitelist)[::prefs::kAlternateErrorPagesEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[autofill::prefs::kAutofillEnabledDeprecated] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[autofill::prefs::kAutofillProfileEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[autofill::prefs::kAutofillCreditCardEnabled] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,24 @@
overflow: hidden;
}
</style>
<settings-toggle-button id="autofillToggle"
class="first"
<settings-toggle-button id="autofillProfileToggle"
class="settings-box first"
aria-label="$i18n{autofill}" no-extension-indicator
label="$i18n{autofillFormsLabel}"
pref="{{prefs.autofill.enabled}}">
label="$i18n{enableProfilesLabel}"
sub-label="$i18n{enableProfilesSublabel}"
pref="{{prefs.autofill.profile_enabled}}">
</settings-toggle-button>
<template is="dom-if" if="[[prefs.autofill.enabled.extensionId]]">
<template is="dom-if" if="[[prefs.autofill.profile_enabled.extensionId]]">
<div class="settings-box continuation">
<extension-controlled-indicator class="start"
id="autofillExtensionIndicator"
extension-id="[[prefs.autofill.enabled.extensionId]]"
extension-name="[[prefs.autofill.enabled.controlledByName]]"
extension-id="[[prefs.autofill.profile_enabled.extensionId]]"
extension-name="[[prefs.autofill.profile_enabled.controlledByName]]"
extension-can-be-disabled="[[
prefs.autofill.enabled.extensionCanBeDisabled]]">
prefs.autofill.profile_enabled.extensionCanBeDisabled]]">
</extension-controlled-indicator>
</div>
</template>
<settings-toggle-button id="autofillProfileToggle"
class="settings-box first"
aria-label="$i18n{autofill}" no-extension-indicator
label="$i18n{enableProfilesLabel}"
pref="{{prefs.autofill.profile_enabled}}"
disabled$="[[!prefs.autofill.enabled.value]]">
</settings-toggle-button>
<div class="settings-box continuation">
<h2 class="start">$i18n{addresses}</h2>
<paper-button id="addAddress"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,22 @@
class="settings-box first"
aria-label="$i18n{creditCards}" no-extension-indicator
label="$i18n{enableCreditCardsLabel}"
pref="{{prefs.autofill.credit_card_enabled}}"
disabled$="[[!prefs.autofill.enabled.value]]">
sub-label="$i18n{enableCreditCardsSublabel}"
pref="{{prefs.autofill.credit_card_enabled}}">
</settings-toggle-button>
<template is="dom-if"
if="[[prefs.autofill.credit_card_enabled.extensionId]]">
<div class="settings-box continuation">
<extension-controlled-indicator class="start"
id="autofillExtensionIndicator"
extension-id="[[prefs.autofill.credit_card_enabled.extensionId]]"
extension-name="[[
prefs.autofill.credit_card_enabled.controlledByName]]"
extension-can-be-disabled="[[
prefs.autofill.credit_card_enabled.extensionCanBeDisabled]]">
</extension-controlled-indicator>
</div>
</template>
<div class="settings-box continuation">
<h2 class="start">$i18n{creditCards}</h2>
<paper-button id="addCreditCard"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
on-click="onPaymentsTap_"></cr-link-row>
<cr-link-row id="addressesManagerButton"
start-icon="settings20:location-on"
label="$i18n{addresses}" icon-class="subpage-arrow"
label="$i18n{addressesTitle}" icon-class="subpage-arrow"
on-click="onAutofillTap_"></cr-link-row>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1388,10 +1388,13 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_PASSWORDS_AND_AUTOFILL_PAGE_TITLE},
{"googlePayments", IDS_SETTINGS_GOOGLE_PAYMENTS},
{"googlePaymentsCached", IDS_SETTINGS_GOOGLE_PAYMENTS_CACHED},
{"autofillFormsLabel", IDS_SETTINGS_AUTOFILL_TOGGLE_LABEL},
{"enableProfilesLabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_LABEL},
{"enableProfilesSublabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_SUBLABEL},
{"enableCreditCardsLabel", IDS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_LABEL},
{"enableCreditCardsSublabel",
IDS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_SUBLABEL},
{"addresses", IDS_AUTOFILL_ADDRESSES},
{"addressesTitle", IDS_AUTOFILL_ADDRESSES_SETTINGS_TITLE},
{"addAddressTitle", IDS_SETTINGS_AUTOFILL_ADDRESSES_ADD_TITLE},
{"editAddressTitle", IDS_SETTINGS_AUTOFILL_ADDRESSES_EDIT_TITLE},
{"addressCountry", IDS_SETTINGS_AUTOFILL_ADDRESSES_COUNTRY},
Expand Down Expand Up @@ -1466,7 +1469,7 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source,
// |localized_strings| array once Autofill Home is fully launched.
if (base::FeatureList::IsEnabled(password_manager::features::kAutofillHome)) {
html_source->AddLocalizedString("autofill",
IDS_SETTINGS_AUTOFILL_AUTOFILL_HOME);
IDS_AUTOFILL_ADDRESSES_SETTINGS_TITLE);
html_source->AddLocalizedString("passwords",
IDS_SETTINGS_PASSWORDS_AUTOFILL_HOME);
html_source->AddLocalizedString("creditCards",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// that callbacks are correctly invoked, expected parameters are correct,
// and failures are detected.

var kTestPrefName = 'autofill.enabled';
var kTestPrefName = 'autofill.profile_enabled';
var kTestPrefValue = true;

// This corresponds to policy key: kHomepageIsNewTabPage used in
Expand Down
10 changes: 1 addition & 9 deletions chrome/test/data/webui/settings/autofill_section_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ cr.define('settings_autofill_section', function() {
document.body.appendChild(section);

assertFalse(!!section.$$('#autofillExtensionIndicator'));
section.set('prefs.autofill.enabled.extensionId', 'test-id');
section.set('prefs.autofill.profile_enabled.extensionId', 'test-id');
Polymer.dom.flush();

assertTrue(!!section.$$('#autofillExtensionIndicator'));
Expand Down Expand Up @@ -173,14 +173,6 @@ cr.define('settings_autofill_section', function() {
assertFalse(section.$$('#addAddress').disabled);
});

test('verifyDisabled', function() {
const section = createAutofillSection(
[], {enabled: {value: false}, profile_enabled: {value: true}});

assertTrue(section.$$('#autofillProfileToggle').disabled);
assertTrue(section.$$('#addAddress').disabled);
});

test('verifyAddressDisabled', function() {
const section = createAutofillSection(
[], {enabled: {value: true}, profile_enabled: {value: false}});
Expand Down
24 changes: 15 additions & 9 deletions chrome/test/data/webui/settings/payments_section_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
// found in the LICENSE file.

cr.define('settings_payments_section', function() {
suite('PaymentSectionUiTest', function() {
test('testAutofillExtensionIndicator', function() {
// Initializing with fake prefs
const section = document.createElement('settings-payments-section');
section.prefs = {autofill: {enabled: {}, credit_card_enabled: {}}};
document.body.appendChild(section);

assertFalse(!!section.$$('#autofillExtensionIndicator'));
section.set('prefs.autofill.credit_card_enabled.extensionId', 'test-id');
Polymer.dom.flush();

assertTrue(!!section.$$('#autofillExtensionIndicator'));
});
});

suite('PaymentsSection', function() {
/** @type {settings.SyncBrowserProxy} */
let syncBrowserProxy = null;
Expand Down Expand Up @@ -61,15 +76,6 @@ cr.define('settings_payments_section', function() {
assertFalse(section.$$('#addCreditCard').disabled);
});

test('verifyDisabled', function() {
const section = createPaymentsSection(
[],
{enabled: {value: false}, credit_card_enabled: {value: true}});

assertTrue(section.$$('#autofillCreditCardToggle').disabled);
assertTrue(section.$$('#addCreditCard').disabled);
});

test('verifyCreditCardsDisabled', function() {
const section = createPaymentsSection(
[],
Expand Down

0 comments on commit 19e310e

Please sign in to comment.