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 @@ ...@@ -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."> <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 Report details to Google about harmful software, system settings, and processes that were found on your computer during this cleanup
</message> </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."> <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 Cleanup is currently unavailable
</message> </message>
......
...@@ -23,6 +23,7 @@ js_library("chrome_cleanup_page") { ...@@ -23,6 +23,7 @@ js_library("chrome_cleanup_page") {
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m", "//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:i18n_behavior.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", "//ui/webui/resources/js:web_ui_listener_behavior.m",
] ]
externs_list = [ "$externs_path/settings_private.js" ] externs_list = [ "$externs_path/settings_private.js" ]
......
...@@ -43,6 +43,13 @@ ...@@ -43,6 +43,13 @@
disabled$="[[!cleanupEnabled_]]"> disabled$="[[!cleanupEnabled_]]">
</settings-checkbox> </settings-checkbox>
</div> </div>
<div class="cr-row continuation">
<settings-checkbox hidden="[[!showNotificationPermission_]]"
id="chromeCleanupShowNotificationControl"
sub-label="$i18n{chromeCleanupExplanationNotificationPermission}"
disabled$="[[!cleanupEnabled_]]">
</settings-checkbox>
</div>
<cr-expand-button <cr-expand-button
alt="[[showItemsLinkLabel_]]" alt="[[showItemsLinkLabel_]]"
class="cr-row" class="cr-row"
......
...@@ -18,6 +18,7 @@ import '../settings_shared_css.m.js'; ...@@ -18,6 +18,7 @@ import '../settings_shared_css.m.js';
import {assert} from 'chrome://resources/js/assert.m.js'; import {assert} from 'chrome://resources/js/assert.m.js';
import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.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 {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'; import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
...@@ -68,6 +69,7 @@ const ChromeCleanupCardFlags = { ...@@ -68,6 +69,7 @@ const ChromeCleanupCardFlags = {
SHOW_LOGS_PERMISSIONS: 1 << 0, SHOW_LOGS_PERMISSIONS: 1 << 0,
WAITING_FOR_RESULT: 1 << 1, WAITING_FOR_RESULT: 1 << 1,
SHOW_ITEMS_TO_REMOVE: 1 << 2, SHOW_ITEMS_TO_REMOVE: 1 << 2,
SHOW_NOTIFICATION_PERMISSION: 1 << 3,
}; };
/** /**
...@@ -193,6 +195,12 @@ Polymer({ ...@@ -193,6 +195,12 @@ Polymer({
value: false, value: false,
}, },
/** @private */
showNotificationPermission_: {
type: Boolean,
value: false,
},
/** @private */ /** @private */
showItemsToRemove_: { showItemsToRemove_: {
type: Boolean, type: Boolean,
...@@ -544,6 +552,12 @@ Polymer({ ...@@ -544,6 +552,12 @@ Polymer({
(flags & ChromeCleanupCardFlags.WAITING_FOR_RESULT) !== 0; (flags & ChromeCleanupCardFlags.WAITING_FOR_RESULT) !== 0;
this.showItemsToRemove_ = this.showItemsToRemove_ =
(flags & ChromeCleanupCardFlags.SHOW_ITEMS_TO_REMOVE) !== 0; (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 // 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. // shown, otherwise it will add extra padding at the bottom of the card.
...@@ -566,7 +580,8 @@ Polymer({ ...@@ -566,7 +580,8 @@ Polymer({
*/ */
startScanning_() { startScanning_() {
this.browserProxy_.startScanning( this.browserProxy_.startScanning(
this.$.chromeCleanupLogsUploadControl.checked); this.$.chromeCleanupLogsUploadControl.checked,
this.$.chromeCleanupShowNotificationControl.checked);
}, },
/** /**
...@@ -685,7 +700,8 @@ Polymer({ ...@@ -685,7 +700,8 @@ Polymer({
title: this.i18n('chromeCleanupTitleFindAndRemove'), title: this.i18n('chromeCleanupTitleFindAndRemove'),
explanation: this.i18n('chromeCleanupExplanationFindAndRemove'), explanation: this.i18n('chromeCleanupExplanationFindAndRemove'),
actionButton: actionButtons.FIND, actionButton: actionButtons.FIND,
flags: ChromeCleanupCardFlags.SHOW_LOGS_PERMISSIONS, flags: ChromeCleanupCardFlags.SHOW_LOGS_PERMISSIONS |
ChromeCleanupCardFlags.SHOW_NOTIFICATION_PERMISSION,
} }
], ],
[ [
......
...@@ -17,8 +17,9 @@ export class ChromeCleanupProxy { ...@@ -17,8 +17,9 @@ export class ChromeCleanupProxy {
/** /**
* Starts scanning the user's computer. * Starts scanning the user's computer.
* @param {boolean} logsUploadEnabled * @param {boolean} logsUploadEnabled
* @param {boolean} notificationEnabled
*/ */
startScanning(logsUploadEnabled) {} startScanning(logsUploadEnabled, notificationEnabled) {}
/** /**
* Starts a cleanup on the user's computer. * Starts a cleanup on the user's computer.
...@@ -69,7 +70,9 @@ export class ChromeCleanupProxyImpl { ...@@ -69,7 +70,9 @@ export class ChromeCleanupProxyImpl {
} }
/** @override */ /** @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]); chrome.send('startScanning', [logsUploadEnabled]);
} }
......
...@@ -518,6 +518,8 @@ void AddChromeCleanupStrings(content::WebUIDataSource* html_source) { ...@@ -518,6 +518,8 @@ void AddChromeCleanupStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_RESET_CLEANUP_TRY_AGAIN_BUTTON_LABEL}, IDS_SETTINGS_RESET_CLEANUP_TRY_AGAIN_BUTTON_LABEL},
{"chromeCleanupExplanationLogsPermissionPref", {"chromeCleanupExplanationLogsPermissionPref",
IDS_SETTINGS_RESET_CLEANUP_LOGS_PERMISSION_PREF}, IDS_SETTINGS_RESET_CLEANUP_LOGS_PERMISSION_PREF},
{"chromeCleanupExplanationNotificationPermission",
IDS_SETTINGS_RESET_CLEANUP_EXPLANTION_NOTIFICATION_PERMISSION},
{"chromeCleanupTitleCleanupUnavailable", {"chromeCleanupTitleCleanupUnavailable",
IDS_SETTINGS_RESET_CLEANUP_TITLE_CLEANUP_UNAVAILABLE}, IDS_SETTINGS_RESET_CLEANUP_TITLE_CLEANUP_UNAVAILABLE},
{"chromeCleanupExplanationCleanupUnavailable", {"chromeCleanupExplanationCleanupUnavailable",
......
...@@ -40,8 +40,9 @@ class TestChromeCleanupProxy extends TestBrowserProxy { ...@@ -40,8 +40,9 @@ class TestChromeCleanupProxy extends TestBrowserProxy {
} }
/** @override */ /** @override */
startScanning(logsUploadEnabled) { startScanning(logsUploadEnabled, notificationEnabled) {
this.methodCalled('startScanning', logsUploadEnabled); this.methodCalled(
'startScanning', [logsUploadEnabled, notificationEnabled]);
} }
/** @override */ /** @override */
...@@ -375,24 +376,45 @@ suite('ChromeCleanupHandler', function() { ...@@ -375,24 +376,45 @@ suite('ChromeCleanupHandler', function() {
assertFalse(!!actionButton); 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); updateReportingEnabledPref(false);
webUIListenerCallback( webUIListenerCallback(
'chrome-cleanup-on-idle', ChromeCleanupIdleReason.INITIAL); 'chrome-cleanup-on-idle', ChromeCleanupIdleReason.INITIAL);
flush(); flush();
if (clickNotification) {
const notificationControl =
chromeCleanupPage.$$('#chromeCleanupShowNotificationControl');
assertTrue(!!notificationControl);
notificationControl.$.checkbox.click();
}
const actionButton = chromeCleanupPage.$$('#action-button'); const actionButton = chromeCleanupPage.$$('#action-button');
assertTrue(!!actionButton); assertTrue(!!actionButton);
actionButton.click(); actionButton.click();
return chromeCleanupProxy.whenCalled('startScanning') const [logsUploadEnabled, notificationEnabled] =
.then(function(logsUploadEnabled) { await chromeCleanupProxy.whenCalled('startScanning');
assertFalse(logsUploadEnabled); assertFalse(logsUploadEnabled);
// Notification is disabled by default, hence a click enables it.
assertEquals(clickNotification, notificationEnabled);
webUIListenerCallback('chrome-cleanup-on-scanning', false); webUIListenerCallback('chrome-cleanup-on-scanning', false);
flush(); flush();
const spinner = chromeCleanupPage.$$('#waiting-spinner'); const spinner = chromeCleanupPage.$$('#waiting-spinner');
assertTrue(spinner.active); assertTrue(spinner.active);
}
test('startScanFromIdle_NotificationDisabled', function() {
return startScanFromIdle(false);
}); });
test('startScanFromIdle_NotificationEnabled', function() {
return startScanFromIdle(true);
}); });
test('scanFoundNothing', function() { 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