Commit 2e58032c authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

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/1301133Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603415}
parent abf4f9a5
...@@ -132,3 +132,15 @@ Crostini.canSharePath = function(entry, persist, volumeManager) { ...@@ -132,3 +132,15 @@ Crostini.canSharePath = function(entry, persist, volumeManager) {
(loadTimeData.getBoolean('DRIVE_FS_ENABLED') && (loadTimeData.getBoolean('DRIVE_FS_ENABLED') &&
Crostini.VALID_ROOT_TYPES_FOR_SHARE.has(rootType)); 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';
};
...@@ -78,3 +78,10 @@ function testCanSharePath() { ...@@ -78,3 +78,10 @@ function testCanSharePath() {
assertTrue(Crostini.canSharePath(fooFolder, false, volumeManager)); 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'}));
}
...@@ -176,12 +176,14 @@ FileTasks.create = function( ...@@ -176,12 +176,14 @@ FileTasks.create = function(
} }
// Linux package installation is currently only supported for a single // 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 // TODO(timloh): Instead of filtering these out, we probably should show
// a dialog with an error message, similar to when attempting to run // a dialog with an error message, similar to when attempting to run
// Crostini tasks with non-Crostini entries. // Crostini tasks with non-Crostini entries.
if (entries.length !== 1 || 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) { taskItems = taskItems.filter(function(item) {
var taskParts = item.taskId.split('|'); var taskParts = item.taskId.split('|');
var appId = taskParts[0]; var appId = taskParts[0];
...@@ -558,7 +560,7 @@ FileTasks.annotateTasks_ = function(tasks, entries) { ...@@ -558,7 +560,7 @@ FileTasks.annotateTasks_ = function(tasks, entries) {
FileTasks.prototype.maybeShareWithCrostiniOrShowDialog_ = function( FileTasks.prototype.maybeShareWithCrostiniOrShowDialog_ = function(
task, callback) { task, callback) {
// Check if this is a crostini task. // Check if this is a crostini task.
if (task.taskId.split('|', 2)[1] !== 'crostini' || this.entries_.length < 1) if (!Crostini.taskRequiresSharing(task))
return callback(); return callback();
let showUnableToOpen = false; let showUnableToOpen = 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