Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('cleanup', function() { | |
| 6 var Manager = Polymer({ | |
| 7 is: 'cleanup-manager', | |
| 8 | |
| 9 properties: { | |
| 10 hasScanResults: { | |
| 11 type: Boolean, | |
| 12 value: false, | |
| 13 }, | |
| 14 | |
| 15 isInfected: { | |
| 16 type: Boolean, | |
| 17 value: false, | |
| 18 }, | |
| 19 | |
| 20 isRunningScanner: { | |
| 21 type: Boolean, | |
| 22 value: false, | |
| 23 }, | |
| 24 | |
| 25 detectionStatusText: { | |
| 26 type: String, | |
| 27 value: "" | |
| 28 }, | |
| 29 | |
| 30 detectionTimeText: { | |
| 31 type: String, | |
| 32 value: "" | |
| 33 }, | |
| 34 | |
| 35 /** @private {!clean.CleanupBrowserProxy} */ | |
| 36 browserProxy_: Object, | |
| 37 }, | |
| 38 | |
| 39 /** @override */ | |
| 40 attached: function() { | |
| 41 // Fetch data to have it displayed as soon as possible. | |
| 42 this.requestLastScanResult_(); | |
| 43 }, | |
| 44 | |
| 45 /** @override */ | |
| 46 created: function() { | |
| 47 this.browserProxy_ = cleanup.CleanupBrowserProxyImpl.getInstance(); | |
| 48 }, | |
| 49 | |
| 50 /** | |
| 51 * Sends a request for Chrome to start the Cleanup Tool's scanning process. | |
| 52 * @private | |
| 53 */ | |
| 54 onScanTap_: function() { | |
| 55 // TODO implement me. | |
| 56 }, | |
| 57 | |
| 58 /** | |
| 59 * Sends a request for Chrome to open the Cleanup Tool's cleanup prompt. | |
| 60 * @private | |
| 61 */ | |
| 62 onCleanupTap_: function() { | |
| 63 // TODO implement me. | |
| 64 }, | |
| 65 | |
| 66 /** | |
| 67 * @param {boolean} hasScanResults | |
| 68 * @param {boolean} isInfected | |
| 69 * @return {string} A class name for icon-specific styling. | |
| 70 * @private | |
| 71 */ | |
| 72 getIconClassName_: function(hasScanResults, isInfected) { | |
| 73 return hasScanResults && isInfected ? "infected-icon" : "clean-icon"; | |
| 74 }, | |
| 75 | |
| 76 /** | |
| 77 * @param {boolean} hasScanResults | |
| 78 * @param {boolean} isInfected | |
| 79 * @return {string} An icon id. See icons.html. | |
| 80 * @private | |
| 81 */ | |
| 82 getStatusIcon_: function(hasScanResults, isInfected) { | |
| 83 return hasScanResults && isInfected ? | |
| 84 "cleanup:infected-user" : | |
| 85 "cleanup:verified-user"; | |
| 86 }, | |
| 87 | |
| 88 /** | |
| 89 * @param {boolean} hasScanResults | |
| 90 * @param {boolean} isRunningScanner | |
| 91 * @return {boolean} True if the "Scan" button should be displayed, false | |
| 92 * otherwise. | |
| 93 * @private | |
| 94 */ | |
| 95 shouldShowScan_: function(hasScanResults, isRunningScanner) { | |
| 96 return !hasScanResults && !isRunningScanner; | |
| 97 }, | |
| 98 | |
| 99 /** | |
| 100 * Requests the latest Chrome Cleanup Tool scan results from Chrome, then | |
| 101 * updates the local state with the new information. | |
| 102 * @private | |
| 103 */ | |
| 104 requestLastScanResult_: function() { | |
| 105 this.browserProxy_.requestLastScanResult().then( | |
| 106 this.updateLastScanState_.bind(this)); | |
| 107 }, | |
| 108 | |
| 109 /** | |
| 110 @param {LastScanResult} lastScanResults | |
| 111 */ | |
| 112 updateLastScanState_: function(lastScanResults) { | |
| 113 this.hasScanResults = lastScanResults.hasScanResults; | |
| 114 this.isInfected = lastScanResults.hasScanResults; | |
| 115 this.detectionStatusText = lastScanResults.detectionStatusText; | |
| 116 this.detectionTimeText = lastScanResults.detectionTimeText; | |
| 117 } | |
| 118 }); | |
| 119 | |
| 120 /** @return {!cleanup.Manager} */ | |
| 121 Manager.get = function() { | |
| 122 return /** @type {!cleanup.Manager} */ ( | |
| 123 queryRequiredElement('cleanup-manager')); | |
| 124 } | |
| 125 | |
| 126 return { | |
| 127 Manager: Manager | |
| 128 }; | |
|
tommycli
2017/04/07 19:23:07
I suspect that the cr.define, the Manager.get, and
tommycli
2017/04/07 20:23:38
The cr.define is to namespace Manager into the 'cl
Dan Beam
2017/04/07 21:48:59
that's not totally true, but close enough (if the
proberge
2017/04/08 02:03:11
Gotcha, thanks!
| |
| 129 }); | |
| OLD | NEW |