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

Unified Diff: chrome/browser/resources/md_downloads/item.js

Issue 1302293008: MD Downloads: use computed data binding to hide removal (X) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dom-if2
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_downloads/item.js
diff --git a/chrome/browser/resources/md_downloads/item.js b/chrome/browser/resources/md_downloads/item.js
index 706436de77ccc5b7b9d1a7eebe00000f6e7bacca..2f43efc43bf71648aad800d370f95a55398659e6 100644
--- a/chrome/browser/resources/md_downloads/item.js
+++ b/chrome/browser/resources/md_downloads/item.js
@@ -158,20 +158,13 @@ cr.define('downloads', function() {
this.$.content.classList.toggle('show-progress', this.showProgress_);
- var hideRemove;
-
- if (this.isDangerous_) {
- hideRemove = true;
- } else {
+ if (!this.isDangerous_) {
this.$['file-link'].href = data.url;
this.ensureTextIs_(this.$['file-link'], data.file_name);
this.$['file-link'].hidden = !this.completelyOnDisk_;
this.$.name.hidden = this.completelyOnDisk_;
- hideRemove = this.showCancel_ ||
- !loadTimeData.getBoolean('allowDeletingHistory');
-
/** @const */ var controlledByExtension = data.by_ext_id &&
data.by_ext_name;
this.$['controlled-by'].hidden = !controlledByExtension;
@@ -184,8 +177,6 @@ cr.define('downloads', function() {
var icon = 'chrome://fileicon/' + encodeURIComponent(data.file_path);
this.iconLoader_.loadScaledIcon(this.$['file-icon'], icon);
}
-
- this.$.remove.style.visibility = hideRemove ? 'hidden' : '';
},
/** @private */
@@ -220,6 +211,13 @@ cr.define('downloads', function() {
},
/** @private */
+ computeRemoveStyle_: function() {
+ var canDelete = loadTimeData.getBoolean('allowDeletingHistory');
+ var hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete;
+ return hideRemove ? 'visibility: hidden' : '';
+ },
+
+ /** @private */
computeShowCancel_: function() {
return this.data_.state == downloads.States.IN_PROGRESS ||
this.data_.state == downloads.States.PAUSED;
@@ -302,6 +300,11 @@ cr.define('downloads', function() {
this.actionService_.cancel(this.data_.id);
},
+ /** @private */
+ onDiscardDangerous_: function() {
+ this.actionService_.discardDangerous(this.data_.id);
+ },
+
/**
* @private
* @param {Event} e
@@ -327,21 +330,10 @@ cr.define('downloads', function() {
/** @private */
onRemoveClick_: function() {
- assert(!this.$.remove.disabled);
this.actionService_.remove(this.data_.id);
},
/** @private */
- onSaveDangerous_: function() {
- this.actionService_.saveDangerous(this.data_.id);
- },
-
- /** @private */
- onDiscardDangerous_: function() {
- this.actionService_.discardDangerous(this.data_.id);
- },
-
- /** @private */
onResumeClick_: function() {
this.actionService_.resume(this.data_.id);
},
@@ -352,6 +344,11 @@ cr.define('downloads', function() {
},
/** @private */
+ onSaveDangerous_: function() {
+ this.actionService_.saveDangerous(this.data_.id);
+ },
+
+ /** @private */
onScrollbarWidthChange_: function() {
if (!this.$)
return;

Powered by Google App Engine
This is Rietveld 408576698