Commit 1441a754 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Fix opening file from Launcher search

The IF condition is inverted, it should return when it isn't a native
FileEntry/DirectoryEntry, only FilesAppEntry's types have "type_name"
attribute defined.

Test: New browser test being added on crrev.com/c/1186295
Bug: 869481
Change-Id: Icfdbdedc8289c65447f02c0604e6a36ac8176e6b
Reviewed-on: https://chromium-review.googlesource.com/1186006
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585698}
parent ff2772ef
......@@ -160,8 +160,8 @@ LauncherSearch.prototype.onOpenResult_ = function(itemId) {
undefined, /* App ID */
LaunchType.FOCUS_SAME_OR_CREATE);
} else {
entry = util.toFilesAppEntry(entry);
if (entry.type_name === undefined) {
// getFileTasks supports only native entries.
if (!util.isNativeEntry(entry)) {
return;
}
// If the file is not directory, try to execute default task.
......
......@@ -1475,3 +1475,17 @@ util.doIfPrimaryContext = function(callback) {
util.toFilesAppEntry = function(entry) {
return /** @type {FilesAppEntry} */ (entry);
};
/**
* Returns true if entry is FileSystemEntry or FileSystemDirectoryEntry, it
* returns false if it's FakeEntry or any one of the FilesAppEntry types.
* TODO(lucmult): Wrap Entry in a FilesAppEntry derived class and remove
* this function. https://crbug.com/835203.
* @param {Entry|FilesAppEntry|FakeEntry} entry
* @return {boolean}
*/
util.isNativeEntry = function(entry) {
entry = util.toFilesAppEntry(entry);
// Only FilesAppEntry types has |type_name| attribute.
return entry.type_name === undefined;
};
......@@ -168,12 +168,8 @@ FileTasks.create = function(
volumeManager, metadataModel, directoryModel, ui, entries, mimeTypes,
taskHistory) {
var tasksPromise = new Promise(function(fulfill) {
// Filter entries to only contain native entries, only FilesAppEntry types
// have type_name property defined.
entries = entries.filter(entry => {
entry = util.toFilesAppEntry(entry);
return entry.type_name === undefined;
});
// getFileTasks supports only native entries.
entries = entries.filter(util.isNativeEntry);
if (entries.length === 0) {
fulfill([]);
return;
......
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