Commit 457ff60a authored by Rainhard Findling's avatar Rainhard Findling Committed by Commit Bot

CCT scan completion notification: checkbox in Settings UI behind flag

Bug: 1087263
Change-Id: I85e269707a7579c8894a25ab1d8dc7da71009906
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2494766
Commit-Queue: Rainhard Findling <rainhard@chromium.org>
Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821174}
parent 70ecafd1
......@@ -3118,6 +3118,9 @@
<message name="IDS_SETTINGS_RESET_CLEANUP_LOGS_PERMISSION_PREF" desc="A checkbox label for the 'Report harmful software removal details' preference.">
Report details to Google about harmful software, system settings, and processes that were found on your computer during this cleanup
</message>
<message name="IDS_SETTINGS_RESET_CLEANUP_EXPLANTION_NOTIFICATION_PERMISSION" desc="A checkbox label for showing a notification dialog to users once the Chrome scan for harmful software completed.">
Notify me when Chrome has finished searching for harmful software
</message>
<message name="IDS_SETTINGS_RESET_CLEANUP_TITLE_CLEANUP_UNAVAILABLE" desc="Title of error message that could appear before the cleanup of harmful software because Chrome failed to contact the server. This message will only appear on Windows desktop/laptop computers.">
Cleanup is currently unavailable
</message>
......
......@@ -23,6 +23,7 @@ js_library("chrome_cleanup_page") {
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:i18n_behavior.m",
"//ui/webui/resources/js:load_time_data.m",
"//ui/webui/resources/js:web_ui_listener_behavior.m",
]
externs_list = [ "$externs_path/settings_private.js" ]
......
......@@ -43,6 +43,13 @@
disabled$="[[!cleanupEnabled_]]">
</settings-checkbox>
</div>
<div class="cr-row continuation">
<settings-checkbox hidden="[[!showNotificationPermission_]]"
id="chromeCleanupShowNotificationControl"
sub-label="$i18n{chromeCleanupExplanationNotificationPermission}"
disabled$="[[!cleanupEnabled_]]">
</settings-checkbox>
</div>
<cr-expand-button
alt="[[showItemsLinkLabel_]]"
class="cr-row"
......
......@@ -18,6 +18,7 @@ import '../settings_shared_css.m.js';
import {assert} from 'chrome://resources/js/assert.m.js';
import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
......@@ -68,6 +69,7 @@ const ChromeCleanupCardFlags = {
SHOW_LOGS_PERMISSIONS: 1 << 0,
WAITING_FOR_RESULT: 1 << 1,
SHOW_ITEMS_TO_REMOVE: 1 << 2,
SHOW_NOTIFICATION_PERMISSION: 1 << 3,
};
/**
......@@ -193,6 +195,12 @@ Polymer({
value: false,
},
/** @private */
showNotificationPermission_: {
type: Boolean,
value: false,
},
/** @private */
showItemsToRemove_: {
type: Boolean,
......@@ -544,6 +552,12 @@ Polymer({
(flags & ChromeCleanupCardFlags.WAITING_FOR_RESULT) !== 0;
this.showItemsToRemove_ =
(flags & ChromeCleanupCardFlags.SHOW_ITEMS_TO_REMOVE) !== 0;
this.showNotificationPermission_ =
(flags & ChromeCleanupCardFlags.SHOW_NOTIFICATION_PERMISSION) !== 0 &&
loadTimeData.valueExists(
'chromeCleanupScanCompletedNotificationEnabled') &&
loadTimeData.getBoolean(
'chromeCleanupScanCompletedNotificationEnabled');
// Files to remove list should only be expandable if details are being
// shown, otherwise it will add extra padding at the bottom of the card.
......@@ -566,7 +580,8 @@ Polymer({
*/
startScanning_() {
this.browserProxy_.startScanning(
this.$.chromeCleanupLogsUploadControl.checked);
this.$.chromeCleanupLogsUploadControl.checked,
this.$.chromeCleanupShowNotificationControl.checked);
},
/**
......@@ -685,7 +700,8 @@ Polymer({
title: this.i18n('chromeCleanupTitleFindAndRemove'),
explanation: this.i18n('chromeCleanupExplanationFindAndRemove'),
actionButton: actionButtons.FIND,
flags: ChromeCleanupCardFlags.SHOW_LOGS_PERMISSIONS,
flags: ChromeCleanupCardFlags.SHOW_LOGS_PERMISSIONS |
ChromeCleanupCardFlags.SHOW_NOTIFICATION_PERMISSION,
}
],
[
......
......@@ -17,8 +17,9 @@ export class ChromeCleanupProxy {
/**
* Starts scanning the user's computer.
* @param {boolean} logsUploadEnabled
* @param {boolean} notificationEnabled
*/
startScanning(logsUploadEnabled) {}
startScanning(logsUploadEnabled, notificationEnabled) {}
/**
* Starts a cleanup on the user's computer.
......@@ -69,7 +70,9 @@ export class ChromeCleanupProxyImpl {
}
/** @override */
startScanning(logsUploadEnabled) {
startScanning(logsUploadEnabled, notificationEnabled) {
// TODO(1087263): Send the |notificationEnabled| parameter which indicates
// if a completion dialog should be shown once the scan completed.
chrome.send('startScanning', [logsUploadEnabled]);
}
......
......@@ -518,6 +518,8 @@ void AddChromeCleanupStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_RESET_CLEANUP_TRY_AGAIN_BUTTON_LABEL},
{"chromeCleanupExplanationLogsPermissionPref",
IDS_SETTINGS_RESET_CLEANUP_LOGS_PERMISSION_PREF},
{"chromeCleanupExplanationNotificationPermission",
IDS_SETTINGS_RESET_CLEANUP_EXPLANTION_NOTIFICATION_PERMISSION},
{"chromeCleanupTitleCleanupUnavailable",
IDS_SETTINGS_RESET_CLEANUP_TITLE_CLEANUP_UNAVAILABLE},
{"chromeCleanupExplanationCleanupUnavailable",
......
......@@ -40,8 +40,9 @@ class TestChromeCleanupProxy extends TestBrowserProxy {
}
/** @override */
startScanning(logsUploadEnabled) {
this.methodCalled('startScanning', logsUploadEnabled);
startScanning(logsUploadEnabled, notificationEnabled) {
this.methodCalled(
'startScanning', [logsUploadEnabled, notificationEnabled]);
}
/** @override */
......@@ -375,24 +376,45 @@ suite('ChromeCleanupHandler', function() {
assertFalse(!!actionButton);
});
test('startScanFromIdle', function() {
/**
* @param {boolean} clickNotification Whether to test the case
* where the user clicks on the completion notification option.
* @return {!Promise}
*/
async function startScanFromIdle(clickNotification) {
updateReportingEnabledPref(false);
webUIListenerCallback(
'chrome-cleanup-on-idle', ChromeCleanupIdleReason.INITIAL);
flush();
if (clickNotification) {
const notificationControl =
chromeCleanupPage.$$('#chromeCleanupShowNotificationControl');
assertTrue(!!notificationControl);
notificationControl.$.checkbox.click();
}
const actionButton = chromeCleanupPage.$$('#action-button');
assertTrue(!!actionButton);
actionButton.click();
return chromeCleanupProxy.whenCalled('startScanning')
.then(function(logsUploadEnabled) {
const [logsUploadEnabled, notificationEnabled] =
await chromeCleanupProxy.whenCalled('startScanning');
assertFalse(logsUploadEnabled);
// Notification is disabled by default, hence a click enables it.
assertEquals(clickNotification, notificationEnabled);
webUIListenerCallback('chrome-cleanup-on-scanning', false);
flush();
const spinner = chromeCleanupPage.$$('#waiting-spinner');
assertTrue(spinner.active);
}
test('startScanFromIdle_NotificationDisabled', function() {
return startScanFromIdle(false);
});
test('startScanFromIdle_NotificationEnabled', function() {
return startScanFromIdle(true);
});
test('scanFoundNothing', 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