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

Side by Side Diff: chrome/browser/resources/md_downloads/crisper.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
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/item.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 /** 5 /**
6 * @fileoverview Assertion support. 6 * @fileoverview Assertion support.
7 */ 7 */
8 8
9 /** 9 /**
10 * Verify |condition| is truthy and return |condition| if so. 10 * Verify |condition| is truthy and return |condition| if so.
(...skipping 6304 matching lines...) Expand 10 before | Expand all | Expand 10 after
6315 type: Boolean, 6315 type: Boolean,
6316 value: true, 6316 value: true,
6317 }, 6317 },
6318 6318
6319 isDangerous_: { 6319 isDangerous_: {
6320 computed: 'computeIsDangerous_(data.state)', 6320 computed: 'computeIsDangerous_(data.state)',
6321 type: Boolean, 6321 type: Boolean,
6322 value: false, 6322 value: false,
6323 }, 6323 },
6324 6324
6325 isMalware_: {
6326 computed: 'computeIsMalware_(isDangerous_, data.danger_type)',
6327 type: Boolean,
6328 value: false,
6329 },
6330
6325 isInProgress_: { 6331 isInProgress_: {
6326 computed: 'computeIsInProgress_(data.state)', 6332 computed: 'computeIsInProgress_(data.state)',
6327 type: Boolean, 6333 type: Boolean,
6328 value: false, 6334 value: false,
6329 }, 6335 },
6330 6336
6337 pauseOrResumeText_: {
6338 computed: 'computePauseOrResumeText_(isInProgress_, data.resume)',
6339 type: String,
6340 },
6341
6331 showCancel_: { 6342 showCancel_: {
6332 computed: 'computeShowCancel_(data.state)', 6343 computed: 'computeShowCancel_(data.state)',
6333 type: Boolean, 6344 type: Boolean,
6334 value: false, 6345 value: false,
6335 }, 6346 },
6336 6347
6337 showProgress_: { 6348 showProgress_: {
6338 computed: 'computeShowProgress_(showCancel_, data.percent)', 6349 computed: 'computeShowProgress_(showCancel_, data.percent)',
6339 type: Boolean, 6350 type: Boolean,
6340 value: false, 6351 value: false,
6341 }, 6352 },
6342
6343 isMalware_: {
6344 computed: 'computeIsMalware_(isDangerous_, data.danger_type)',
6345 type: Boolean,
6346 value: false,
6347 },
6348 }, 6353 },
6349 6354
6350 observers: [ 6355 observers: [
6351 // TODO(dbeam): this gets called way more when I observe data.by_ext_id 6356 // TODO(dbeam): this gets called way more when I observe data.by_ext_id
6352 // and data.by_ext_name directly. Why? 6357 // and data.by_ext_name directly. Why?
6353 'observeControlledBy_(controlledBy_)', 6358 'observeControlledBy_(controlledBy_)',
6354 'observeIsDangerous_(isDangerous_, data)', 6359 'observeIsDangerous_(isDangerous_, data)',
6355 ], 6360 ],
6356 6361
6357 ready: function() { 6362 ready: function() {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6465 /** @private */ 6470 /** @private */
6466 computeIsMalware_: function() { 6471 computeIsMalware_: function() {
6467 return this.isDangerous_ && 6472 return this.isDangerous_ &&
6468 (this.data.danger_type == downloads.DangerType.DANGEROUS_CONTENT || 6473 (this.data.danger_type == downloads.DangerType.DANGEROUS_CONTENT ||
6469 this.data.danger_type == downloads.DangerType.DANGEROUS_HOST || 6474 this.data.danger_type == downloads.DangerType.DANGEROUS_HOST ||
6470 this.data.danger_type == downloads.DangerType.DANGEROUS_URL || 6475 this.data.danger_type == downloads.DangerType.DANGEROUS_URL ||
6471 this.data.danger_type == downloads.DangerType.POTENTIALLY_UNWANTED); 6476 this.data.danger_type == downloads.DangerType.POTENTIALLY_UNWANTED);
6472 }, 6477 },
6473 6478
6474 /** @private */ 6479 /** @private */
6480 computePauseOrResumeText_: function() {
6481 if (this.isInProgress_)
6482 return loadTimeData.getString('controlPause');
6483 if (this.data.resume)
6484 return loadTimeData.getString('controlResume');
6485 return '';
6486 },
6487
6488 /** @private */
6475 computeRemoveStyle_: function() { 6489 computeRemoveStyle_: function() {
6476 var canDelete = loadTimeData.getBoolean('allowDeletingHistory'); 6490 var canDelete = loadTimeData.getBoolean('allowDeletingHistory');
6477 var hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete; 6491 var hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete;
6478 return hideRemove ? 'visibility: hidden' : ''; 6492 return hideRemove ? 'visibility: hidden' : '';
6479 }, 6493 },
6480 6494
6481 /** @private */ 6495 /** @private */
6482 computeShowCancel_: function() { 6496 computeShowCancel_: function() {
6483 return this.data.state == downloads.States.IN_PROGRESS || 6497 return this.data.state == downloads.States.IN_PROGRESS ||
6484 this.data.state == downloads.States.PAUSED; 6498 this.data.state == downloads.States.PAUSED;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
6553 /** 6567 /**
6554 * @param {Event} e 6568 * @param {Event} e
6555 * @private 6569 * @private
6556 */ 6570 */
6557 onFileLinkTap_: function(e) { 6571 onFileLinkTap_: function(e) {
6558 e.preventDefault(); 6572 e.preventDefault();
6559 downloads.ActionService.getInstance().openFile(this.data.id); 6573 downloads.ActionService.getInstance().openFile(this.data.id);
6560 }, 6574 },
6561 6575
6562 /** @private */ 6576 /** @private */
6563 onPauseTap_: function() { 6577 onPauseOrResumeTap_: function() {
6564 downloads.ActionService.getInstance().pause(this.data.id); 6578 if (this.isInProgress_)
6579 downloads.ActionService.getInstance().pause(this.data.id);
6580 else
6581 downloads.ActionService.getInstance().resume(this.data.id);
6565 }, 6582 },
6566 6583
6567 /** @private */ 6584 /** @private */
6568 onRemoveTap_: function() { 6585 onRemoveTap_: function() {
6569 downloads.ActionService.getInstance().remove(this.data.id); 6586 downloads.ActionService.getInstance().remove(this.data.id);
6570 }, 6587 },
6571 6588
6572 /** @private */ 6589 /** @private */
6573 onResumeTap_: function() {
6574 downloads.ActionService.getInstance().resume(this.data.id);
6575 },
6576
6577 /** @private */
6578 onRetryTap_: function() { 6590 onRetryTap_: function() {
6579 downloads.ActionService.getInstance().download(this.data.url); 6591 downloads.ActionService.getInstance().download(this.data.url);
6580 }, 6592 },
6581 6593
6582 /** @private */ 6594 /** @private */
6583 onSaveDangerousTap_: function() { 6595 onSaveDangerousTap_: function() {
6584 downloads.ActionService.getInstance().saveDangerous(this.data.id); 6596 downloads.ActionService.getInstance().saveDangerous(this.data.id);
6585 }, 6597 },
6586 6598
6587 /** @private */ 6599 /** @private */
(...skipping 4782 matching lines...) Expand 10 before | Expand all | Expand 10 after
11370 /** @return {boolean} Whether "Clear all" should be allowed. */ 11382 /** @return {boolean} Whether "Clear all" should be allowed. */
11371 canClearAll: function() { 11383 canClearAll: function() {
11372 return !this.$['search-input'].getValue() && this.downloadsShowing; 11384 return !this.$['search-input'].getValue() && this.downloadsShowing;
11373 }, 11385 },
11374 11386
11375 onFindCommand: function() { 11387 onFindCommand: function() {
11376 this.$['search-input'].showAndFocus(); 11388 this.$['search-input'].showAndFocus();
11377 }, 11389 },
11378 11390
11379 /** @private */ 11391 /** @private */
11380 closeMoreActions_: function(e) { 11392 closeMoreActions_: function() {
11381 this.$.more.close(); 11393 this.$.more.close();
11382 }, 11394 },
11383 11395
11384 /** @private */ 11396 /** @private */
11385 downloadsShowingChanged_: function() { 11397 downloadsShowingChanged_: function() {
11386 this.updateClearAll_(); 11398 this.updateClearAll_();
11387 }, 11399 },
11388 11400
11389 /** @private */ 11401 /** @private */
11390 onClearAllTap_: function() { 11402 onClearAllTap_: function() {
11391 assert(this.canClearAll()); 11403 assert(this.canClearAll());
11392 downloads.ActionService.getInstance().clearAll(); 11404 downloads.ActionService.getInstance().clearAll();
11393 }, 11405 },
11394 11406
11395 /** @private */ 11407 /** @private */
11396 onPaperDropdownClose_: function() { 11408 onPaperDropdownClose_: function() {
11397 window.removeEventListener('resize', assert(this.boundClose_)); 11409 window.removeEventListener('resize', assert(this.boundClose_));
11398 }, 11410 },
11399 11411
11400 /** 11412 /**
11401 * @param {!Event} e 11413 * @param {!Event} e
11402 * @private 11414 * @private
11403 */ 11415 */
11404 onItemBlur_: function(e) { 11416 onItemBlur_: function(e) {
11405 if (this.$$('paper-menu').items.indexOf(e.relatedTarget) >= 0) 11417 var menu = /** @type {PaperMenuElement} */(this.$$('paper-menu'));
11418 if (menu.items.indexOf(e.relatedTarget) >= 0)
Dan Beam 2016/07/19 01:41:21 totallllly remembered to re-vulcanize after that l
11406 return; 11419 return;
11407 11420
11408 // This can be this.$.more.restoreFocusOnClose = false when this lands: 11421 // This can be this.$.more.restoreFocusOnClose = false when this lands:
11409 // https://github.com/PolymerElements/paper-menu-button/pull/94 11422 // https://github.com/PolymerElements/paper-menu-button/pull/94
11410 this.$.more.$.dropdown.restoreFocusOnClose = false; 11423 this.$.more.$.dropdown.restoreFocusOnClose = false;
11411 this.closeMoreActions_(); 11424 this.closeMoreActions_();
11412 this.$.more.$.dropdown.restoreFocusOnClose = true; 11425 this.$.more.$.dropdown.restoreFocusOnClose = true;
11413 }, 11426 },
11414 11427
11415 /** @private */ 11428 /** @private */
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
11630 Manager.get().updateItem_(index, data); 11643 Manager.get().updateItem_(index, data);
11631 }; 11644 };
11632 11645
11633 return {Manager: Manager}; 11646 return {Manager: Manager};
11634 }); 11647 });
11635 // Copyright 2015 The Chromium Authors. All rights reserved. 11648 // Copyright 2015 The Chromium Authors. All rights reserved.
11636 // Use of this source code is governed by a BSD-style license that can be 11649 // Use of this source code is governed by a BSD-style license that can be
11637 // found in the LICENSE file. 11650 // found in the LICENSE file.
11638 11651
11639 window.addEventListener('load', downloads.Manager.onLoad); 11652 window.addEventListener('load', downloads.Manager.onLoad);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/item.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698