Skip to content

Commit

Permalink
[SafetyCheck] Add entry points for unused websites.
Browse files Browse the repository at this point in the history
This CL adds entry point for safety check unused permissions module. A
row will be added to safety checks together with a button that routes
to site settings. The strings are TBD, so here the dummy strings are
used.

For now, the entry point will be visible if SafetyCheckPermissions flag
is enabled. However, the triggering mechanism to show unused permissions
will be update in following CLs.

Screenshot: https://screenshot.googleplex.com/83DfXrPsb4fUMdQ

UX deck: https://docs.google.com/presentation/d/1O3MsXYPcGEtgDW42zDjCweDnU8hsnRZvYt_aOfbycek/edit?resourcekey=0-fuBJewxgoJh3cwPq-eBXJg#slide=id.g135e69f8a99_6_9

Bug: 1345920
Change-Id: Iab369e23a5a876182777dd7bd0cb5371556cee24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3779882
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1032503}
  • Loading branch information
Side Yilmaz authored and Chromium LUCI CQ committed Aug 8, 2022
1 parent 05b6bd3 commit 1513018
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 40 deletions.
3 changes: 3 additions & 0 deletions chrome/app/settings_strings.grdp
Expand Up @@ -1811,6 +1811,9 @@
<message name="IDS_SETTINGS_SAFETY_CHECK_REVIEW" desc="Text for a button that allows users to review safety check findings, such as compromised passwords or blocklisted extensions.">
Review
</message>
<message name="IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_PRIMARY_LABEL" translateable="false" desc="The placeholder title for 'Unused Site Permissions' module. It is an element in safety check that shows the revoked permissions of unused websites.">
Permissions removed from unused websites.
</message>
<message name="IDS_SETTINGS_SAFETY_CHECK_UPDATES_PRIMARY_LABEL" desc="'Updates' is an element in safety check that shows the update status of Chrome.">
Updates
</message>
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/BUILD.gn
Expand Up @@ -204,6 +204,7 @@ build_webui("build") {
"safety_check_page/safety_check_page.ts",
"safety_check_page/safety_check_passwords_child.ts",
"safety_check_page/safety_check_safe_browsing_child.ts",
"safety_check_page/safety_check_unused_site_permissions.ts",
"safety_check_page/safety_check_updates_child.ts",
"search_engines_page/omnibox_extension_entry.ts",
"search_engines_page/search_engine_delete_confirmation_dialog.ts",
Expand Down
Expand Up @@ -48,3 +48,8 @@
</settings-safety-check-chrome-cleaner-child>
</if>
</iron-collapse>
<template is="dom-if" if="[[safetyCheckPermissionsEnabled_]]"
restamp>
<settings-safety-check-unused-site-permissions>
</settings-safety-check-unused-site-permissions>
</template>
Expand Up @@ -31,6 +31,7 @@ import {WebUIListenerMixin} from 'chrome://resources/js/web_ui_listener_mixin.js
import {flush, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {HatsBrowserProxyImpl, TrustSafetyInteraction} from '../hats_browser_proxy.js';
import {loadTimeData} from '../i18n_setup.js';
import {MetricsBrowserProxy, MetricsBrowserProxyImpl, SafetyCheckInteractions} from '../metrics_browser_proxy.js';
import {routes} from '../route.js';
import {Router} from '../router.js';
Expand Down Expand Up @@ -66,11 +67,23 @@ export class SettingsSafetyCheckPageElement extends

/** UI string to display for the parent status. */
parentDisplayString_: String,

/**
* Boolean that decides if the entry point for unused site permissions
* should be shown.
*/
safetyCheckPermissionsEnabled_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('safetyCheckPermissionsEnabled');
},
},
};
}

private parentStatus_: SafetyCheckParentStatus;
private parentDisplayString_: string;
private safetyCheckPermissionsEnabled_: boolean;
private safetyCheckBrowserProxy_: SafetyCheckBrowserProxy =
SafetyCheckBrowserProxyImpl.getInstance();
private metricsBrowserProxy_: MetricsBrowserProxy =
Expand Down
@@ -0,0 +1,9 @@
<settings-safety-check-child
id="safetyCheckChild"
icon-status="[[iconStatus_]]"
label="$i18n{safetyCheckUnusedSitePermissionsPrimaryLabel}"
button-label="$i18n{safetyCheckReview}"
button-aria-label="$i18n{safetyCheckReview}"
on-button-click="onButtonClick_"
role="presentation">
</settings-safety-check-child>
@@ -0,0 +1,67 @@
// Copyright 2022 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
* @fileoverview
* 'settings-safety-unused-site-permissions' is the settings page containing the
* safety check unused site permissions module showing the unused sites that has
* some granted permissions.
*/

import './safety_check_child.js';

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

