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

Side by Side Diff: chrome/browser/resources/cleanup_tool/manager.js

Issue 2819633003: Cleanup Tool WebUI: Add functionality to the Cleanup button (Closed)
Patch Set: minor cleanups Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 Polymer({ 5 Polymer({
6 is: 'cleanup-manager', 6 is: 'cleanup-manager',
7 7
8 properties: { 8 properties: {
9 hasScanResults: { 9 hasScanResults: {
10 type: Boolean, 10 type: Boolean,
11 value: false, 11 value: false,
12 }, 12 },
13 13
14 isInfected: { 14 isInfected: {
15 type: Boolean, 15 type: Boolean,
16 value: false, 16 value: false,
17 }, 17 },
18 18
19 isRunningScanner: { 19 isRunning: {
20 type: Boolean, 20 type: Boolean,
21 value: false, 21 value: false,
22 }, 22 },
23 23
24 detectionStatusText: { 24 detectionStatusText: {
25 type: String, 25 type: String,
26 value: "" 26 value: ""
27 }, 27 },
28 28
29 detectionTimeText: { 29 detectionTimeText: {
(...skipping 22 matching lines...) Expand all
52 */ 52 */
53 onScanTap_: function() { 53 onScanTap_: function() {
54 // TODO implement me. 54 // TODO implement me.
55 }, 55 },
56 56
57 /** 57 /**
58 * Sends a request for Chrome to open the Cleanup Tool's cleanup prompt. 58 * Sends a request for Chrome to open the Cleanup Tool's cleanup prompt.
59 * @private 59 * @private
60 */ 60 */
61 onCleanupTap_: function() { 61 onCleanupTap_: function() {
62 // TODO implement me. 62 this.isRunning = true;
63 this.browserProxy_.startCleanup().then(this.onCleanupResult_.bind(this));
63 }, 64 },
64 65
65 /** 66 /**
67 * @param {CleanupResult} cleanupResults
68 */
69 onCleanupResult_: function(cleanupResults) {
70 this.isRunning= false;
alito 2017/04/14 00:01:18 nit: space before '='
proberge 2017/04/18 19:24:28 Done.
71 if (!cleanupResults.wasCancelled)
72 this.isInfected = false;
alito 2017/04/14 00:01:18 Could you document why isInfected is set to false
proberge 2017/04/18 19:24:28 Done.
73
74 // TODO(proberge): Do something about cleanupResults.uwsRemoved.
75 },
76
77 /**
66 * @param {boolean} hasScanResults 78 * @param {boolean} hasScanResults
67 * @param {boolean} isInfected 79 * @param {boolean} isInfected
68 * @return {string} A class name for icon-specific styling. 80 * @return {string} A class name for icon-specific styling.
69 * @private 81 * @private
70 */ 82 */
71 getIconClassName_: function(hasScanResults, isInfected) { 83 getIconClassName_: function(hasScanResults, isInfected) {
72 return hasScanResults && isInfected ? "infected-icon" : "clean-icon"; 84 return hasScanResults && isInfected ? "infected-icon" : "clean-icon";
73 }, 85 },
74 86
75 /** 87 /**
76 * @param {boolean} hasScanResults 88 * @param {boolean} hasScanResults
77 * @param {boolean} isInfected 89 * @param {boolean} isInfected
78 * @return {string} An icon id. See icons.html. 90 * @return {string} An icon id. See icons.html.
79 * @private 91 * @private
80 */ 92 */
81 getStatusIcon_: function(hasScanResults, isInfected) { 93 getStatusIcon_: function(hasScanResults, isInfected) {
82 return hasScanResults && isInfected ? 94 return hasScanResults && isInfected ?
83 "cleanup:infected-user" : 95 "cleanup:infected-user" :
84 "cleanup:verified-user"; 96 "cleanup:verified-user";
85 }, 97 },
86 98
87 /** 99 /**
88 * @param {boolean} hasScanResults 100 * @param {boolean} hasScanResults
89 * @param {boolean} isRunningScanner 101 * @param {boolean} isRunning
90 * @return {boolean} True if the "Scan" button should be displayed, false 102 * @return {boolean} Whether the "Scan" button should be displayed.
91 * otherwise.
92 * @private 103 * @private
93 */ 104 */
94 shouldShowScan_: function(hasScanResults, isRunningScanner) { 105 shouldShowScan_: function(hasScanResults, isRunning) {
95 return !hasScanResults && !isRunningScanner; 106 return !hasScanResults && !isRunning;
96 }, 107 },
97 108
98 /** 109 /**
110 * @param {boolean} hasScanResults
111 * @param {boolean} isRunning
112 * @return {boolean} Whether the "Run Chrome Cleanup" button should be
113 * displayed.
114 * @private
115 */
116 shouldShowClean_: function(hasScanResults, isRunning) {
117 return hasScanResults && !isRunning;
118 },
119
120 /**
121 * @param {boolean} hasScanResults
122 * @param {boolean} isRunning
123 * @return {boolean} True if the "Scanning" label should be displayed.
alito 2017/04/14 00:01:18 nit: True if -> Whether
proberge 2017/04/18 19:24:28 Done.
124 * @private
125 */
126 shouldShowScanning_: function(hasScanResults, isRunning) {
127 return !hasScanResults && isRunning;
128 },
129
130 /**
131 * @param {boolean} hasScanResults
132 * @param {boolean} isRunning
133 * @return {boolean} True if the "Cleaning" label should be displayed.
alito 2017/04/14 00:01:18 nit: True if -> Whether
proberge 2017/04/18 19:24:28 Done.
134 * @private
135 */
136 shouldShowCleaning_: function(hasScanResults, isRunning) {
137 return hasScanResults && isRunning;
138 },
139
140 /**
99 * Requests the latest Chrome Cleanup Tool scan results from Chrome, then 141 * Requests the latest Chrome Cleanup Tool scan results from Chrome, then
100 * updates the local state with the new information. 142 * updates the local state with the new information.
101 * @private 143 * @private
102 */ 144 */
103 requestLastScanResult_: function() { 145 requestLastScanResult_: function() {
104 this.browserProxy_.requestLastScanResult().then( 146 this.browserProxy_.requestLastScanResult().then(
105 this.updateLastScanState_.bind(this)); 147 this.updateLastScanState_.bind(this));
106 }, 148 },
107 149
108 /** 150 /**
109 @param {LastScanResult} lastScanResults 151 @param {LastScanResult} lastScanResults
110 */ 152 */
111 updateLastScanState_: function(lastScanResults) { 153 updateLastScanState_: function(lastScanResults) {
112 this.hasScanResults = lastScanResults.hasScanResults; 154 this.hasScanResults = lastScanResults.hasScanResults;
113 this.isInfected = lastScanResults.hasScanResults; 155 this.isInfected = lastScanResults.hasScanResults;
114 this.detectionStatusText = lastScanResults.detectionStatusText; 156 this.detectionStatusText = lastScanResults.detectionStatusText;
115 this.detectionTimeText = lastScanResults.detectionTimeText; 157 this.detectionTimeText = lastScanResults.detectionTimeText;
116 } 158 }
117 }); 159 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698