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

[locationline] Do not show empty (aka root) paths

Searchbox activity can send requests to the location line breadcrumb to
display a root "/" path, when the current directory entry is a Recents,
a Fake entry, a mounted Zip file viz., all special directories that are
rooted according to the directory model API

   directoryModel.getCurrentDirEntry();

However, root paths have no path components and cause the location line
show() code to throw an exception accessing components[0].name, causing
files app to become totally unresponsive to user input.

Change location line to ignore requests to show a root (empty) path and
no JS exceptions is the result.

Bug: 1107391
Change-Id: I74523e94ec29f65342b393c2b176f8f4771e838d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308613Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790271}
parent 94616747
...@@ -36,7 +36,7 @@ class LocationLine extends cr.EventTarget { ...@@ -36,7 +36,7 @@ class LocationLine extends cr.EventTarget {
} }
/** /**
* Shows breadcrumbs. This operation is done without IO. * Shows path of |entry|.
* *
* @param {!Entry|!FakeEntry} entry Target entry or fake entry. * @param {!Entry|!FakeEntry} entry Target entry or fake entry.
*/ */
...@@ -47,6 +47,12 @@ class LocationLine extends cr.EventTarget { ...@@ -47,6 +47,12 @@ class LocationLine extends cr.EventTarget {
const components = const components =
PathComponent.computeComponentsFromEntry(entry, this.volumeManager_); PathComponent.computeComponentsFromEntry(entry, this.volumeManager_);
// Root "/" paths have no components, crbug.com/1107391.
if (!components.length) {
return;
}
if (util.isFilesNg()) { if (util.isFilesNg()) {
this.updateNg_(components); this.updateNg_(components);
} else { } else {
...@@ -55,8 +61,8 @@ class LocationLine extends cr.EventTarget { ...@@ -55,8 +61,8 @@ class LocationLine extends cr.EventTarget {
} }
/** /**
* Returns current path components built by the current directory entry. * Returns the breadcrumb path components.
* @return {!Array<!PathComponent>} Current path components. * @return {!Array<!PathComponent>}
*/ */
getCurrentPathComponents() { getCurrentPathComponents() {
return this.components_; return this.components_;
...@@ -64,8 +70,7 @@ class LocationLine extends cr.EventTarget { ...@@ -64,8 +70,7 @@ class LocationLine extends cr.EventTarget {
/** /**
* Updates the breadcrumb display for files-ng. * Updates the breadcrumb display for files-ng.
* @param {!Array<!PathComponent>} components Components to the * @param {!Array<!PathComponent>} components Path components.
* target path.
* @private * @private
*/ */
updateNg_(components) { updateNg_(components) {
...@@ -79,12 +84,12 @@ class LocationLine extends cr.EventTarget { ...@@ -79,12 +84,12 @@ class LocationLine extends cr.EventTarget {
breadcrumbs.setSignalCallback(this.breadCrumbSignal_.bind(this)); breadcrumbs.setSignalCallback(this.breadCrumbSignal_.bind(this));
} }
let crumbPath = components[0].name; let path = components[0].name;
for (let i = 1; i < components.length; i++) { for (let i = 1; i < components.length; i++) {
crumbPath += '/' + components[i].name; path += '/' + components[i].name;
} }
breadcrumbs.path = crumbPath;
breadcrumbs.path = path;
this.breadcrumbs_.hidden = false; this.breadcrumbs_.hidden = false;
} }
......
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