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

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

Issue 2154033002: MD Downloads: fix focus issue on downloads page by combining pause/play (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge + re-vulcanize Created 4 years, 5 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 properties: { 9 properties: {
10 data: { 10 data: {
(...skipping 19 matching lines...) Expand all
30 type: Boolean, 30 type: Boolean,
31 value: true, 31 value: true,
32 }, 32 },
33 33
34 isDangerous_: { 34 isDangerous_: {
35 computed: 'computeIsDangerous_(data.state)', 35 computed: 'computeIsDangerous_(data.state)',
36 type: Boolean, 36 type: Boolean,
37 value: false, 37 value: false,
38 }, 38 },
39 39
40 isMalware_: {
41 computed: 'computeIsMalware_(isDangerous_, data.danger_type)',
42 type: Boolean,
43 value: false,
44 },
45
40 isInProgress_: { 46 isInProgress_: {
41 computed: 'computeIsInProgress_(data.state)', 47 computed: 'computeIsInProgress_(data.state)',
42 type: Boolean, 48 type: Boolean,
43 value: false, 49 value: false,
44 }, 50 },
45 51
52 pauseOrResumeText_: {
53 computed: 'computePauseOrResumeText_(isInProgress_, data.resume)',
54 type: String,
55 },
56
46 showCancel_: { 57 showCancel_: {
47 computed: 'computeShowCancel_(data.state)', 58 computed: 'computeShowCancel_(data.state)',
48 type: Boolean, 59 type: Boolean,
49 value: false, 60 value: false,
50 }, 61 },
51 62
52 showProgress_: { 63 showProgress_: {
53 computed: 'computeShowProgress_(showCancel_, data.percent)', 64 computed: 'computeShowProgress_(showCancel_, data.percent)',
54 type: Boolean, 65 type: Boolean,
55 value: false, 66 value: false,
56 }, 67 },
57
58 isMalware_: {
59 computed: 'computeIsMalware_(isDangerous_, data.danger_type)',
60 type: Boolean,
61 value: false,
62 },
63 }, 68 },
64 69
65 observers: [ 70 observers: [
66 // TODO(dbeam): this gets called way more when I observe data.by_ext_id 71 // TODO(dbeam): this gets called way more when I observe data.by_ext_id
67 // and data.by_ext_name directly. Why? 72 // and data.by_ext_name directly. Why?
68 'observeControlledBy_(controlledBy_)', 73 'observeControlledBy_(controlledBy_)',
69 'observeIsDangerous_(isDangerous_, data)', 74 'observeIsDangerous_(isDangerous_, data)',
70 ], 75 ],
71 76
72 ready: function() { 77 ready: function() {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 /** @private */ 185 /** @private */
181 computeIsMalware_: function() { 186 computeIsMalware_: function() {
182 return this.isDangerous_ && 187 return this.isDangerous_ &&
183 (this.data.danger_type == downloads.DangerType.DANGEROUS_CONTENT || 188 (this.data.danger_type == downloads.DangerType.DANGEROUS_CONTENT ||
184 this.data.danger_type == downloads.DangerType.DANGEROUS_HOST || 189 this.data.danger_type == downloads.DangerType.DANGEROUS_HOST ||
185 this.data.danger_type == downloads.DangerType.DANGEROUS_URL || 190 this.data.danger_type == downloads.DangerType.DANGEROUS_URL ||
186 this.data.danger_type == downloads.DangerType.POTENTIALLY_UNWANTED); 191 this.data.danger_type == downloads.DangerType.POTENTIALLY_UNWANTED);
187 }, 192 },
188 193
189 /** @private */ 194 /** @private */
195 computePauseOrResumeText_: function() {
196 if (this.isInProgress_)
197 return loadTimeData.getString('controlPause');
198 if (this.data.resume)
199 return loadTimeData.getString('controlResume');
200 return '';
201 },
202
203 /** @private */
190 computeRemoveStyle_: function() { 204 computeRemoveStyle_: function() {
191 var canDelete = loadTimeData.getBoolean('allowDeletingHistory'); 205 var canDelete = loadTimeData.getBoolean('allowDeletingHistory');
192 var hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete; 206 var hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete;
193 return hideRemove ? 'visibility: hidden' : ''; 207 return hideRemove ? 'visibility: hidden' : '';
194 }, 208 },
195 209
196 /** @private */ 210 /** @private */
197 computeShowCancel_: function() { 211 computeShowCancel_: function() {
198 return this.data.state == downloads.States.IN_PROGRESS || 212 return this.data.state == downloads.States.IN_PROGRESS ||
199 this.data.state == downloads.States.PAUSED; 213 this.data.state == downloads.States.PAUSED;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 /** 282 /**
269 * @param {Event} e 283 * @param {Event} e
270 * @private 284 * @private
271 */ 285 */
272 onFileLinkTap_: function(e) { 286 onFileLinkTap_: function(e) {
273 e.preventDefault(); 287 e.preventDefault();
274 downloads.ActionService.getInstance().openFile(this.data.id); 288 downloads.ActionService.getInstance().openFile(this.data.id);
275 }, 289 },
276 290
277 /** @private */ 291 /** @private */
278 onPauseTap_: function() { 292 onPauseOrResumeTap_: function() {
279 downloads.ActionService.getInstance().pause(this.data.id); 293 if (this.isInProgress_)
294 downloads.ActionService.getInstance().pause(this.data.id);
295 else
296 downloads.ActionService.getInstance().resume(this.data.id);
280 }, 297 },
281 298
282 /** @private */ 299 /** @private */
283 onRemoveTap_: function() { 300 onRemoveTap_: function() {
284 downloads.ActionService.getInstance().remove(this.data.id); 301 downloads.ActionService.getInstance().remove(this.data.id);
285 }, 302 },
286 303
287 /** @private */ 304 /** @private */
288 onResumeTap_: function() {
289 downloads.ActionService.getInstance().resume(this.data.id);
290 },
291
292 /** @private */
293 onRetryTap_: function() { 305 onRetryTap_: function() {
294 downloads.ActionService.getInstance().download(this.data.url); 306 downloads.ActionService.getInstance().download(this.data.url);
295 }, 307 },
296 308
297 /** @private */ 309 /** @private */
298 onSaveDangerousTap_: function() { 310 onSaveDangerousTap_: function() {
299 downloads.ActionService.getInstance().saveDangerous(this.data.id); 311 downloads.ActionService.getInstance().saveDangerous(this.data.id);
300 }, 312 },
301 313
302 /** @private */ 314 /** @private */
303 onShowTap_: function() { 315 onShowTap_: function() {
304 downloads.ActionService.getInstance().show(this.data.id); 316 downloads.ActionService.getInstance().show(this.data.id);
305 }, 317 },
306 }); 318 });
307 319
308 return {Item: Item}; 320 return {Item: Item};
309 }); 321 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698