OLD | NEW |
---|---|
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 Loading... | |
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} */ ({}); | |
ftirelo
2017/07/05 19:02:25
Are () required here?
proberge
2017/07/05 20:14:20
Maybe not, but all examples I could find do:
https
| |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 * @param {!Array<!string>} files The list of files to present to the user. | 218 * @param {!Array<!string>} files The list of files to present to the user. |
208 * @private | 219 * @private |
209 */ | 220 */ |
210 onCleaning_: function(files) { | 221 onCleaning_: function(files) { |
211 this.waitingForCleanupResults_ = true; | 222 this.waitingForCleanupResults_ = true; |
212 this.title_ = this.i18n('chromeCleanupTitleRemoving'); | 223 this.title_ = this.i18n('chromeCleanupTitleRemoving'); |
213 this.isRemoving_ = true; | 224 this.isRemoving_ = true; |
214 this.resetIcon_(); | 225 this.resetIcon_(); |
215 this.disableActionButton_(); | 226 this.disableActionButton_(); |
216 this.enableDetails_(files); | 227 this.enableDetails_(files); |
228 this.showLogsPermission_ = false; | |
217 }, | 229 }, |
218 | 230 |
219 /** | 231 /** |
220 * Listener of event 'chrome-cleanup-on-reboot-required'. | 232 * 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 | 233 * 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. | 234 * the card and cleanup this element's fields. |
223 * @private | 235 * @private |
224 */ | 236 */ |
225 onRebootRequired_: function() { | 237 onRebootRequired_: function() { |
226 this.title_ = this.i18n('chromeCleanupTitleRestart'); | 238 this.title_ = this.i18n('chromeCleanupTitleRestart'); |
227 this.isRemoving_ = false; | 239 this.isRemoving_ = false; |
228 this.setIconWarning_(); | 240 this.setIconWarning_(); |
229 this.enableActionButton_( | 241 this.enableActionButton_( |
230 this.i18n('chromeCleanupRestartButtonLabel'), | 242 this.i18n('chromeCleanupRestartButtonLabel'), |
231 this.restartComputer_.bind(this)); | 243 this.restartComputer_.bind(this)); |
232 this.disableDetails_(); | 244 this.disableDetails_(); |
233 }, | 245 }, |
234 | 246 |
235 /** | 247 /** |
236 * Listener of event 'chrome-cleanup-dismiss'. | 248 * Listener of event 'chrome-cleanup-dismiss'. |
237 * Hides the Cleanup card. | 249 * Hides the Cleanup card. |
238 * @private | 250 * @private |
239 */ | 251 */ |
240 onDismiss_: function() { | 252 onDismiss_: function() { |
241 this.fire('chrome-cleanup-dismissed'); | 253 this.fire('chrome-cleanup-dismissed'); |
242 }, | 254 }, |
243 | 255 |
244 /** | 256 /** |
257 * @param {boolean} enabled Whether logs upload is enabled. | |
258 * @private | |
259 */ | |
260 onUploadPermissionChange_: function(enabled) { | |
261 this.logsUploadPref_ = { | |
262 key: '', | |
263 type: chrome.settingsPrivate.PrefType.BOOLEAN, | |
264 value: enabled, | |
265 }; | |
266 }, | |
267 | |
268 /** | |
269 * @param {boolean} enabled Whether to enable logs upload. | |
270 * @private | |
271 */ | |
272 changeLogsPermission_: function(enabled) { | |
273 var enabled = this.$.logsUploadControl.checked; | |
274 this.browserProxy_.setLogsUploadPermission(enabled); | |
275 }, | |
276 | |
277 /** | |
245 * Dismiss the card. | 278 * Dismiss the card. |
246 * @private | 279 * @private |
247 */ | 280 */ |
248 dismiss_: function() { | 281 dismiss_: function() { |
249 this.browserProxy_.dismissCleanupPage(); | 282 this.browserProxy_.dismissCleanupPage(); |
250 }, | 283 }, |
251 | 284 |
252 /** | 285 /** |
253 * Hides the action button in the card when no action is available. | 286 * Hides the action button in the card when no action is available. |
254 * @private | 287 * @private |
(...skipping 16 matching lines...) Expand all Loading... | |
271 this.actionButtonLabel_ = buttonLabel; | 304 this.actionButtonLabel_ = buttonLabel; |
272 this.doAction_ = action; | 305 this.doAction_ = action; |
273 }, | 306 }, |
274 | 307 |
275 /** | 308 /** |
276 * Disables the details section on the card. | 309 * Disables the details section on the card. |
277 * @private | 310 * @private |
278 */ | 311 */ |
279 disableDetails_: function() { | 312 disableDetails_: function() { |
280 this.showDetails_ = false; | 313 this.showDetails_ = false; |
281 this.detailsDescription = ''; | 314 this.showLogsPermission_ = false; |
282 this.showFilesToRemove_ = false; | 315 this.showFilesToRemove_ = false; |
283 this.filesToRemove_ = []; | 316 this.filesToRemove_ = []; |
284 }, | 317 }, |
285 | 318 |
286 /** | 319 /** |
287 * Enables the details section on the card. | 320 * Enables the details section on the card. |
288 * @param {!Array<!string>} files The list of files to present to the user. | 321 * @param {!Array<!string>} files The list of files to present to the user. |
289 * @private | 322 * @private |
290 */ | 323 */ |
291 enableDetails_: function(files) { | 324 enableDetails_: function(files) { |
292 this.showDetails_ = true; | 325 this.showDetails_ = true; |
293 this.detailsDescription = this.i18n('chromeCleanupExplanation'); | 326 this.showLogsPermission_ = true; |
294 // Note: doesn't change the state of this.showFilesToRemove_. | 327 // Note: doesn't change the state of this.showFilesToRemove_. |
295 this.filesToRemove_ = files; | 328 this.filesToRemove_ = files; |
296 }, | 329 }, |
297 | 330 |
298 /** | 331 /** |
299 * Sends an action to the browser proxy to start the cleanup. | 332 * Sends an action to the browser proxy to start the cleanup. |
300 * @private | 333 * @private |
301 */ | 334 */ |
302 startCleanup_: function() { | 335 startCleanup_: function() { |
303 this.browserProxy_.startCleanup(); | 336 this.browserProxy_.startCleanup(this.$.logsUploadControl.checked); |
304 }, | 337 }, |
305 | 338 |
306 /** | 339 /** |
307 * Sends an action to the browser proxy to restart the machine. | 340 * Sends an action to the browser proxy to restart the machine. |
308 * @private | 341 * @private |
309 */ | 342 */ |
310 restartComputer_: function() { | 343 restartComputer_: function() { |
311 this.browserProxy_.restartComputer(); | 344 this.browserProxy_.restartComputer(); |
312 }, | 345 }, |
313 | 346 |
(...skipping 27 matching lines...) Expand all Loading... | |
341 | 374 |
342 /** | 375 /** |
343 * Resets the card's icon. | 376 * Resets the card's icon. |
344 * @private | 377 * @private |
345 */ | 378 */ |
346 resetIcon_: function() { | 379 resetIcon_: function() { |
347 this.statusIcon_ = ''; | 380 this.statusIcon_ = ''; |
348 this.statusIconClassName_ = ''; | 381 this.statusIconClassName_ = ''; |
349 }, | 382 }, |
350 }); | 383 }); |
OLD | NEW |