Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js

Issue 2971823002: Cleanup Tool WebUI: Add logs upload checkbox and minor polishing (Closed)
Patch Set: Address review comments on #3, simplify idle error cases Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * The reason why the controller is in state kIdle. 6 * The reason why the controller is in state kIdle.
7 * Must be kept in sync with ChromeCleanerController::IdleReason. 7 * Must be kept in sync with ChromeCleanerController::IdleReason.
8 * @enum {string} 8 * @enum {string}
9 */ 9 */
10 settings.ChromeCleanupIdleReason = { 10 settings.ChromeCleanupIdleReason = {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 value: '', 59 value: '',
60 }, 60 },
61 61
62 /** @private */ 62 /** @private */
63 showDetails_: { 63 showDetails_: {
64 type: Boolean, 64 type: Boolean,
65 value: false, 65 value: false,
66 }, 66 },
67 67
68 /** @private */ 68 /** @private */
69 detailsDescription: { 69 showLogsPermission_: {
70 type: String, 70 type: Boolean,
71 value: '', 71 value: false,
72 }, 72 },
73 73
74 /** @private */ 74 /** @private */
75 showFilesToRemove_: { 75 showFilesToRemove_: {
76 type: Boolean, 76 type: Boolean,
77 value: false, 77 value: false,
78 }, 78 },
79 79
80 /** @private */ 80 /** @private */
81 filesToRemove_: { 81 filesToRemove_: {
82 type: Array, 82 type: Array,
83 value: [], 83 value: [],
84 }, 84 },
85 85
86 /** @private */ 86 /** @private */
87 statusIcon_: { 87 statusIcon_: {
88 type: String, 88 type: String,
89 value: '', 89 value: '',
90 }, 90 },
91 91
92 /** @private */ 92 /** @private */
93 statusIconClassName_: { 93 statusIconClassName_: {
94 type: String, 94 type: String,
95 value: '', 95 value: '',
96 }, 96 },
97
98 /** @private {chrome.settingsPrivate.PrefObject} */
99 logsUploadPref_: {
100 type: Object,
101 value: function() {
102 return /** @type {chrome.settingsPrivate.PrefObject} */ ({});
103 },
104 },
97 }, 105 },
98 106
99 /** @private {?settings.ChromeCleanupProxy} */ 107 /** @private {?settings.ChromeCleanupProxy} */
100 browserProxy_: null, 108 browserProxy_: null,
101 109
102 /** @private {?function()} */ 110 /** @private {?function()} */
103 doAction_: null, 111 doAction_: null,
104 112
105 /** 113 /**
106 * If true, this settings page is waiting for cleanup results. 114 * If true, this settings page is waiting for cleanup results.
107 * @private {boolean} 115 * @private {boolean}
108 */ 116 */
109 waitingForCleanupResults_: false, 117 waitingForCleanupResults_: false,
110 118
111 /** @override */ 119 /** @override */
112 attached: function() { 120 attached: function() {
113 this.browserProxy_ = settings.ChromeCleanupProxyImpl.getInstance(); 121 this.browserProxy_ = settings.ChromeCleanupProxyImpl.getInstance();
114 122
115 this.addWebUIListener('chrome-cleanup-on-idle', this.onIdle_.bind(this)); 123 this.addWebUIListener('chrome-cleanup-on-idle', this.onIdle_.bind(this));
116 this.addWebUIListener( 124 this.addWebUIListener(
117 'chrome-cleanup-on-scanning', this.onScanning_.bind(this)); 125 'chrome-cleanup-on-scanning', this.onScanning_.bind(this));
118 this.addWebUIListener( 126 this.addWebUIListener(
119 'chrome-cleanup-on-infected', this.onInfected_.bind(this)); 127 'chrome-cleanup-on-infected', this.onInfected_.bind(this));
120 this.addWebUIListener( 128 this.addWebUIListener(
121 'chrome-cleanup-on-cleaning', this.onCleaning_.bind(this)); 129 'chrome-cleanup-on-cleaning', this.onCleaning_.bind(this));
122 this.addWebUIListener( 130 this.addWebUIListener(
123 'chrome-cleanup-on-reboot-required', this.onRebootRequired_.bind(this)); 131 'chrome-cleanup-on-reboot-required', this.onRebootRequired_.bind(this));
124 this.addWebUIListener( 132 this.addWebUIListener(
125 'chrome-cleanup-on-dismiss', this.onDismiss_.bind(this)); 133 'chrome-cleanup-on-dismiss', this.onDismiss_.bind(this));
134 this.addWebUIListener(
135 'chrome-cleanup-upload-permission-change',
136 this.onUploadPermissionChange_.bind(this));
126 137
127 this.browserProxy_.registerChromeCleanerObserver(); 138 this.browserProxy_.registerChromeCleanerObserver();
128 }, 139 },
129 140
130 /** 141 /**
131 * Implements the action for the only visible button in the UI, which can be 142 * Implements the action for the only visible button in the UI, which can be
132 * either to start a cleanup or to restart the computer. 143 * either to start a cleanup or to restart the computer.
133 * @private 144 * @private
134 */ 145 */
135 proceed_: function() { 146 proceed_: function() {
(...skipping 12 matching lines...) Expand all
148 * Listener of event 'chrome-cleanup-on-idle'. 159 * Listener of event 'chrome-cleanup-on-idle'.
149 * @param {number} idleReason 160 * @param {number} idleReason
150 * @private 161 * @private
151 */ 162 */
152 onIdle_: function(idleReason) { 163 onIdle_: function(idleReason) {
153 if (idleReason == settings.ChromeCleanupIdleReason.CLEANING_SUCCEEDED) { 164 if (idleReason == settings.ChromeCleanupIdleReason.CLEANING_SUCCEEDED) {
154 this.title_ = this.i18n('chromeCleanupTitleRemoved'); 165 this.title_ = this.i18n('chromeCleanupTitleRemoved');
155 this.enableActionButton_( 166 this.enableActionButton_(
156 this.i18n('chromeCleanupDoneButtonLabel'), this.dismiss_.bind(this)); 167 this.i18n('chromeCleanupDoneButtonLabel'), this.dismiss_.bind(this));
157 this.setIconDone_(); 168 this.setIconDone_();
158 } else if (idleReason == settings.ChromeCleanupIdleReason.CLEANING_FAILED) { 169 } else {
170 // Scanning-related idle reasons are unexpected. Show an error message for
171 // all reasons other than |CLEANING_SUCCEEDED|.
159 this.title_ = this.i18n('chromeCleanupTitleErrorCantRemove'); 172 this.title_ = this.i18n('chromeCleanupTitleErrorCantRemove');
160 this.enableActionButton_( 173 this.enableActionButton_(
161 this.i18n('chromeCleanupDoneButtonLabel'), this.dismiss_.bind(this)); 174 this.i18n('chromeCleanupDoneButtonLabel'), this.dismiss_.bind(this));
162 this.setIconWarning_(); 175 this.setIconWarning_();
163 } else {
164 // TODO(proberge): Handle other cases.
165 this.title_ = '';
166 this.disableActionButton_();
167 } 176 }
168 177
169 this.isRemoving_ = false; 178 this.isRemoving_ = false;
170 this.disableDetails_(); 179 this.disableDetails_();
171 this.waitingForCleanupResults_ = false; 180 this.waitingForCleanupResults_ = false;
172 }, 181 },
173 182
174 /** 183 /**
175 * Listener of event 'chrome-cleanup-on-scanning'. 184 * Listener of event 'chrome-cleanup-on-scanning'.
176 * No UI will be shown in the Settings page on that state, so we simply hide 185 * No UI will be shown in the Settings page on that state, so we simply hide
(...skipping 30 matching lines...) Expand all
207 * @param {!Array<!string>} files The list of files to present to the user. 216 * @param {!Array<!string>} files The list of files to present to the user.
208 * @private 217 * @private
209 */ 218 */
210 onCleaning_: function(files) { 219 onCleaning_: function(files) {
211 this.waitingForCleanupResults_ = true; 220 this.waitingForCleanupResults_ = true;
212 this.title_ = this.i18n('chromeCleanupTitleRemoving'); 221 this.title_ = this.i18n('chromeCleanupTitleRemoving');
213 this.isRemoving_ = true; 222 this.isRemoving_ = true;
214 this.resetIcon_(); 223 this.resetIcon_();
215 this.disableActionButton_(); 224 this.disableActionButton_();
216 this.enableDetails_(files); 225 this.enableDetails_(files);
226 this.showLogsPermission_ = false;
217 }, 227 },
218 228
219 /** 229 /**
220 * Listener of event 'chrome-cleanup-on-reboot-required'. 230 * Listener of event 'chrome-cleanup-on-reboot-required'.
221 * No UI will be shown in the Settings page on that state, so we simply hide 231 * No UI will be shown in the Settings page on that state, so we simply hide
222 * the card and cleanup this element's fields. 232 * the card and cleanup this element's fields.
223 * @private 233 * @private
224 */ 234 */
225 onRebootRequired_: function() { 235 onRebootRequired_: function() {
226 this.title_ = this.i18n('chromeCleanupTitleRestart'); 236 this.title_ = this.i18n('chromeCleanupTitleRestart');
227 this.isRemoving_ = false; 237 this.isRemoving_ = false;
228 this.setIconWarning_(); 238 this.setIconWarning_();
229 this.enableActionButton_( 239 this.enableActionButton_(
230 this.i18n('chromeCleanupRestartButtonLabel'), 240 this.i18n('chromeCleanupRestartButtonLabel'),
231 this.restartComputer_.bind(this)); 241 this.restartComputer_.bind(this));
232 this.disableDetails_(); 242 this.disableDetails_();
233 }, 243 },
234 244
235 /** 245 /**
236 * Listener of event 'chrome-cleanup-dismiss'. 246 * Listener of event 'chrome-cleanup-dismiss'.
237 * Hides the Cleanup card. 247 * Hides the Cleanup card.
238 * @private 248 * @private
239 */ 249 */
240 onDismiss_: function() { 250 onDismiss_: function() {
241 this.fire('chrome-cleanup-dismissed'); 251 this.fire('chrome-cleanup-dismissed');
242 }, 252 },
243 253
244 /** 254 /**
255 * @param {boolean} enabled Whether logs upload is enabled.
256 * @private
257 */
258 onUploadPermissionChange_: function(enabled) {
259 this.logsUploadPref_ = {
260 key: '',
261 type: chrome.settingsPrivate.PrefType.BOOLEAN,
262 value: enabled,
263 };
264 },
265
266 /**
267 * @param {boolean} enabled Whether to enable logs upload.
268 * @private
269 */
270 changeLogsPermission_: function(enabled) {
271 var enabled = this.$.chromeCleanupLogsUploadControl.checked;
272 this.browserProxy_.setLogsUploadPermission(enabled);
273 },
274
275 /**
245 * Dismiss the card. 276 * Dismiss the card.
246 * @private 277 * @private
247 */ 278 */
248 dismiss_: function() { 279 dismiss_: function() {
249 this.browserProxy_.dismissCleanupPage(); 280 this.browserProxy_.dismissCleanupPage();
250 }, 281 },
251 282
252 /** 283 /**
253 * Hides the action button in the card when no action is available. 284 * Hides the action button in the card when no action is available.
254 * @private 285 * @private
(...skipping 16 matching lines...) Expand all
271 this.actionButtonLabel_ = buttonLabel; 302 this.actionButtonLabel_ = buttonLabel;
272 this.doAction_ = action; 303 this.doAction_ = action;
273 }, 304 },
274 305
275 /** 306 /**
276 * Disables the details section on the card. 307 * Disables the details section on the card.
277 * @private 308 * @private
278 */ 309 */
279 disableDetails_: function() { 310 disableDetails_: function() {
280 this.showDetails_ = false; 311 this.showDetails_ = false;
281 this.detailsDescription = ''; 312 this.showLogsPermission_ = false;
282 this.showFilesToRemove_ = false; 313 this.showFilesToRemove_ = false;
283 this.filesToRemove_ = []; 314 this.filesToRemove_ = [];
284 }, 315 },
285 316
286 /** 317 /**
287 * Enables the details section on the card. 318 * Enables the details section on the card.
288 * @param {!Array<!string>} files The list of files to present to the user. 319 * @param {!Array<!string>} files The list of files to present to the user.
289 * @private 320 * @private
290 */ 321 */
291 enableDetails_: function(files) { 322 enableDetails_: function(files) {
292 this.showDetails_ = true; 323 this.showDetails_ = true;
293 this.detailsDescription = this.i18n('chromeCleanupExplanation'); 324 this.showLogsPermission_ = true;
294 // Note: doesn't change the state of this.showFilesToRemove_. 325 // Note: doesn't change the state of this.showFilesToRemove_.
295 this.filesToRemove_ = files; 326 this.filesToRemove_ = files;
296 }, 327 },
297 328
298 /** 329 /**
299 * Sends an action to the browser proxy to start the cleanup. 330 * Sends an action to the browser proxy to start the cleanup.
300 * @private 331 * @private
301 */ 332 */
302 startCleanup_: function() { 333 startCleanup_: function() {
303 this.browserProxy_.startCleanup(); 334 this.browserProxy_.startCleanup(
335 this.$.chromeCleanupLogsUploadControl.checked);
304 }, 336 },
305 337
306 /** 338 /**
307 * Sends an action to the browser proxy to restart the machine. 339 * Sends an action to the browser proxy to restart the machine.
308 * @private 340 * @private
309 */ 341 */
310 restartComputer_: function() { 342 restartComputer_: function() {
311 this.browserProxy_.restartComputer(); 343 this.browserProxy_.restartComputer();
312 }, 344 },
313 345
(...skipping 27 matching lines...) Expand all
341 373
342 /** 374 /**
343 * Resets the card's icon. 375 * Resets the card's icon.
344 * @private 376 * @private
345 */ 377 */
346 resetIcon_: function() { 378 resetIcon_: function() {
347 this.statusIcon_ = ''; 379 this.statusIcon_ = '';
348 this.statusIconClassName_ = ''; 380 this.statusIconClassName_ = '';
349 }, 381 },
350 }); 382 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698