OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 onScanComplete_: function(lastScanResults) { | 61 onScanComplete_: function(lastScanResults) { |
62 this.isRunningScanner = false; | 62 this.isRunningScanner = false; |
63 this.updateLastScanState_(lastScanResults); | 63 this.updateLastScanState_(lastScanResults); |
64 }, | 64 }, |
65 | 65 |
66 /** | 66 /** |
67 * Sends a request for Chrome to open the Cleanup Tool's cleanup prompt. | 67 * Sends a request for Chrome to open the Cleanup Tool's cleanup prompt. |
68 * @private | 68 * @private |
69 */ | 69 */ |
70 onCleanupTap_: function() { | 70 onCleanupTap_: function() { |
71 // TODO implement me. | 71 this.isRunning = true; |
| 72 this.browserProxy_.startCleanup().then(this.onCleanupResult_.bind(this)); |
72 }, | 73 }, |
73 | 74 |
74 /** | 75 /** |
| 76 * @param {CleanupResult} cleanupResults |
| 77 */ |
| 78 onCleanupResult_: function(cleanupResults) { |
| 79 this.isRunning = false; |
| 80 |
| 81 if (!cleanupResults.wasCancelled) |
| 82 // Assume cleanup was completed and clear infected status. |
| 83 this.isInfected = false; |
| 84 |
| 85 // TODO(proberge): Do something about cleanupResults.uwsRemoved. |
| 86 }, |
| 87 |
| 88 /** |
75 * @param {boolean} hasScanResults | 89 * @param {boolean} hasScanResults |
76 * @param {boolean} isInfected | 90 * @param {boolean} isInfected |
77 * @return {string} A class name for icon-specific styling. | 91 * @return {string} A class name for icon-specific styling. |
78 * @private | 92 * @private |
79 */ | 93 */ |
80 getIconClassName_: function(hasScanResults, isInfected) { | 94 getIconClassName_: function(hasScanResults, isInfected) { |
81 return hasScanResults && isInfected ? "infected-icon" : "clean-icon"; | 95 return hasScanResults && isInfected ? "infected-icon" : "clean-icon"; |
82 }, | 96 }, |
83 | 97 |
84 /** | 98 /** |
85 * @param {boolean} hasScanResults | 99 * @param {boolean} hasScanResults |
86 * @param {boolean} isInfected | 100 * @param {boolean} isInfected |
87 * @return {string} An icon id. See icons.html. | 101 * @return {string} An icon id. See icons.html. |
88 * @private | 102 * @private |
89 */ | 103 */ |
90 getStatusIcon_: function(hasScanResults, isInfected) { | 104 getStatusIcon_: function(hasScanResults, isInfected) { |
91 return hasScanResults && isInfected ? | 105 return hasScanResults && isInfected ? |
92 "cleanup:infected-user" : | 106 "cleanup:infected-user" : |
93 "cleanup:verified-user"; | 107 "cleanup:verified-user"; |
94 }, | 108 }, |
95 | 109 |
96 /** | 110 /** |
97 * @param {boolean} hasScanResults | 111 * @param {boolean} hasScanResults |
98 * @param {boolean} isRunningScanner | 112 * @param {boolean} isRunning |
99 * @return {boolean} True if the "Scan" button should be displayed, false | 113 * @return {boolean} Whether the "Scan" button should be displayed. |
100 * otherwise. | |
101 * @private | 114 * @private |
102 */ | 115 */ |
103 shouldShowScan_: function(hasScanResults, isRunningScanner) { | 116 shouldShowScan_: function(hasScanResults, isRunning) { |
104 return !hasScanResults && !isRunningScanner; | 117 return !hasScanResults && !isRunning; |
105 }, | 118 }, |
106 | 119 |
107 /** | 120 /** |
| 121 * @param {boolean} hasScanResults |
| 122 * @param {boolean} isRunning |
| 123 * @return {boolean} Whether the "Run Chrome Cleanup" button should be |
| 124 * displayed. |
| 125 * @private |
| 126 */ |
| 127 shouldShowClean_: function(hasScanResults, isRunning) { |
| 128 return hasScanResults && !isRunning; |
| 129 }, |
| 130 |
| 131 /** |
| 132 * @param {boolean} hasScanResults |
| 133 * @param {boolean} isRunning |
| 134 * @return {boolean} True Whether the "Scanning" label should be displayed. |
| 135 * @private |
| 136 */ |
| 137 shouldShowScanning_: function(hasScanResults, isRunning) { |
| 138 return !hasScanResults && isRunning; |
| 139 }, |
| 140 |
| 141 /** |
| 142 * @param {boolean} hasScanResults |
| 143 * @param {boolean} isRunning |
| 144 * @return {boolean} True Whether the "Cleaning" label should be displayed. |
| 145 * @private |
| 146 */ |
| 147 shouldShowCleaning_: function(hasScanResults, isRunning) { |
| 148 return hasScanResults && isRunning; |
| 149 }, |
| 150 |
| 151 /** |
108 * Requests the latest Chrome Cleanup Tool scan results from Chrome, then | 152 * Requests the latest Chrome Cleanup Tool scan results from Chrome, then |
109 * updates the local state with the new information. | 153 * updates the local state with the new information. |
110 * @private | 154 * @private |
111 */ | 155 */ |
112 requestLastScanResult_: function() { | 156 requestLastScanResult_: function() { |
113 this.browserProxy_.requestLastScanResult().then( | 157 this.browserProxy_.requestLastScanResult().then( |
114 this.updateLastScanState_.bind(this)); | 158 this.updateLastScanState_.bind(this)); |
115 }, | 159 }, |
116 | 160 |
117 /** | 161 /** |
118 @param {LastScanResult} lastScanResults | 162 @param {LastScanResult} lastScanResults |
119 */ | 163 */ |
120 updateLastScanState_: function(lastScanResults) { | 164 updateLastScanState_: function(lastScanResults) { |
121 this.hasScanResults = lastScanResults.hasScanResults; | 165 this.hasScanResults = lastScanResults.hasScanResults; |
122 this.isInfected = lastScanResults.hasScanResults; | 166 this.isInfected = lastScanResults.hasScanResults; |
123 this.detectionStatusText = lastScanResults.detectionStatusText; | 167 this.detectionStatusText = lastScanResults.detectionStatusText; |
124 this.detectionTimeText = lastScanResults.detectionTimeText; | 168 this.detectionTimeText = lastScanResults.detectionTimeText; |
125 } | 169 } |
126 }); | 170 }); |
OLD | NEW |