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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 });
OLDNEW
« 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