CrOS FilesApp: allow install deb by sharing with crostini
Currently deb files can only be installed into the crostini
container in FilesApp if they are already in Linux files.
Now, files will be shared with the container if they are in
a sharable volume such as Downloads or Drive, so deb files
at these locations can be installed.
Bug: 878324
Change-Id: I126568eefec1506a205035d9f8a585548f92b527
Reviewed-on: https://chromium-review.googlesource.com/c/1301133
Reviewed-by: Timothy Loh <timloh@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603415}
diff --git a/ui/file_manager/file_manager/foreground/js/crostini.js b/ui/file_manager/file_manager/foreground/js/crostini.js
index b0f412f..f9c3ee45 100644
--- a/ui/file_manager/file_manager/foreground/js/crostini.js
+++ b/ui/file_manager/file_manager/foreground/js/crostini.js
@@ -132,3 +132,15 @@
(loadTimeData.getBoolean('DRIVE_FS_ENABLED') &&
Crostini.VALID_ROOT_TYPES_FOR_SHARE.has(rootType));
};
+
+/**
+ * Returns true if task requires entries to be shared before executing task.
+ * @param {!chrome.fileManagerPrivate.FileTask} task Task to run.
+ * @return {boolean} true if task requires entries to be shared.
+ */
+Crostini.taskRequiresSharing = function(task) {
+ const taskParts = task.taskId.split('|');
+ const taskType = taskParts[1];
+ const actionId = taskParts[2];
+ return taskType === 'crostini' || actionId === 'install-linux-package';
+};
diff --git a/ui/file_manager/file_manager/foreground/js/crostini_unittest.js b/ui/file_manager/file_manager/foreground/js/crostini_unittest.js
index 2bc29768..a22fa6ca 100644
--- a/ui/file_manager/file_manager/foreground/js/crostini_unittest.js
+++ b/ui/file_manager/file_manager/foreground/js/crostini_unittest.js
@@ -78,3 +78,10 @@
assertTrue(Crostini.canSharePath(fooFolder, false, volumeManager));
}
}
+
+function testTaskRequiresSharing() {
+ assertTrue(Crostini.taskRequiresSharing({taskId: 'app|crostini|open-with'}));
+ assertTrue(
+ Crostini.taskRequiresSharing({taskId: 'appId|x|install-linux-package'}));
+ assertFalse(Crostini.taskRequiresSharing({taskId: 'appId|x|open-with'}));
+}
diff --git a/ui/file_manager/file_manager/foreground/js/file_tasks.js b/ui/file_manager/file_manager/foreground/js/file_tasks.js
index 5f9ec981..1a0fd3f 100644
--- a/ui/file_manager/file_manager/foreground/js/file_tasks.js
+++ b/ui/file_manager/file_manager/foreground/js/file_tasks.js
@@ -176,12 +176,14 @@
}
// Linux package installation is currently only supported for a single
- // file already inside the Linux container.
+ // file which is inside the Linux container, or in a sharable volume.
// TODO(timloh): Instead of filtering these out, we probably should show
// a dialog with an error message, similar to when attempting to run
// Crostini tasks with non-Crostini entries.
if (entries.length !== 1 ||
- !Crostini.isCrostiniEntry(entries[0], volumeManager)) {
+ !(Crostini.isCrostiniEntry(entries[0], volumeManager) ||
+ Crostini.canSharePath(
+ entries[0], false /* persist */, volumeManager))) {
taskItems = taskItems.filter(function(item) {
var taskParts = item.taskId.split('|');
var appId = taskParts[0];
@@ -558,7 +560,7 @@
FileTasks.prototype.maybeShareWithCrostiniOrShowDialog_ = function(
task, callback) {
// Check if this is a crostini task.
- if (task.taskId.split('|', 2)[1] !== 'crostini' || this.entries_.length < 1)
+ if (!Crostini.taskRequiresSharing(task))
return callback();
let showUnableToOpen = false;