Skip to content

Commit

Permalink
[site settings] Add a new item to "Clear site data" confirmation dialog
Browse files Browse the repository at this point in the history
Add a third list item to Site Settings -> Clear Data -> Confirm Clear Storage dialog when kPrivacySandboxSettings4 feature is enabled. While adding that:
- introduce a new string identifier
- introduce a new icon.
Add two tests for cases when the flag is on and off.

Screenshot: crbug.com/1378703#c33
Bug: 1378703, b/258643218 (includes UX deck)
Change-Id: Ic554bfd094d240e933a16b9bf384805f6084ac70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020182
Reviewed-by: Theodore Olsauskas-Warren <sauski@google.com>
Reviewed-by: Rainhard Findling <rainhard@chromium.org>
Commit-Queue: Aisulu Rakhmetullina <aisulu@google.com>
Cr-Commit-Position: refs/heads/main@{#1084445}
  • Loading branch information
Aisulu authored and Chromium LUCI CQ committed Dec 16, 2022
1 parent ef2c300 commit 87f4c02
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 19 deletions.
3 changes: 3 additions & 0 deletions chrome/app/settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -3688,6 +3688,9 @@
<message name="IDS_SETTINGS_SITE_SETTINGS_SITE_CLEAR_STORAGE_OFFLINE_DATA" desc="Text for the dialog that warns about loss of offline data when clearing all storage data.">
Any offline data will be cleared
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_REMOVE_SITE_AD_PERSONALIZATION" translateable="false" desc="Text for the dialog that warns about loss of the data that affects ad personalization when clearing all storage data.">
Nunc pulvinar, orci sed ullamcorper varius, nunc velit eleifend quam, a commodo lacus elit id tortor
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_SITE_CLEAR_STORAGE_APPS" desc="Text for the dialog that warns about loss of offline data for installed app when clearing all storage data for site.">
Offline data in installed app will also be cleared
</message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<defs>
<g id="logout" width="24px" height="24px" viewBox="0 0 24 24" fill="#757575"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"></path><path d="M0 0h24v24H0z" fill="none"></path></g>
<g id="offline" viewBox="0 0 24 24" width="24px" height="24px" fill="#757575"><path clip-path="url(#b)" d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm5 16H7v-2h10v2zm-6.7-4L7 10.7l1.4-1.4 1.9 1.9 5.3-5.3L17 7.3 10.3 14z"></path></g>
<g id="tag" width="24px" height="24px" viewBox="0 0 24 24"><path transform="scale(-1, 1) translate(-24, 0)" d="M14.25 21.4q-.575.575-1.425.575-.85 0-1.425-.575l-8.8-8.8q-.275-.275-.437-.65Q2 11.575 2 11.15V4q0-.825.588-1.413Q3.175 2 4 2h7.15q.425 0 .8.162.375.163.65.438l8.8 8.825q.575.575.575 1.412 0 .838-.575 1.413ZM12.825 20l7.15-7.15L11.15 4H4v7.15ZM6.5 8q.625 0 1.062-.438Q8 7.125 8 6.5t-.438-1.062Q7.125 5 6.5 5t-1.062.438Q5 5.875 5 6.5t.438 1.062Q5.875 8 6.5 8ZM4 4Z"></g>
</defs>
</svg>
</iron-iconset-svg>
19 changes: 14 additions & 5 deletions chrome/browser/resources/settings/site_settings/site_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
padding: 8px;
}
</style>

<!-- Confirm reset settings dialog. -->
<cr-dialog id="confirmResetSettings" close-text="$i18n{close}"
on-close="onResetSettingsDialogClosed_">
Expand Down Expand Up @@ -59,14 +60,21 @@
<div class="detail-list">
<div class="detail">
<iron-icon icon="all-sites:logout" aria-hidden="true"
role="presentation"></iron-icon>
role="presentation"></iron-icon>
$i18n{siteSettingsSiteClearStorageSignOut}
</div>
<div class="detail">
<iron-icon icon="all-sites:offline" aria-hidden="true"
role="presentation"></iron-icon>
role="presentation"></iron-icon>
$i18n{siteSettingsSiteClearStorageOfflineData}
</div>
<template is="dom-if" if="[[isPrivacySandboxSettings4_]]">
<div class="detail" id="adPersonalization">
<iron-icon icon="all-sites:tag" aria-hidden="true"
role="presentation"></iron-icon>
$i18n{siteSettingsRemoveSiteAdPersonalization}
</div>
</template>
</div>
</div>
<div slot="button-container">
Expand Down Expand Up @@ -112,9 +120,9 @@ <h2 class="first">$i18n{siteSettingsUsage}</h2>
<template is="dom-if" if="[[fpsEnterprisePref_]]">
<div id="fpsPolicyContainer">
<cr-policy-pref-indicator
id="fpsPolicy" pref="[[fpsEnterprisePref_]]"
icon-aria-label="[[label]]" focus-row-control
focus-type="policy">
id="fpsPolicy" pref="[[fpsEnterprisePref_]]"
icon-aria-label="[[label]]" focus-row-control
focus-type="policy">
</cr-policy-pref-indicator>
</div>
</template>
Expand All @@ -136,6 +144,7 @@ <h2 class="flex">$i18n{siteSettingsPermissions}</h2>
$i18n{siteSettingsReset}
</cr-button>
</div>

<div class="list-frame">
<site-details-permission category="[[contentSettingsTypesEnum_.GEOLOCATION]]"
icon="settings:location-on" label="$i18n{siteSettingsLocation}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ export class SiteDetailsElement extends SiteDetailsElementBase {
loadTimeData.getBoolean('enableWebBluetoothNewPermissionsBackend'),
},

isPrivacySandboxSettings4_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('isPrivacySandboxSettings4');
},
},

