Commit 429d31c5 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[directory tree] Make AndroidAppItem derive from TreeItem

TreeItem handles the item content creation, label, tree parent_ etc so
remove local AndfroidAppItem code related to that.

Bug: 992819
Change-Id: Idc618323fdfae016c2e8788f3d54148ae33f38b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1868352
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707264}
parent 71b3152a
...@@ -1656,38 +1656,30 @@ class ShortcutItem extends cr.ui.TreeItem { ...@@ -1656,38 +1656,30 @@ class ShortcutItem extends cr.ui.TreeItem {
* A TreeItem representing an Android picker app. These Android app items are * A TreeItem representing an Android picker app. These Android app items are
* shown as top-level volume entries of the DirectoryTree. * shown as top-level volume entries of the DirectoryTree.
*/ */
class AndroidAppItem extends cr.ui.TreeItem { class AndroidAppItem extends TreeItem {
/** /**
* @param {!NavigationModelAndroidAppItem} modelItem NavigationModelItem * @param {!NavigationModelAndroidAppItem} modelItem NavigationModelItem
* associated with this volume. * associated with this volume.
* @param {!DirectoryTree} tree Directory tree. * @param {!DirectoryTree} tree Directory tree.
*/ */
constructor(modelItem, tree) { constructor(modelItem, tree) {
super(); super(modelItem.androidApp.name, tree);
// Get the original label id defined by TreeItem, before overwriting
// prototype.
const labelId = this.labelElement.id;
this.__proto__ = AndroidAppItem.prototype; this.__proto__ = AndroidAppItem.prototype;
/** @private {!DirectoryTree} */ if (window.IN_TEST) {
this.parentTree_ = tree; this.setAttribute('dir-type', 'AndroidAppItem');
}
/** @private {!NavigationModelAndroidAppItem} */
this.modelItem_ = modelItem; this.modelItem_ = modelItem;
this.innerHTML = TREE_ITEM_INNER_HTML; const icon = this.querySelector('.icon');
this.labelElement.id = labelId; icon.classList.add('item-icon');
/** @public {string} */
this.label = modelItem.androidApp.name;
const appIcon = this.querySelector('.icon');
appIcon.classList.add('item-icon');
if (modelItem.androidApp.iconSet) { if (modelItem.androidApp.iconSet) {
const backgroundImage = const backgroundImage =
util.iconSetToCSSBackgroundImageValue(modelItem.androidApp.iconSet); util.iconSetToCSSBackgroundImageValue(modelItem.androidApp.iconSet);
if (backgroundImage !== 'none') { if (backgroundImage !== 'none') {
appIcon.setAttribute('style', 'background-image: ' + backgroundImage); icon.setAttribute('style', 'background-image: ' + backgroundImage);
} }
} }
......
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