Skip to content

Commit

Permalink
[Privacy Sandbox] Create the layout for the Ad Measurement subpage
Browse files Browse the repository at this point in the history
This CL creates the layout for the Ad Measurement subpage for the
Privacy Sandbox settings, connecting the toggle of the subpage to the
respective prefs.

Tests are added to check for enabling and disabling the toggle and that
its sublabel is static regarding the toggle state.

Preview: https://crbug.com/1378703#c109

Bug: 1378703, b/254412694, b/254412652, b/254412707
Change-Id: Ia654744d58b3e1cf586ffd5e5cb45735f9da6287
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4071625
Reviewed-by: Theodore Olsauskas-Warren <sauski@google.com>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Commit-Queue: Gabriel Oliveira <gabolvr@google.com>
Cr-Commit-Position: refs/heads/main@{#1078493}
  • Loading branch information
Gabriel Oliveira authored and Chromium LUCI CQ committed Dec 2, 2022
1 parent 27b52a8 commit 74543cb
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 3 deletions.
21 changes: 21 additions & 0 deletions chrome/app/settings_strings.grdp
Expand Up @@ -1827,6 +1827,27 @@
<message name="IDS_SETTINGS_AD_MEASUREMENT_PAGE_TITLE" translateable="false" desc="Title for the Ad Measurement preferences page.">
Vestibulum augue
</message>
<message name="IDS_SETTINGS_AD_MEASUREMENT_PAGE_TOGGLE_LABEL" translateable="false" desc="Label for the toggle in the Ad Measurement preferences page.">
Vestibulum augue erat
</message>
<message name="IDS_SETTINGS_AD_MEASUREMENT_PAGE_TOGGLE_SUB_LABEL" translateable="false" desc="Sublabel for the toggle in the Ad Measurement preferences page.">
Vestibulum eleifend nunc a viverra congue. Integer nec mauris rutrum, porta mauris et, pellentesque ligula. Nam et pulvinar eros, in gravida nisl.
</message>
<message name="IDS_SETTINGS_AD_MEASUREMENT_PAGE_ENABLED_HEADING" translateable="false" desc="Heading for the 'When on' section in the Ad Measurement preferences page.">
Mauris
</message>
<message name="IDS_SETTINGS_AD_MEASUREMENT_PAGE_CONSIDER_HEADING" translateable="false" desc="Heading for the 'Things to consider' section in the Ad Measurement preferences page.">
Aenean
</message>
<message name="IDS_SETTINGS_AD_MEASUREMENT_PAGE_ENABLED_BULLET_1" translateable="false" desc="First bullet point underneath the 'When on' section in the Ad Measurement preferences page.">
Praesent sodales, magna eget volutpat iaculis, justo odio viverra justo, id venenatis est est sit amet ex
</message>
<message name="IDS_SETTINGS_AD_MEASUREMENT_PAGE_ENABLED_BULLET_2" translateable="false" desc="Second bullet point underneath the 'When on' section in the Ad Measurement preferences page.">
Nunc metus est, faucibus sit amet lacus sit amet, aliquet rutrum libero. Maecenas vel euismod ante.
</message>
<message name="IDS_SETTINGS_AD_MEASUREMENT_PAGE_CONSIDER_BULLET_1" translateable="false" desc="First bullet point underneath the 'Things to consider' section in the Ad Measurement preferences page.">
Mauris mattis urna elit. Phasellus quis erat sapien. Praesent finibus pellentesque iaculis. Mauris hendrerit metus at enim rhoncus bibendum.
</message>

<!-- Privacy Guide -->
<message name="IDS_SETTINGS_PRIVACY_GUIDE_LABEL" desc="Label of the row in the Chrome privacy and security settings page that leads to the 'Privacy Guide'. 'Privacy Guide' is a term, see go/glossarymanager/termset?gid=27517723&amp;tsid=28b420b3.">
Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/resources/settings/icons.html
Expand Up @@ -26,10 +26,12 @@
<g id="lightbulb"><path d="M7.49996 17.5C7.49996 17.9583 7.87496 18.3333 8.33329 18.3333H11.6666C12.125 18.3333 12.5 17.9583 12.5 17.5V16.6667H7.49996V17.5ZM9.99996 1.66667C6.78329 1.66667 4.16663 4.28334 4.16663 7.50001C4.16663 9.48334 5.15829 11.225 6.66663 12.2833V14.1667C6.66663 14.625 7.04163 15 7.49996 15H12.5C12.9583 15 13.3333 14.625 13.3333 14.1667V12.2833C14.8416 11.225 15.8333 9.48334 15.8333 7.50001C15.8333 4.28334 13.2166 1.66667 9.99996 1.66667ZM12.375 10.9167L11.6666 11.4167V13.3333H8.33329V11.4167L7.62496 10.9167C6.49996 10.1333 5.83329 8.85834 5.83329 7.50001C5.83329 5.20001 7.69996 3.33334 9.99996 3.33334C12.3 3.33334 14.1666 5.20001 14.1666 7.50001C14.1666 8.85834 13.5 10.1333 12.375 10.9167Z"></path></g>
<g id="link"><path fill-rule="evenodd" clip-rule="evenodd" d="M9.16663 12.5H5.83329C4.45829 12.5 3.33329 11.375 3.33329 10C3.33329 8.62501 4.45829 7.50001 5.83329 7.50001H9.16663V5.83334H5.83329C3.53329 5.83334 1.66663 7.70001 1.66663 10C1.66663 12.3 3.53329 14.1667 5.83329 14.1667H9.16663V12.5ZM14.1666 5.83334H10.8333V7.50001H14.1666C15.5416 7.50001 16.6666 8.62501 16.6666 10C16.6666 11.375 15.5416 12.5 14.1666 12.5H10.8333V14.1667H14.1666C16.4666 14.1667 18.3333 12.3 18.3333 10C18.3333 7.70001 16.4666 5.83334 14.1666 5.83334ZM13.3333 9.16668H6.66663V10.8333H13.3333V9.16668Z"></path></g>
<g id="logout"><path d="M14.1665 5.83333L12.9915 7.00833L15.1415 9.16667H6.6665V10.8333H15.1415L12.9915 12.9833L14.1665 14.1667L18.3332 10L14.1665 5.83333ZM3.33317 4.16667H9.99984V2.5H3.33317C2.4165 2.5 1.6665 3.25 1.6665 4.16667V15.8333C1.6665 16.75 2.4165 17.5 3.33317 17.5H9.99984V15.8333H3.33317V4.16667Z"></path></g>
<g id="performance-max"><path d="m4.625 14-1.083-1.062L8 8.5l3.25 3.25 4.146-4.021 1.062 1.063-5.208 5.104L8 10.625Zm6.625-5-.771-1.729L8.75 6.5l1.729-.771L11.25 4l.771 1.729 1.729.771-1.729.771Z"></path></g>
<g id="public"><path fill-rule="evenodd" clip-rule="evenodd" d="M10 1.667A8.336 8.336 0 0 0 1.667 10c0 4.6 3.733 8.333 8.333 8.333S18.333 14.6 18.333 10 14.6 1.667 10 1.667zM3.333 10c0-.508.067-1.008.175-1.483L7.492 12.5v.833c0 .917.75 1.667 1.666 1.667v1.608C5.883 16.192 3.333 13.392 3.333 10zm9.992 3.333c.75 0 1.367.492 1.583 1.167a6.66 6.66 0 0 0 1.758-4.5 6.67 6.67 0 0 0-4.175-6.175v.342c0 .916-.75 1.666-1.666 1.666H9.158V7.5a.836.836 0 0 1-.833.833H6.658V10h5c.459 0 .834.375.834.833v2.5h.833z"></path></g>
<g id="privacy-sandbox"><path d="M11.708 17.562q-.437.438-1.062.438t-1.063-.438l-7.145-7.145q-.209-.209-.323-.49Q2 9.646 2 9.354V3.5q0-.625.438-1.062Q2.875 2 3.5 2h5.854q.292 0 .563.104.271.104.5.334l7.145 7.145q.438.438.438 1.052 0 .615-.438 1.053ZM10.646 16.5l5.854-5.854L9.354 3.5H3.5v5.854ZM5.5 6.75q.521 0 .885-.365.365-.364.365-.885t-.365-.885Q6.021 4.25 5.5 4.25t-.885.365q-.365.364-.365.885t.365.885q.364.365.885.365Zm-2-3.25Z"></path></g>
<g id="security"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.183 4.7L10 1.667 16.816 4.7v4.542c0 4.208-2.908 8.133-6.816 9.091-3.909-.958-6.817-4.883-6.817-9.091V4.7zM15.3 9.992H10V3.325L4.7 5.683V10l5.3-.008v6.775c2.816-.875 4.9-3.65 5.3-6.775z"></path></g>
<g id="shoppingcart"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.1585 10.8333H12.8502C13.4502 10.8333 14.0002 10.5083 14.3002 9.99167L17.0335 5.20001C17.2502 4.81667 17.2502 4.33334 17.0335 3.95001C16.8168 3.56667 16.3918 3.33334 15.9502 3.33334H4.61683L3.87516 1.66667H0.833496V3.33334H2.79183L5.74183 9.98334L4.85016 11.7583C4.59183 12.275 4.61683 12.8833 4.92516 13.3833C5.2335 13.8833 5.7585 14.175 6.34183 14.175H15.8335V12.5083H6.35016L7.1835 10.8417H12.1585V10.8333ZM7.50016 16.6667C7.50016 17.5871 6.75397 18.3333 5.8335 18.3333C4.91302 18.3333 4.16683 17.5871 4.16683 16.6667C4.16683 15.7462 4.91302 15 5.8335 15C6.75397 15 7.50016 15.7462 7.50016 16.6667ZM15.8335 16.6667C15.8335 17.5871 15.0873 18.3333 14.1668 18.3333C13.2464 18.3333 12.5002 17.5871 12.5002 16.6667C12.5002 15.7462 13.2464 15 14.1668 15C15.0873 15 15.8335 15.7462 15.8335 16.6667ZM12.8502 9.16667L15.2335 5.00001H5.3585L7.2085 9.16667H12.8502Z"></path></g>
<g id="spam"><path d="M15.0714 6.66667V3.5H16.5V7.38889H15.0714V6.66667ZM15.0714 9.83333H16.5V8.38889H15.0714V9.83333ZM9.71429 10.9444C11.6214 10.9444 15.4286 11.9122 15.4286 13.8333V16H4V13.8333C4 11.9122 7.80714 10.9444 9.71429 10.9444ZM9.71429 4.44444C10.472 4.44444 11.1988 4.74881 11.7346 5.29058C12.2704 5.83235 12.5714 6.56715 12.5714 7.33333C12.5714 8.09951 12.2704 8.83431 11.7346 9.37609C11.1988 9.91786 10.472 10.2222 9.71429 10.2222C8.95652 10.2222 8.2298 9.91786 7.69398 9.37609C7.15816 8.83431 6.85714 8.09951 6.85714 7.33333C6.85714 6.56715 7.15816 5.83235 7.69398 5.29058C8.2298 4.74881 8.95652 4.44444 9.71429 4.44444ZM9.71429 12.3167C7.59286 12.3167 5.35714 13.3711 5.35714 13.8333V14.6278H14.0714V13.8333C14.0714 13.3711 11.8357 12.3167 9.71429 12.3167ZM9.71429 5.81667C9.31646 5.81667 8.93493 5.97646 8.65363 6.26089C8.37232 6.54532 8.21429 6.93109 8.21429 7.33333C8.21429 7.73558 8.37232 8.12135 8.65363 8.40578C8.93493 8.69021 9.31646 8.85 9.71429 8.85C10.1121 8.85 10.4936 8.69021 10.7749 8.40578C11.0563 8.12135 11.2143 7.73558 11.2143 7.33333C11.2143 6.93109 11.0563 6.54532 10.7749 6.26089C10.4936 5.97646 10.1121 5.81667 9.71429 5.81667Z"></path></g>
<g id="vpn-key"><path d="M10.4727273,8 C9.87272727,6.2525 8.26181818,5 6.36363636,5 C3.95272727,5 2,7.01375 2,9.5 C2,11.98625 3.95272727,14 6.36363636,14 C8.26181818,14 9.87272727,12.7475 10.4727273,11 L13.6363636,11 L13.6363636,14 L16.5454545,14 L16.5454545,11 L18,11 L18,8 L10.4727273,8 Z M6.36363636,11 C5.56,11 4.90909091,10.32875 4.90909091,9.5 C4.90909091,8.67125 5.56,8 6.36363636,8 C7.16727273,8 7.81818182,8.67125 7.81818182,9.5 C7.81818182,10.32875 7.16727273,11 6.36363636,11 Z"></path></g>
<g id="cloud-off"><path d="M16.4732571,13.3443682 C16.8002856,12.9882746 17,12.5134184 17,11.9922 C17,10.8882 16.104,9.9922 15,9.9922 L13.494,9.9922 L13.494,9.0002 C13.494,7.0672 11.927,5.5002 9.994,5.5002 C9.5847901,5.5002 9.1930204,5.57089988 8.82954884,5.70065995 L7.33083687,4.20194798 C8.11843435,3.75577808 9.02717677,3.5002 10,3.5002 C12.71,3.5002 14.957,5.4612 15.411,8.0412 C17.424,8.2502 19,9.9312 19,12.0002 C19,13.0718701 18.5784721,14.0451601 17.8921876,14.7632987 L16.4732571,13.3443682 Z M17.8711111,17 L16.8711111,18 L14.8713111,16.0002 L6,16.0002 C3.239,16.0002 1,13.7622 1,11.0002 C1,8.58475294 2.71868905,6.59044755 4.99627833,6.12516722 L2,3.12888889 L3,2.12888889 L17.8711111,17 Z M6.86331111,7.9922 L6,7.9922 C4.343,7.9922 3,9.3352 3,10.9922 C3,12.6492 4.343,13.9922 6,13.9922 L12.8633111,13.9922 L6.86331111,7.9922 Z"></path></g>
<!-- The polygon ("+" shape) within this icon will always be filled with
Expand Down
@@ -1 +1,71 @@
Ad Measurement subpage under construction.
<style include="settings-shared">
.description-column {
padding: 0 var(--cr-section-padding);
width: 50%;
}

.description-header {
color: var(--google-blue-600);
font-weight: 500;
}

.description-item {
align-items: center;
column-gap: 16px;
display: flex;
padding: 16px 0;
}

.description-wrapper {
display: flex;
padding-top: 4px;
}

@media (prefers-color-scheme: dark) {
.description-header {
color: var(--google-blue-300);
}
}
</style>

<settings-toggle-button
id="adMeasurementToggle"
pref="{{prefs.privacy_sandbox.m1.ad_measurement_enabled}}"
label="$i18n{adMeasurementPageToggleLabel}"
sub-label="$i18n{adMeasurementPageToggleSubLabel}">
</settings-toggle-button>
<div class="description-wrapper">
<div class="description-column">
<div class="description-header">
$i18n{adMeasurementPageEnabledHeading}
</div>
<div role="list">
<div class="description-item">
<iron-icon icon="settings20:spam" aria-hidden="true"></iron-icon>
<div class="secondary">
$i18n{adMeasurementPageEnabledBullet1}
</div>
</div>
<div class="description-item">
<iron-icon icon="settings20:performance-max" aria-hidden="true">
</iron-icon>
<div class="secondary">
$i18n{adMeasurementPageEnabledBullet2}
</div>
</div>
</div>
</div>
<div class="description-column">
<div class="description-header">
$i18n{adMeasurementPageConsiderHeading}
</div>
<div role="list">
<div class="description-item">
<iron-icon icon="settings:permissions" aria-hidden="true"></iron-icon>
<div class="secondary">
$i18n{adMeasurementPageConsiderBullet1}
</div>
</div>
</div>
</div>
</div>
Expand Up @@ -2,14 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../../controls/settings_toggle_button.js';
import '../../prefs/prefs.js';
import '../../settings_shared.css.js';

import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {SettingsToggleButtonElement} from '../../controls/settings_toggle_button.js';
import {PrefsMixin} from '../../prefs/prefs_mixin.js';

import {getTemplate} from './privacy_sandbox_ad_measurement_subpage.html.js';

export interface SettingsPrivacySandboxAdMeasurementSubpageElement {
$: {
adMeasurementToggle: SettingsToggleButtonElement,
};
}

const SettingsPrivacySandboxAdMeasurementSubpageElementBase =
PrefsMixin(PolymerElement);

Expand Down
Expand Up @@ -1874,6 +1874,20 @@ void AddPrivacySandboxStrings(content::WebUIDataSource* html_source,
{"topicsPageTitle", IDS_SETTINGS_TOPICS_PAGE_TITLE},
{"fledgePageTitle", IDS_SETTINGS_FLEDGE_PAGE_TITLE},
{"adMeasurementPageTitle", IDS_SETTINGS_AD_MEASUREMENT_PAGE_TITLE},
{"adMeasurementPageToggleLabel",
IDS_SETTINGS_AD_MEASUREMENT_PAGE_TOGGLE_LABEL},
{"adMeasurementPageToggleSubLabel",
IDS_SETTINGS_AD_MEASUREMENT_PAGE_TOGGLE_SUB_LABEL},
{"adMeasurementPageEnabledHeading",
IDS_SETTINGS_AD_MEASUREMENT_PAGE_ENABLED_HEADING},
{"adMeasurementPageConsiderHeading",
IDS_SETTINGS_AD_MEASUREMENT_PAGE_CONSIDER_HEADING},
{"adMeasurementPageEnabledBullet1",
IDS_SETTINGS_AD_MEASUREMENT_PAGE_ENABLED_BULLET_1},
{"adMeasurementPageEnabledBullet2",
IDS_SETTINGS_AD_MEASUREMENT_PAGE_ENABLED_BULLET_2},
{"adMeasurementPageConsiderBullet1",
IDS_SETTINGS_AD_MEASUREMENT_PAGE_CONSIDER_BULLET_1},

};
html_source->AddLocalizedStrings(kLocalizedStrings);
Expand Down
6 changes: 6 additions & 0 deletions chrome/test/data/webui/settings/cr_settings_browsertest.js
Expand Up @@ -614,6 +614,12 @@ TEST_F(
runMochaSuite('PrivacySandboxPageTests');
});

