Chromium Code Reviews| Index: chrome/browser/resources/cleanup_tool/manager.js |
| diff --git a/chrome/browser/resources/cleanup_tool/manager.js b/chrome/browser/resources/cleanup_tool/manager.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..661a014d322d968269acb997216216e1c9abc721 |
| --- /dev/null |
| +++ b/chrome/browser/resources/cleanup_tool/manager.js |
| @@ -0,0 +1,129 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('cleanup', function() { |
| + var Manager = Polymer({ |
| + is: 'cleanup-manager', |
| + |
| + properties: { |
| + hasScanResults: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| + |
| + isInfected: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| + |
| + isRunningScanner: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| + |
| + detectionStatusText: { |
| + type: String, |
| + value: "" |
| + }, |
| + |
| + detectionTimeText: { |
| + type: String, |
| + value: "" |
| + }, |
| + |
| + /** @private {!clean.CleanupBrowserProxy} */ |
| + browserProxy_: Object, |
| + }, |
| + |
| + behaviors: [I18nBehavior], |
| + |
| + /** @override */ |
| + created: function() { |
| + this.browserProxy_ = cleanup.CleanupBrowserProxyImpl.getInstance(); |
| + }, |
| + |
| + /** |
| + * Sends a request for Chrome to start the Cleanup Tool's scanning process. |
| + * @private |
| + */ |
| + onScanTap_: function() { |
| + // TODO implement me. |
| + }, |
| + |
| + /** |
| + * Sends a request for Chrome to open the Cleanup Tool's cleanup prompt. |
| + * @private |
| + */ |
| + onCleanupTap_: function() { |
| + // TODO implement me. |
| + }, |
| + |
| + /** |
| + * @param {boolean} hasScanResults |
| + * @param {boolean} isInfected |
| + * @return {string} A class name for icon-specific styling. |
| + * @private |
| + */ |
| + getIconClassName_: function(hasScanResults, isInfected) { |
| + return hasScanResults && isInfected ? "infected-icon" : "clean-icon"; |
| + }, |
| + |
| + /** |
| + * @param {boolean} hasScanResults |
| + * @param {boolean} isInfected |
| + * @return {string} An icon id. See icons.html. |
| + * @private |
| + */ |
| + getStatusIcon_: function(hasScanResults, isInfected) { |
| + return hasScanResults && isInfected ? |
| + "cleanup:infected-user" : |
| + "cleanup:verified-user"; |
| + }, |
| + |
| + /** |
| + * @param {boolean} hasScanResults |
| + * @param {boolean} isRunningScanner |
| + * @return {boolean} True if the "Scan" button should be displayed, false |
| + * otherwise. |
| + * @private |
| + */ |
| + shouldShowScan_: function(hasScanResults, isRunningScanner) { |
| + return !hasScanResults && !isRunningScanner; |
| + }, |
| + |
| + /** |
| + * Requests the latest Chrome Cleanup Tool scan results from Chrome, then |
| + * updates the local state with the new information. |
| + */ |
| + 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.
|
| + this.browserProxy_.requestLastScanResult().then( |
| + this.updateLastScanState_.bind(this)); |
| + }, |
| + |
| + /** |
| + @param {LastScanResult} lastScanResults |
| + */ |
| + updateLastScanState_: function(lastScanResults) { |
| + this.hasScanResults = lastScanResults.hasScanResults; |
| + this.isInfected = lastScanResults.hasScanResults; |
| + this.detectionStatusText = lastScanResults.detectionStatusText; |
| + this.detectionTimeText = lastScanResults.detectionTimeText; |
| + } |
| + }); |
| + |
| + /** @return {!cleanup.Manager} */ |
| + Manager.get = function() { |
| + return /** @type {!cleanup.Manager} */ ( |
| + queryRequiredElement('cleanup-manager')); |
| + } |
| + |
| + return { |
| + Manager: Manager |
| + }; |
| +}); |
| + |
| +// Fetch data while loading to have it displayed as soon as possible. |
| +document.addEventListener('DOMContentLoaded', function() { |
| + 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
|
| +}); |