Commit 21274196 authored by sauski's avatar sauski Committed by Commit Bot

Ensure cookie_controls_mode is set with block_third_party_cookies

To ensure that the two related preferences, cookie_controls_mode and
block_third_party_cookies remain in a consistent state, this CL updates
the existing block_third_party_cookies toggle located in settings
to update both preferences.

Bug: 1068144
Change-Id: Ia64cb37c766a3143c6ac986efc67e87283852a8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134261Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: Theodore Olsauskas-Warren <sauski@google.com>
Cr-Commit-Position: refs/heads/master@{#757019}
parent 6f34b897
......@@ -563,7 +563,7 @@ polymer_modulizer("privacy_page") {
"chrome/browser/resources/settings/metrics_browser_proxy.html|PrivacyElementInteractions,MetricsBrowserProxyImpl",
"chrome/browser/resources/settings/privacy_page/privacy_page_browser_proxy.html|PrivacyPageBrowserProxy,PrivacyPageBrowserProxyImpl",
"chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.html|SiteSettingsPrefsBrowserProxyImpl",
"chrome/browser/resources/settings/site_settings/constants.html|ContentSettingsTypes,ChooserType",
"chrome/browser/resources/settings/site_settings/constants.html|ContentSettingsTypes,CookieControlsMode,ChooserType",
"chrome/browser/resources/settings/people_page/sync_browser_proxy.html|SyncBrowserProxyImpl,SyncStatus",
"chrome/browser/resources/settings/hats_browser_proxy.html|HatsBrowserProxyImpl",
"chrome/browser/resources/settings/page_visibility.html|PrivacyPageVisibility",
......
......@@ -273,9 +273,13 @@
sub-option-mode="cookies-session-only">
</category-default-setting>
<settings-toggle-button
id="blockThirdPartyCookies"
pref="{{prefs.profile.block_third_party_cookies}}"
label="$i18n{thirdPartyCookie}"
sub-label="$i18n{thirdPartyCookieSublabel}">
sub-label="$i18n{thirdPartyCookieSublabel}"
on-settings-boolean-control-change=
"onBlockThirdPartyCookiesToggleChange_"
no-set-pref>
</settings-toggle-button>
<cr-link-row id="site-data-trigger" class="hr"
on-click="onSiteDataTap_" label="$i18n{siteSettingsCookieLink}">
......
......@@ -415,6 +415,20 @@ cr.define('settings', function() {
this.browserProxy_.setBlockAutoplayEnabled(target.checked);
},
/**
* Updates both required block third party cookie preferences.
* @param {!Event} event
* @private
*/
onBlockThirdPartyCookiesToggleChange_(event) {
const target = /** @type {!SettingsToggleButtonElement} */ (event.target);
this.setPrefValue('profile.block_third_party_cookies', target.checked);
this.setPrefValue(
'profile.cookie_controls_mode',
target.checked ? settings.CookieControlsMode.ENABLED :
settings.CookieControlsMode.DISABLED);
},
/**
* Records changes made to the "can a website check if you have saved
* payment methods" setting for logging, the logic of actually changing the
......
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// clang-format off
// #import {SiteSettingsPrefsBrowserProxyImpl} from 'chrome://settings/lazy_load.js';
// #import {CookieControlsMode, SiteSettingsPrefsBrowserProxyImpl} from 'chrome://settings/lazy_load.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {MetricsBrowserProxyImpl, PrivacyElementInteractions, PrivacyPageBrowserProxyImpl, SyncBrowserProxyImpl, HatsBrowserProxyImpl, Router, routes} from 'chrome://settings/settings.js';
// #import {TestMetricsBrowserProxy} from 'chrome://test/settings/test_metrics_browser_proxy.m.js';
......@@ -226,6 +226,30 @@ suite('PrivacyPage', function() {
test_util.isChildVisible(page, '#security-keys-subpage-trigger'));
}
});
test('BlockThirdPartyCookiesToggle', async function() {
page.prefs.profile.block_third_party_cookies = {value: false};
page.prefs.profile.cookie_controls_mode = {
value: settings.CookieControlsMode.DISABLED
};
settings.Router.getInstance().navigateTo(
settings.routes.SITE_SETTINGS_COOKIES);
Polymer.dom.flush();
page.$$('#blockThirdPartyCookies').click();
Polymer.dom.flush();
assertTrue(page.prefs.profile.block_third_party_cookies.value);
assertEquals(
page.prefs.profile.cookie_controls_mode.value,
settings.CookieControlsMode.ENABLED);
page.$$('#blockThirdPartyCookies').click();
Polymer.dom.flush();
assertFalse(page.prefs.profile.block_third_party_cookies.value);
assertEquals(
page.prefs.profile.cookie_controls_mode.value,
settings.CookieControlsMode.DISABLED);
});
});
suite('PrivacyPageRedesignEnabled', function() {
......
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