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

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: 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
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 /** @const */ var showProgress = 79 /** @const */ var showProgress =
80 isFinite(data.percent) && !this.isDangerous_; 80 isFinite(data.percent) && !this.isDangerous_;
81 this.$.progress.hidden = !showProgress; 81 this.$.progress.hidden = !showProgress;
82 82
83 if (showProgress) { 83 if (showProgress) {
84 this.$.progress.indeterminate = data.percent < 0; 84 this.$.progress.indeterminate = data.percent < 0;
85 this.$.progress.value = data.percent; 85 this.$.progress.value = data.percent;
86 } 86 }
87 87
88 var iconUrl = 'chrome://';
89
90 if (this.isDangerous_) { 88 if (this.isDangerous_) {
91 var dangerType = data.danger_type;
92
93 this.isMalware_ = 89 this.isMalware_ =
94 dangerType == downloads.DangerType.DANGEROUS_CONTENT || 90 data.danger_type == downloads.DangerType.DANGEROUS_CONTENT ||
95 dangerType == downloads.DangerType.DANGEROUS_HOST || 91 data.danger_type == downloads.DangerType.DANGEROUS_HOST ||
96 dangerType == downloads.DangerType.DANGEROUS_URL || 92 data.danger_type == downloads.DangerType.DANGEROUS_URL ||
97 dangerType == downloads.DangerType.POTENTIALLY_UNWANTED; 93 data.danger_type == downloads.DangerType.POTENTIALLY_UNWANTED;
98
99 // TODO(dbeam): this icon sucks: it's a PNG we have to scale and looks
100 // nothing like the mocks. Find a prettier, more vectorized version.
101 var dangerousFile = dangerType == downloads.DangerType.DANGEROUS_FILE;
groby-ooo-7-16 2015/08/04 00:56:06 I'm slightly confused. Who's setting up the URL fo
Dan Beam 2015/08/04 01:11:20 the new UI shows the same warning icon regardless
102 var idr = dangerousFile ? 'IDR_WARNING' : 'IDR_SAFEBROWSING_WARNING';
103 iconUrl += 'theme/' + idr;
104 } else { 94 } else {
105 /** @const */ var completelyOnDisk = 95 /** @const */ var completelyOnDisk =
106 data.state == downloads.States.COMPLETE && 96 data.state == downloads.States.COMPLETE &&
107 !data.file_externally_removed; 97 !data.file_externally_removed;
108 98
109 this.$['file-link'].href = data.url; 99 this.$['file-link'].href = data.url;
110 this.ensureTextIs_(this.$['file-link'], data.file_name); 100 this.ensureTextIs_(this.$['file-link'], data.file_name);
111 101
112 this.$['file-link'].hidden = !completelyOnDisk; 102 this.$['file-link'].hidden = !completelyOnDisk;
113 this.$.name.hidden = completelyOnDisk; 103 this.$.name.hidden = completelyOnDisk;
(...skipping 17 matching lines...) Expand all
131 /** @const */ var controlledByExtension = data.by_ext_id && 121 /** @const */ var controlledByExtension = data.by_ext_id &&
132 data.by_ext_name; 122 data.by_ext_name;
133 this.$['controlled-by'].hidden = !controlledByExtension; 123 this.$['controlled-by'].hidden = !controlledByExtension;
134 if (controlledByExtension) { 124 if (controlledByExtension) {
135 var link = this.$['controlled-by'].querySelector('a'); 125 var link = this.$['controlled-by'].querySelector('a');
136 link.href = 'chrome://extensions#' + data.by_ext_id; 126 link.href = 'chrome://extensions#' + data.by_ext_id;
137 link.setAttribute('column-type', 'controlled-by'); 127 link.setAttribute('column-type', 'controlled-by');
138 link.textContent = data.by_ext_name; 128 link.textContent = data.by_ext_name;
139 } 129 }
140 130
141 iconUrl += 'fileicon/' + encodeURIComponent(data.file_path); 131 var icon = 'chrome://fileicon/' + encodeURIComponent(data.file_path);
132 this.iconLoader_.loadScaledIcon(this.$.icon, icon);
142 } 133 }
143
144 this.iconLoader_.loadScaledIcon(this.$.icon, iconUrl);
145 }, 134 },
146 135
147 /** 136 /**
148 * Overwrite |el|'s textContent if it differs from |text|. 137 * Overwrite |el|'s textContent if it differs from |text|.
149 * @param {!Element} el 138 * @param {!Element} el
150 * @param {string} text 139 * @param {string} text
151 * @private 140 * @private
152 */ 141 */
153 ensureTextIs_: function(el, text) { 142 ensureTextIs_: function(el, text) {
154 if (el.textContent != text) 143 if (el.textContent != text)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 }, 261 },
273 262
274 /** @private */ 263 /** @private */
275 onShowClick_: function() { 264 onShowClick_: function() {
276 this.actionService_.show(this.id_); 265 this.actionService_.show(this.id_);
277 }, 266 },
278 }); 267 });
279 268
280 return {Item: Item}; 269 return {Item: Item};
281 }); 270 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698