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

Side by Side Diff: chrome/browser/resources/md_downloads/item.js

Issue 1268023002: MD downloads: implement real warning icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dl-search-x
Patch Set: groby@ review Created 5 years, 4 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
« no previous file with comments | « chrome/browser/resources/md_downloads/item.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('downloads', function() { 5 cr.define('downloads', function() {
6 var Item = Polymer({ 6 var Item = Polymer({
7 is: 'downloads-item', 7 is: 'downloads-item',
8 8
9 /** 9 /**
10 * @param {!downloads.ThrottledIconLoader} iconLoader 10 * @param {!downloads.ThrottledIconLoader} iconLoader
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 /** @const */ var showProgress = 74 /** @const */ var showProgress =
75 isFinite(data.percent) && !this.isDangerous_; 75 isFinite(data.percent) && !this.isDangerous_;
76 this.$.progress.hidden = !showProgress; 76 this.$.progress.hidden = !showProgress;
77 77
78 if (showProgress) { 78 if (showProgress) {
79 this.$.progress.indeterminate = data.percent < 0; 79 this.$.progress.indeterminate = data.percent < 0;
80 this.$.progress.value = data.percent; 80 this.$.progress.value = data.percent;
81 } 81 }
82 82
83 var iconUrl = 'chrome://';
84
85 if (this.isDangerous_) { 83 if (this.isDangerous_) {
86 var dangerType = data.danger_type;
87
88 this.isMalware_ = 84 this.isMalware_ =
89 dangerType == downloads.DangerType.DANGEROUS_CONTENT || 85 data.danger_type == downloads.DangerType.DANGEROUS_CONTENT ||
90 dangerType == downloads.DangerType.DANGEROUS_HOST || 86 data.danger_type == downloads.DangerType.DANGEROUS_HOST ||
91 dangerType == downloads.DangerType.DANGEROUS_URL || 87 data.danger_type == downloads.DangerType.DANGEROUS_URL ||
92 dangerType == downloads.DangerType.POTENTIALLY_UNWANTED; 88 data.danger_type == downloads.DangerType.POTENTIALLY_UNWANTED;
93
94 // TODO(dbeam): this icon sucks: it's a PNG we have to scale and looks
95 // nothing like the mocks. Find a prettier, more vectorized version.
96 var dangerousFile = dangerType == downloads.DangerType.DANGEROUS_FILE;
97 var idr = dangerousFile ? 'IDR_WARNING' : 'IDR_SAFEBROWSING_WARNING';
98 iconUrl += 'theme/' + idr;
99 } else { 89 } else {
100 /** @const */ var completelyOnDisk = 90 /** @const */ var completelyOnDisk =
101 data.state == downloads.States.COMPLETE && 91 data.state == downloads.States.COMPLETE &&
102 !data.file_externally_removed; 92 !data.file_externally_removed;
103 93
104 this.$['file-link'].href = data.url; 94 this.$['file-link'].href = data.url;
105 this.ensureTextIs_(this.$['file-link'], data.file_name); 95 this.ensureTextIs_(this.$['file-link'], data.file_name);
106 96
107 this.$['file-link'].hidden = !completelyOnDisk; 97 this.$['file-link'].hidden = !completelyOnDisk;
108 this.$.name.hidden = completelyOnDisk; 98 this.$.name.hidden = completelyOnDisk;
(...skipping 17 matching lines...) Expand all
126 /** @const */ var controlledByExtension = data.by_ext_id && 116 /** @const */ var controlledByExtension = data.by_ext_id &&
127 data.by_ext_name; 117 data.by_ext_name;
128 this.$['controlled-by'].hidden = !controlledByExtension; 118 this.$['controlled-by'].hidden = !controlledByExtension;
129 if (controlledByExtension) { 119 if (controlledByExtension) {
130 var link = this.$['controlled-by'].querySelector('a'); 120 var link = this.$['controlled-by'].querySelector('a');
131 link.href = 'chrome://extensions#' + data.by_ext_id; 121 link.href = 'chrome://extensions#' + data.by_ext_id;
132 link.setAttribute('column-type', 'controlled-by'); 122 link.setAttribute('column-type', 'controlled-by');
133 link.textContent = data.by_ext_name; 123 link.textContent = data.by_ext_name;
134 } 124 }
135 125
136 iconUrl += 'fileicon/' + encodeURIComponent(data.file_path); 126 var icon = 'chrome://fileicon/' + encodeURIComponent(data.file_path);
127 this.iconLoader_.loadScaledIcon(this.$['file-icon'], icon);
137 } 128 }
138
139 this.iconLoader_.loadScaledIcon(this.$.icon, iconUrl);
140 }, 129 },
141 130
142 /** 131 /**
143 * Overwrite |el|'s textContent if it differs from |text|. 132 * Overwrite |el|'s textContent if it differs from |text|.
144 * @param {!Element} el 133 * @param {!Element} el
145 * @param {string} text 134 * @param {string} text
146 * @private 135 * @private
147 */ 136 */
148 ensureTextIs_: function(el, text) { 137 ensureTextIs_: function(el, text) {
149 if (el.textContent != text) 138 if (el.textContent != text)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 }, 256 },
268 257
269 /** @private */ 258 /** @private */
270 onShowClick_: function() { 259 onShowClick_: function() {
271 this.actionService_.show(this.id_); 260 this.actionService_.show(this.id_);
272 }, 261 },
273 }); 262 });
274 263
275 return {Item: Item}; 264 return {Item: Item};
276 }); 265 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_downloads/item.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698