contentSettingsTypesEnum_: {
type: Object,
value: ContentSettingsTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_SITE_CLEAR_STORAGE_SIGN_OUT},
{"siteSettingsSiteClearStorageOfflineData",
IDS_SETTINGS_SITE_SETTINGS_SITE_CLEAR_STORAGE_OFFLINE_DATA},
{"siteSettingsRemoveSiteAdPersonalization",
IDS_SETTINGS_SITE_SETTINGS_REMOVE_SITE_AD_PERSONALIZATION},
{"siteSettingsSiteClearStorageApps",
IDS_SETTINGS_SITE_SETTINGS_SITE_CLEAR_STORAGE_APPS},
{"siteSettingsSiteGroupDelete", IDS_SETTINGS_SITE_SETTINGS_GROUP_DELETE},
Expand Down
10 changes: 10 additions & 0 deletions chrome/test/data/webui/settings/cr_settings_browsertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ GEN('#include "components/content_settings/core/common/features.h"');
GEN('#include "components/performance_manager/public/features.h"');
GEN('#include "components/privacy_sandbox/privacy_sandbox_features.h"');
GEN('#include "components/autofill/core/common/autofill_features.h"');
GEN('#include "components/privacy_sandbox/privacy_sandbox_features.h"');
GEN('#include "content/public/common/content_features.h"');
GEN('#include "content/public/test/browser_test.h"');

Expand Down Expand Up @@ -405,6 +406,15 @@ var CrSettingsSiteDetailsTest = class extends CrSettingsBrowserTest {
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/site_details_tests.js';
}

/** @override */
get featureListInternal() {
return {
enabled: [
'privacy_sandbox::kPrivacySandboxSettings4',
],
};
}
};

// Disabling on debug due to flaky timeout on Win7 Tests (dbg)(1) bot.
Expand Down
67 changes: 53 additions & 14 deletions chrome/test/data/webui/settings/site_details_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {ChooserType, ContentSetting, ContentSettingsTypes, SiteDetailsElement, S
import {MetricsBrowserProxyImpl, PrivacyElementInteractions, Router, routes} from 'chrome://settings/settings.js';
import {assertDeepEquals, assertEquals, assertFalse, assertTrue} from 'chrome://webui-test/chai_assert.js';
import {TestBrowserProxy} from 'chrome://webui-test/test_browser_proxy.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.js';

import {TestMetricsBrowserProxy} from './test_metrics_browser_proxy.js';
import {TestSiteSettingsPrefsBrowserProxy} from './test_site_settings_prefs_browser_proxy.js';
Expand All @@ -33,28 +34,20 @@ class TestWebsiteUsageBrowserProxy extends TestBrowserProxy implements
}
}

/** @fileoverview Suite of tests for site-details. */
/** Suite of tests for site-details. */
suite('SiteDetails', function() {
/**
* A site list element created before each test.
*/
/** A site list element created before each test. */
let testElement: SiteDetailsElement;

/**
* An example pref with 1 pref in each category.
*/
/** An example pref with 1 pref in each category. */
let prefs: SiteSettingsPref;

/**
* The mock site settings prefs proxy object to use during test.
*/
/** The mock site settings prefs proxy object to use during test. */
let browserProxy: TestSiteSettingsPrefsBrowserProxy;

let testMetricsBrowserProxy: TestMetricsBrowserProxy;

/**
* The mock website usage proxy object to use during test.
*/
/** The mock website usage proxy object to use during test. */
let websiteUsageProxy: TestWebsiteUsageBrowserProxy;

// Initialize a site-details before each test.
Expand Down Expand Up @@ -360,7 +353,6 @@ suite('SiteDetails', function() {
});
});


test('show confirmation dialog on reset settings', async function() {
browserProxy.setPrefs(prefs);
const origin = 'https://foo.com:443';
Expand Down Expand Up @@ -528,6 +520,7 @@ suite('SiteDetails', function() {
testElement.shadowRoot!.querySelector<HTMLElement>('#fpsPolicy');
assertEquals(null, fpsPolicy);
});

test(
'first party set policy shown when managed key is set to true',
async function() {
Expand All @@ -554,4 +547,50 @@ suite('SiteDetails', function() {
testElement.shadowRoot!.querySelector<HTMLElement>('#fpsPolicy');
assertFalse(fpsPolicy!.hidden);
});

test(
'clear data dialog warns about ad personalization data removal',
function() {
const origin = 'https://foo.com:443';
browserProxy.setPrefs(prefs);
testElement = createSiteDetails(origin);

flush();

assertTrue(Boolean(testElement.shadowRoot!.querySelector<HTMLElement>(
'#confirmClearStorage #adPersonalization')));
});
});

// TODO(crbug.com/1378703): Remove once PrivacySandboxSettings4 has been rolled
// out.
suite('SiteDetailsPrivacySandboxSettings4Disabled', function() {
suiteSetup(function() {
loadTimeData.overrideValues({
isPrivacySandboxSettings4: false,
});
});

/** A site list element created before each test. */
let testElement: SiteDetailsElement;

function createSiteDetails(origin: string) {
const siteDetailsElement = document.createElement('site-details');
document.body.appendChild(siteDetailsElement);
Router.getInstance().navigateTo(
routes.SITE_SETTINGS_SITE_DETAILS,
new URLSearchParams('site=' + origin));
return siteDetailsElement;
}

test(
'clear data dialog does not warn about ad personalization data removal',
function() {
const origin = 'https://foo.com:443';
testElement = createSiteDetails(origin);

flush();
assertFalse(Boolean(testElement.shadowRoot!.querySelector<HTMLElement>(
'#confirmClearStorage #adPersonalization')));
});
});

0 comments on commit 87f4c02

Please sign in to comment.