import {routes} from '../route.js';
import {Router} from '../router.js';

import {SafetyCheckIconStatus} from './safety_check_child.js';
import {getTemplate} from './safety_check_unused_site_permissions.html.js';

export interface SettingsSafetyCheckUnusedSitePermissionsElement {
$: {
'safetyCheckChild': SettingsSafetyCheckUnusedSitePermissionsElement,
};
}

export class SettingsSafetyCheckUnusedSitePermissionsElement extends
PolymerElement {
static get is() {
return 'settings-safety-check-unused-site-permissions';
}

static get template() {
return getTemplate();
}

static get properties() {
return {
iconStatus_: {
type: SafetyCheckIconStatus,
value() {
return SafetyCheckIconStatus.WARNING;
},
},
};
}

private iconStatus_: SafetyCheckIconStatus;

private onButtonClick_() {
Router.getInstance().navigateTo(
routes.SITE_SETTINGS, /* dynamicParams= */ undefined,
/* removeSearch= */ true);
}
}

declare global {
interface HTMLElementTagNameMap {
'settings-safety-check-unused-site-permissions':
SettingsSafetyCheckUnusedSitePermissionsElement;
}
}

customElements.define(
SettingsSafetyCheckUnusedSitePermissionsElement.is,
SettingsSafetyCheckUnusedSitePermissionsElement);
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/settings.ts
Expand Up @@ -76,6 +76,7 @@ export {SettingsSafetyCheckExtensionsChildElement} from './safety_check_page/saf
export {SettingsSafetyCheckPageElement} from './safety_check_page/safety_check_page.js';
export {SettingsSafetyCheckPasswordsChildElement} from './safety_check_page/safety_check_passwords_child.js';
export {SettingsSafetyCheckSafeBrowsingChildElement} from './safety_check_page/safety_check_safe_browsing_child.js';
export {SettingsSafetyCheckUnusedSitePermissionsElement} from './safety_check_page/safety_check_unused_site_permissions.js';
export {SettingsSafetyCheckUpdatesChildElement} from './safety_check_page/safety_check_updates_child.js';
export {SearchEngine, SearchEnginesBrowserProxy, SearchEnginesBrowserProxyImpl, SearchEnginesInfo, SearchEnginesInteractions} from './search_engines_page/search_engines_browser_proxy.js';
export {SettingsSearchPageElement} from './search_page/search_page.js';
Expand Down
Expand Up @@ -1947,6 +1947,8 @@ void AddSafetyCheckStrings(content::WebUIDataSource* html_source) {
{"safetyCheckIconWarningAriaLabel",
IDS_SETTINGS_SAFETY_CHECK_ICON_WARNING_ARIA_LABEL},
{"safetyCheckReview", IDS_SETTINGS_SAFETY_CHECK_REVIEW},
{"safetyCheckUnusedSitePermissionsPrimaryLabel",
IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_PRIMARY_LABEL},
{"safetyCheckUpdatesPrimaryLabel",
IDS_SETTINGS_SAFETY_CHECK_UPDATES_PRIMARY_LABEL},
{"safetyCheckUpdatesButtonAriaLabel", IDS_UPDATE_RECOMMENDED_DIALOG_TITLE},
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/webui/settings/settings_ui.cc
Expand Up @@ -397,6 +397,10 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
"privacySandbox", IDR_SETTINGS_PRIVACY_SANDBOX_PRIVACY_SANDBOX_HTML);
}

html_source->AddBoolean(
"safetyCheckPermissionsEnabled",
base::FeatureList::IsEnabled(features::kSafetyCheckPermissions));

TryShowHatsSurveyWithTimeout();
}

Expand Down
2 changes: 2 additions & 0 deletions chrome/test/data/webui/settings/BUILD.gn
Expand Up @@ -92,6 +92,8 @@ non_preprocessed_files = [
"reset_page_test.ts",
"reset_profile_banner_test.ts",
"safety_check_page_test.ts",
"safety_check_permissions_test.ts",
"safety_check_test_utils.ts",
"search_engines_page_test.ts",
"search_page_test.ts",
"search_settings_test.ts",
Expand Down
20 changes: 20 additions & 0 deletions chrome/test/data/webui/settings/cr_settings_browsertest.js
Expand Up @@ -341,6 +341,26 @@ TEST_F('CrSettingsSafetyCheckPageTest', 'All', function() {
mocha.run();
});

var CrSettingsSafetyCheckPermissionsTest = class extends CrSettingsBrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/safety_check_permissions_test.js';
}

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

TEST_F('CrSettingsSafetyCheckPermissionsTest', 'All', function() {
mocha.run();
});

GEN('#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)');
var CrSettingsSafetyCheckChromeCleanerTest =
class extends CrSettingsBrowserTest {
Expand Down

0 comments on commit 1513018

Please sign in to comment.