Commit df2f0663 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[directorytree] Add files-ng generic provided icons if needed

Every volume type in FilesApp has volumeMetadata from chrome.FMP, that
contains an iconSet property: it is empty (contains no icons) for most
volume types.

Somes volumes like AndroidAppItem, PROVIDED, and DOCUMENT_PROVIDER can
(and usually do) provide icons in the iconSet property. If they don't,
FilesApp draws nothing in their .tree-row .item-icon element today.

AndroidAppItem volumes can provide icons: in the files-ng case, draw a
generic provided icon if their iconSet has no icons.

VolumeItem PROVIDED and DOCUMENT_PROVIDER can provide icons, but there
is no reliable way to detect/fix their missing icons today since other
volume types use VolumeItem too. If they don't provide icons, FilesApp
files-ng will now draw a gray box in their .item-icon, a visual change
in behavior compared to normal FilesApp.

Bug: 992819
Change-Id: I6d2ec07ef91fd3acd8edff8bc5053eab4450680c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1945958Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721279}
parent 43d64fe0
......@@ -1116,19 +1116,19 @@ class VolumeItem extends DirectoryItem {
*/
setupIcon_(icon, volumeInfo) {
icon.classList.add('item-icon');
const backgroundImage =
util.iconSetToCSSBackgroundImageValue(volumeInfo.iconSet);
if (backgroundImage !== 'none') {
// The icon div is not yet added to DOM, therefore it is impossible to
// use style.backgroundImage.
icon.setAttribute('style', 'background-image: ' + backgroundImage);
}
icon.setAttribute('volume-type-icon', volumeInfo.volumeType);
if (volumeInfo.volumeType === VolumeManagerCommon.VolumeType.MEDIA_VIEW) {
icon.setAttribute(
'volume-subtype',
VolumeManagerCommon.getMediaViewRootTypeFromVolumeId(
volumeInfo.volumeId));
const subtype = VolumeManagerCommon.getMediaViewRootTypeFromVolumeId(
volumeInfo.volumeId);
icon.setAttribute('volume-subtype', subtype);
} else {
icon.setAttribute('volume-subtype', volumeInfo.deviceType || '');
}
......@@ -1676,6 +1676,10 @@ class AndroidAppItem extends TreeItem {
}
}
if (directorytree.FILES_NG_ENABLED && !icon.hasAttribute('style')) {
icon.setAttribute('use-generic-provided-icon', '');
}
// Create an external link icon. TODO(crbug.com/986169) does this icon
// element need aria-label, role, tabindex, etc?
const externalLinkIcon = document.createElement('span');
......
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