TEST_F(
'CrSettingsPrivacySandboxPageTest', 'AdMeasurementSubpageTests',
function() {
runMochaSuite('PrivacySandboxAdMeasurementSubpageTests');
});

var CrSettingsPrivacyGuidePageTest = class extends CrSettingsBrowserTest {
/** @override */
get browsePreload() {
Expand Down
71 changes: 69 additions & 2 deletions chrome/test/data/webui/settings/privacy_sandbox_page_test.ts
Expand Up @@ -5,9 +5,9 @@
import 'chrome://settings/lazy_load.js';

import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {SettingsPrivacySandboxPageElement} from 'chrome://settings/lazy_load.js';
import {SettingsPrivacySandboxAdMeasurementSubpageElement, SettingsPrivacySandboxPageElement} from 'chrome://settings/lazy_load.js';
import {CrSettingsPrefs, Router, routes, SettingsPrefsElement} from 'chrome://settings/settings.js';
import {assertEquals, assertTrue} from 'chrome://webui-test/chai_assert.js';
import {assertEquals, assertFalse, assertTrue} from 'chrome://webui-test/chai_assert.js';
import {flushTasks} from 'chrome://webui-test/polymer_test_util.js';
import {isVisible} from 'chrome://webui-test/test_util.js';

Expand Down Expand Up @@ -111,3 +111,70 @@ suite('PrivacySandboxPageTests', function() {
Router.getInstance().getCurrentRoute());
});
});

