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 behaviors: [I18nBehavior], | |
| 40 | |
| 41 /** @override */ | |
| 42 created: function() { | |
| 43 this.browserProxy_ = cleanup.CleanupBrowserProxyImpl.getInstance(); | |
| 44 }, | |
| 45 | |
| 46 /** | |
| 47 * Sends a request for Chrome to start the Cleanup Tool's scanning process. | |
| 48 * @private | |
| 49 */ | |
| 50 onScanTap_: function() { | |
| 51 // TODO implement me. | |
| 52 }, | |
| 53 | |
| 54 /** | |
| 55 * Sends a request for Chrome to open the Cleanup Tool's cleanup prompt. | |
| 56 * @private | |
| 57 */ | |
| 58 onCleanupTap_: function() { | |
| 59 // TODO implement me. | |
| 60 }, | |
| 61 | |
| 62 /** | |
| 63 * @param {boolean} hasScanResults | |
| 64 * @param {boolean} isInfected | |
| 65 * @return {string} A class name for icon-specific styling. | |
| 66 * @private | |
| 67 */ | |
| 68 getIconClassName_: function(hasScanResults, isInfected) { | |
| 69 return hasScanResults && isInfected ? "infected-icon" : "clean-icon"; | |
| 70 }, | |
| 71 | |
| 72 /** | |
| 73 * @param {boolean} hasScanResults | |
| 74 * @param {boolean} isInfected | |
| 75 * @return {string} An icon id. See icons.html. | |
| 76 * @private | |
| 77 */ | |
| 78 getStatusIcon_: function(hasScanResults, isInfected) { | |
| 79 return hasScanResults && isInfected ? | |
| 80 "cleanup:infected-user" : | |
| 81 "cleanup:verified-user"; | |
| 82 }, | |
| 83 | |
| 84 /** | |
| 85 * @param {boolean} hasScanResults | |
| 86 * @param {boolean} isRunningScanner | |
| 87 * @return {boolean} True if the "Scan" button should be displayed, false | |
| 88 * otherwise. | |
| 89 * @private | |
| 90 */ | |
| 91 shouldShowScan_: function(hasScanResults, isRunningScanner) { | |
| 92 return !hasScanResults && !isRunningScanner; | |
| 93 }, | |
| 94 | |
| 95 /** | |
| 96 * Requests the latest Chrome Cleanup Tool scan results from Chrome, then | |
| 97 * updates the local state with the new information. | |
| 98 */ | |
| 99 requestLastScanResult: function() { | |
|
tommycli
2017/03/30 20:18:00
I think this can be private if the suggestion on l
proberge
2017/03/30 21:04:33
Acknowledged.
proberge
2017/04/05 21:34:06
Done.
| |
| 100 this.browserProxy_.requestLastScanResult().then( | |
| 101 this.updateLastScanState_.bind(this)); | |
| 102 }, | |
| 103 | |
| 104 /** | |
| 105 @param {LastScanResult} lastScanResults | |
| 106 */ | |
| 107 updateLastScanState_: function(lastScanResults) { | |
| 108 this.hasScanResults = lastScanResults.hasScanResults; | |
| 109 this.isInfected = lastScanResults.hasScanResults; | |
| 110 this.detectionStatusText = lastScanResults.detectionStatusText; | |
| 111 this.detectionTimeText = lastScanResults.detectionTimeText; | |
| 112 } | |
| 113 }); | |
| 114 | |
| 115 /** @return {!cleanup.Manager} */ | |
| 116 Manager.get = function() { | |
| 117 return /** @type {!cleanup.Manager} */ ( | |
| 118 queryRequiredElement('cleanup-manager')); | |
| 119 } | |
| 120 | |
| 121 return { | |
| 122 Manager: Manager | |
| 123 }; | |
| 124 }); | |
| 125 | |
| 126 // Fetch data while loading to have it displayed as soon as possible. | |
| 127 document.addEventListener('DOMContentLoaded', function() { | |
| 128 cleanup.Manager.get().requestLastScanResult(); | |
|
tommycli
2017/03/30 20:18:00
I think you don't need to define Manager inside a
proberge
2017/03/30 21:04:33
The document.addEventListener is outside of the cr
tommycli
2017/04/05 20:47:26
Hey... I don't think you need document.addEventLis
proberge
2017/04/05 21:34:06
Oops yeah you're completely right. I don't know en
| |
| 129 }); | |
| OLD | NEW |