Commit 7ed004e5 authored by Esmael El-Moslimany's avatar Esmael El-Moslimany Committed by Commit Bot

Download WebUI: include file name in remove link aria-label

Bug: 866926
Change-Id: I4811f8cafd4febc39955ea4c076b83fb7c0035a9
Reviewed-on: https://chromium-review.googlesource.com/c/1309094
Commit-Queue: Esmael El-Moslimany <aee@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604466}
parent 09a1ec40
...@@ -1576,6 +1576,10 @@ are declared in tools/grit/grit_rule.gni. ...@@ -1576,6 +1576,10 @@ are declared in tools/grit/grit_rule.gni.
desc="In the download view, 'Remove from list' link text"> desc="In the download view, 'Remove from list' link text">
Remove from list Remove from list
</message> </message>
<message name="IDS_DOWNLOAD_LINK_REMOVE_ARIA_LABEL"
desc="In the download view, 'Remove from list' link aria-label">
Remove <ph name="FILE_NAME">$1<ex>somedocument.pdf</ex></ph> from list
</message>
<message name="IDS_DOWNLOAD_LINK_CANCEL" <message name="IDS_DOWNLOAD_LINK_CANCEL"
desc="In the download view, 'Cancel' link text"> desc="In the download view, 'Cancel' link text">
Cancel Cancel
......
...@@ -308,7 +308,7 @@ ...@@ -308,7 +308,7 @@
style$="[[computeRemoveStyle_(isDangerous_, showCancel_)]]"> style$="[[computeRemoveStyle_(isDangerous_, showCancel_)]]">
<button id="remove" <button id="remove"
title="$i18n{controlRemoveFromList}" title="$i18n{controlRemoveFromList}"
aria-label="$i18n{controlRemoveFromList}" aria-label$="[[controlRemoveFromListAriaLabel_]]"
on-click="onRemoveTap_"></button> on-click="onRemoveTap_"></button>
</paper-icon-button-light> </paper-icon-button-light>
</div> </div>
......
...@@ -7,8 +7,10 @@ cr.define('downloads', function() { ...@@ -7,8 +7,10 @@ cr.define('downloads', function() {
is: 'downloads-item', is: 'downloads-item',
properties: { properties: {
/** @type {!downloads.Data} */
data: Object, data: Object,
/** @private */
completelyOnDisk_: { completelyOnDisk_: {
computed: 'computeCompletelyOnDisk_(' + computed: 'computeCompletelyOnDisk_(' +
'data.state, data.file_externally_removed)', 'data.state, data.file_externally_removed)',
...@@ -16,12 +18,20 @@ cr.define('downloads', function() { ...@@ -16,12 +18,20 @@ cr.define('downloads', function() {
value: true, value: true,
}, },
/** @private */
controlledBy_: { controlledBy_: {
computed: 'computeControlledBy_(data.by_ext_id, data.by_ext_name)', computed: 'computeControlledBy_(data.by_ext_id, data.by_ext_name)',
type: String, type: String,
value: '', value: '',
}, },
/** @private */
controlRemoveFromListAriaLabel_: {
type: String,
computed: 'computeControlRemoveFromListAriaLabel_(data.file_name)',
},
/** @private */
isActive_: { isActive_: {
computed: 'computeIsActive_(' + computed: 'computeIsActive_(' +
'data.state, data.file_externally_removed)', 'data.state, data.file_externally_removed)',
...@@ -29,40 +39,47 @@ cr.define('downloads', function() { ...@@ -29,40 +39,47 @@ cr.define('downloads', function() {
value: true, value: true,
}, },
/** @private */
isDangerous_: { isDangerous_: {
computed: 'computeIsDangerous_(data.state)', computed: 'computeIsDangerous_(data.state)',
type: Boolean, type: Boolean,
value: false, value: false,
}, },
/** @private */
isMalware_: { isMalware_: {
computed: 'computeIsMalware_(isDangerous_, data.danger_type)', computed: 'computeIsMalware_(isDangerous_, data.danger_type)',
type: Boolean, type: Boolean,
value: false, value: false,
}, },
/** @private */
isInProgress_: { isInProgress_: {
computed: 'computeIsInProgress_(data.state)', computed: 'computeIsInProgress_(data.state)',
type: Boolean, type: Boolean,
value: false, value: false,
}, },
/** @private */
pauseOrResumeClass_: { pauseOrResumeClass_: {
computed: 'computePauseOrResumeClass_(isInProgress_, data.resume)', computed: 'computePauseOrResumeClass_(isInProgress_, data.resume)',
type: String, type: String,
}, },
/** @private */
pauseOrResumeText_: { pauseOrResumeText_: {
computed: 'computePauseOrResumeText_(isInProgress_, data.resume)', computed: 'computePauseOrResumeText_(isInProgress_, data.resume)',
type: String, type: String,
}, },
/** @private */
showCancel_: { showCancel_: {
computed: 'computeShowCancel_(data.state)', computed: 'computeShowCancel_(data.state)',
type: Boolean, type: Boolean,
value: false, value: false,
}, },
/** @private */
showProgress_: { showProgress_: {
computed: 'computeShowProgress_(showCancel_, data.percent)', computed: 'computeShowProgress_(showCancel_, data.percent)',
type: Boolean, type: Boolean,
...@@ -111,13 +128,19 @@ cr.define('downloads', function() { ...@@ -111,13 +128,19 @@ cr.define('downloads', function() {
return classes.join(' '); return classes.join(' ');
}, },
/** @private */ /**
* @return {boolean}
* @private
*/
computeCompletelyOnDisk_: function() { computeCompletelyOnDisk_: function() {
return this.data.state == downloads.States.COMPLETE && return this.data.state == downloads.States.COMPLETE &&
!this.data.file_externally_removed; !this.data.file_externally_removed;
}, },
/** @private */ /**
* @return {string}
* @private
*/
computeControlledBy_: function() { computeControlledBy_: function() {
if (!this.data.by_ext_id || !this.data.by_ext_name) if (!this.data.by_ext_id || !this.data.by_ext_name)
return ''; return '';
...@@ -127,12 +150,27 @@ cr.define('downloads', function() { ...@@ -127,12 +150,27 @@ cr.define('downloads', function() {
return loadTimeData.getStringF('controlledByUrl', url, HTMLEscape(name)); return loadTimeData.getStringF('controlledByUrl', url, HTMLEscape(name));
}, },
/** @private */ /**
* @return {string}
* @private
*/
computeControlRemoveFromListAriaLabel_: function() {
return loadTimeData.getStringF(
'controlRemoveFromListAriaLabel', this.data.file_name);
},
/**
* @return {string}
* @private
*/
computeDangerIcon_: function() { computeDangerIcon_: function() {
return this.isDangerous_ ? 'cr:warning' : ''; return this.isDangerous_ ? 'cr:warning' : '';
}, },
/** @private */ /**
* @return {string}
* @private
*/
computeDate_: function() { computeDate_: function() {
assert(typeof this.data.hideDate == 'boolean'); assert(typeof this.data.hideDate == 'boolean');
if (this.data.hideDate) if (this.data.hideDate)
...@@ -140,7 +178,10 @@ cr.define('downloads', function() { ...@@ -140,7 +178,10 @@ cr.define('downloads', function() {
return assert(this.data.since_string || this.data.date_string); return assert(this.data.since_string || this.data.date_string);
}, },
/** @private */ /**
* @return {string}
* @private
*/
computeDescription_: function() { computeDescription_: function() {
const data = this.data; const data = this.data;
...@@ -172,24 +213,36 @@ cr.define('downloads', function() { ...@@ -172,24 +213,36 @@ cr.define('downloads', function() {
return ''; return '';
}, },
/** @private */ /**
* @return {boolean}
* @private
*/
computeIsActive_: function() { computeIsActive_: function() {
return this.data.state != downloads.States.CANCELLED && return this.data.state != downloads.States.CANCELLED &&
this.data.state != downloads.States.INTERRUPTED && this.data.state != downloads.States.INTERRUPTED &&
!this.data.file_externally_removed; !this.data.file_externally_removed;
}, },
/** @private */ /**
* @return {boolean}
* @private
*/
computeIsDangerous_: function() { computeIsDangerous_: function() {
return this.data.state == downloads.States.DANGEROUS; return this.data.state == downloads.States.DANGEROUS;
}, },
/** @private */ /**
* @return {boolean}
* @private
*/
computeIsInProgress_: function() { computeIsInProgress_: function() {
return this.data.state == downloads.States.IN_PROGRESS; return this.data.state == downloads.States.IN_PROGRESS;
}, },
/** @private */ /**
* @return {boolean}
* @private
*/
computeIsMalware_: function() { computeIsMalware_: function() {
return this.isDangerous_ && return this.isDangerous_ &&
(this.data.danger_type == downloads.DangerType.DANGEROUS_CONTENT || (this.data.danger_type == downloads.DangerType.DANGEROUS_CONTENT ||
...@@ -209,7 +262,10 @@ cr.define('downloads', function() { ...@@ -209,7 +262,10 @@ cr.define('downloads', function() {
return !this.isInProgress_ && this.data.resume ? 'action-button' : ''; return !this.isInProgress_ && this.data.resume ? 'action-button' : '';
}, },
/** @private */ /**
* @return {string}
* @private
*/
computePauseOrResumeText_: function() { computePauseOrResumeText_: function() {
if (this.data === undefined) if (this.data === undefined)
return ''; return '';
...@@ -221,25 +277,37 @@ cr.define('downloads', function() { ...@@ -221,25 +277,37 @@ cr.define('downloads', function() {
return ''; return '';
}, },
/** @private */ /**
* @return {string}
* @private
*/
computeRemoveStyle_: function() { computeRemoveStyle_: function() {
const canDelete = loadTimeData.getBoolean('allowDeletingHistory'); const canDelete = loadTimeData.getBoolean('allowDeletingHistory');
const hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete; const hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete;
return hideRemove ? 'visibility: hidden' : ''; return hideRemove ? 'visibility: hidden' : '';
}, },
/** @private */ /**
* @return {boolean}
* @private
*/
computeShowCancel_: function() { computeShowCancel_: function() {
return this.data.state == downloads.States.IN_PROGRESS || return this.data.state == downloads.States.IN_PROGRESS ||
this.data.state == downloads.States.PAUSED; this.data.state == downloads.States.PAUSED;
}, },
/** @private */ /**
* @return {boolean}
* @private
*/
computeShowProgress_: function() { computeShowProgress_: function() {
return this.showCancel_ && this.data.percent >= -1; return this.showCancel_ && this.data.percent >= -1;
}, },
/** @private */ /**
* @return {string}
* @private
*/
computeTag_: function() { computeTag_: function() {
switch (this.data.state) { switch (this.data.state) {
case downloads.States.CANCELLED: case downloads.States.CANCELLED:
...@@ -257,7 +325,10 @@ cr.define('downloads', function() { ...@@ -257,7 +325,10 @@ cr.define('downloads', function() {
return ''; return '';
}, },
/** @private */ /**
* @return {boolean}
* @private
*/
isIndeterminate_: function() { isIndeterminate_: function() {
return this.data.percent == -1; return this.data.percent == -1;
}, },
......
...@@ -82,6 +82,8 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) { ...@@ -82,6 +82,8 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
source->AddLocalizedString("controlCancel", IDS_DOWNLOAD_LINK_CANCEL); source->AddLocalizedString("controlCancel", IDS_DOWNLOAD_LINK_CANCEL);
source->AddLocalizedString("controlResume", IDS_DOWNLOAD_LINK_RESUME); source->AddLocalizedString("controlResume", IDS_DOWNLOAD_LINK_RESUME);
source->AddLocalizedString("controlRemoveFromList", IDS_DOWNLOAD_LINK_REMOVE); source->AddLocalizedString("controlRemoveFromList", IDS_DOWNLOAD_LINK_REMOVE);
source->AddLocalizedString("controlRemoveFromListAriaLabel",
IDS_DOWNLOAD_LINK_REMOVE_ARIA_LABEL);
source->AddLocalizedString("controlRetry", IDS_MD_DOWNLOAD_LINK_RETRY); source->AddLocalizedString("controlRetry", IDS_MD_DOWNLOAD_LINK_RETRY);
source->AddLocalizedString("controlledByUrl", IDS_DOWNLOAD_BY_EXTENSION_URL); source->AddLocalizedString("controlledByUrl", IDS_DOWNLOAD_BY_EXTENSION_URL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment