Commit 377decc3 authored by Julian Watson's avatar Julian Watson Committed by Commit Bot

plugin_vm: check paths valid before starting vm

Bug: 1049453
Change-Id: I7c639bb0c4c517216b2b76551b578fd2420e13bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2206866
Auto-Submit: Julian Watson <juwa@google.com>
Commit-Queue: Timothy Loh <timloh@chromium.org>
Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770463}
parent dbcbea67
......@@ -79,7 +79,7 @@ void FocusAllPluginVmWindows() {
// LaunchPluginVmApp will run before this and try to start Plugin VM.
void LaunchPluginVmAppImpl(Profile* profile,
std::string app_id,
const std::vector<storage::FileSystemURL>& files,
std::vector<std::string> file_paths,
LaunchPluginVmAppCallback callback,
bool plugin_vm_is_running) {
if (!plugin_vm_is_running) {
......@@ -94,19 +94,6 @@ void LaunchPluginVmAppImpl(Profile* profile,
false, "LaunchPluginVmApp called with an unknown app_id: " + app_id);
}
std::vector<std::string> file_paths;
file_paths.reserve(files.size());
for (const auto& file : files) {
auto file_path =
ConvertFileSystemURLToPathInsidePluginVmSharedDir(profile, file);
if (!file_path) {
return std::move(callback).Run(
false, "Only files in the shared dir are supported. Got: " +
file.DebugString());
}
file_paths.push_back(std::move(*file_path));
}
vm_tools::cicerone::LaunchContainerApplicationRequest request;
request.set_owner_id(
chromeos::ProfileHelper::GetUserIdHashFromProfile(profile));
......@@ -185,7 +172,7 @@ base::Optional<std::string> ConvertFileSystemURLToPathInsidePluginVmSharedDir(
void LaunchPluginVmApp(Profile* profile,
std::string app_id,
std::vector<storage::FileSystemURL> files,
const std::vector<storage::FileSystemURL>& files,
LaunchPluginVmAppCallback callback) {
if (!plugin_vm::IsPluginVmEnabled(profile)) {
return std::move(callback).Run(false,
......@@ -198,9 +185,22 @@ void LaunchPluginVmApp(Profile* profile,
return std::move(callback).Run(false, "Could not get PluginVmManager");
}
manager->LaunchPluginVm(base::BindOnce(&LaunchPluginVmAppImpl, profile,
std::move(app_id), std::move(files),
std::move(callback)));
std::vector<std::string> file_paths;
file_paths.reserve(files.size());
for (const auto& file : files) {
auto file_path =
ConvertFileSystemURLToPathInsidePluginVmSharedDir(profile, file);
if (!file_path) {
return std::move(callback).Run(
false, "Only files in the shared dir are supported. Got: " +
file.DebugString());
}
file_paths.push_back(std::move(*file_path));
}
manager->LaunchPluginVm(
base::BindOnce(&LaunchPluginVmAppImpl, profile, std::move(app_id),
std::move(file_paths), std::move(callback)));
}
} // namespace plugin_vm
......@@ -33,7 +33,7 @@ using LaunchPluginVmAppCallback =
// the VM. Will start Plugin VM if it is not already running.
void LaunchPluginVmApp(Profile* profile,
std::string app_id,
std::vector<storage::FileSystemURL> files,
const std::vector<storage::FileSystemURL>& files,
LaunchPluginVmAppCallback callback);
} // namespace plugin_vm
......
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