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

Unified Diff: chrome/browser/resources/cleanup_tool/manager.js

Issue 2788743002: Cleanup Tool WebUI: Add functional HTML and skeleton JS for main content (Closed)
Patch Set: Remove i18n-content directives, address latest review comments 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 side-by-side diff with in-line comments
Download patch
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..c85872137a3b844b496876f5940c737357853025
--- /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,
+ },
+
+ /** @override */
+ attached: function() {
+ // Fetch data to have it displayed as soon as possible.
+ this.requestLastScanResult_();
+ },
+
+ /** @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.
+ * @private
+ */
+ requestLastScanResult_: function() {
+ 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
+ };
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!
+});
« no previous file with comments | « chrome/browser/resources/cleanup_tool/manager.html ('k') | chrome/browser/ui/webui/cleanup_tool/cleanup_tool_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698