suite('PrivacySandboxAdMeasurementSubpageTests', function() {
let page: SettingsPrivacySandboxAdMeasurementSubpageElement;
let settingsPrefs: SettingsPrefsElement;

suiteSetup(function() {
loadTimeData.overrideValues({
isPrivacySandboxRestricted: false,
});
settingsPrefs = document.createElement('settings-prefs');
return CrSettingsPrefs.initialized;
});

setup(function() {
document.body.innerHTML = window.trustedTypes!.emptyHTML;
document.body.appendChild(settingsPrefs);
page = document.createElement(
'settings-privacy-sandbox-ad-measurement-subpage');
page.prefs = settingsPrefs.prefs!;
document.body.appendChild(page);
return flushTasks();
});

teardown(function() {
Router.getInstance().resetRouteForTesting();
});

test('enableAdMeasurementToggle', async function() {
page.setPrefValue('privacy_sandbox.m1.ad_measurement_enabled', false);
await flushTasks();
assertTrue(isVisible(page.$.adMeasurementToggle));
assertFalse(page.$.adMeasurementToggle.checked);
assertEquals(
loadTimeData.getString('adMeasurementPageToggleSubLabel'),
page.$.adMeasurementToggle.subLabel);

page.$.adMeasurementToggle.click();
await flushTasks();
assertTrue(isVisible(page.$.adMeasurementToggle));
assertTrue(page.$.adMeasurementToggle.checked);
assertEquals(
loadTimeData.getString('adMeasurementPageToggleSubLabel'),
page.$.adMeasurementToggle.subLabel);
assertTrue(
!!page.getPref('privacy_sandbox.m1.ad_measurement_enabled.value'));
});

test('disableAdMeasurementToggle', async function() {
page.setPrefValue('privacy_sandbox.m1.ad_measurement_enabled', true);
await flushTasks();
assertTrue(isVisible(page.$.adMeasurementToggle));
assertTrue(page.$.adMeasurementToggle.checked);
assertEquals(
loadTimeData.getString('adMeasurementPageToggleSubLabel'),
page.$.adMeasurementToggle.subLabel);

page.$.adMeasurementToggle.click();
await flushTasks();
assertTrue(isVisible(page.$.adMeasurementToggle));
assertFalse(page.$.adMeasurementToggle.checked);
assertEquals(
loadTimeData.getString('adMeasurementPageToggleSubLabel'),
page.$.adMeasurementToggle.subLabel);
assertFalse(
!!page.getPref('privacy_sandbox.m1.ad_measurement_enabled.value'));
});
});

0 comments on commit 74543cb

Please sign in to comment.