Commit 6ce9c441 authored by Joel Hockey's avatar Joel Hockey Committed by Chromium LUCI CQ

Use real FilesApp Origin for ConvertPathInsideVMToFileSystemURL

The FileSystemURL from ConvertPathInsideVMToFileSystemURL will be used
with the clipboard to copy and paste files between VMs and FilesApp. It
needs to be valid with the real FilesApp Origin in order for this to
work.

Bug: b/162602338
Change-Id: I3ac2961e762dd26104b5f2461997b3175a5f7367
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2643737
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarJason Lin <lxj@google.com>
Cr-Commit-Position: refs/heads/master@{#845950}
parent d92d11df
......@@ -22,6 +22,7 @@
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
#include "chrome/browser/chromeos/fileapi/file_system_backend.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
......@@ -40,6 +41,7 @@
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/common/extension.h"
#include "net/base/escape.h"
#include "net/base/filename_util.h"
#include "storage/browser/file_system/external_mount_points.h"
......@@ -479,7 +481,9 @@ bool ConvertPathInsideVMToFileSystemURL(
if (container_info &&
AppendRelativePath(container_info->homedir, inside, &relative_path)) {
*file_system_url = mount_points->CreateExternalFileSystemURL(
url::Origin(), GetCrostiniMountPointName(profile), relative_path);
url::Origin::Create(extensions::Extension::GetBaseURLFromExtensionId(
file_manager::kFileManagerAppId)),
GetCrostiniMountPointName(profile), relative_path);
return file_system_url->is_valid();
}
}
......@@ -545,7 +549,9 @@ bool ConvertPathInsideVMToFileSystemURL(
}
*file_system_url = mount_points->CreateExternalFileSystemURL(
url::Origin(), mount_name, path);
url::Origin::Create(extensions::Extension::GetBaseURLFromExtensionId(
file_manager::kFileManagerAppId)),
mount_name, path);
return file_system_url->is_valid();
}
......
......@@ -434,6 +434,9 @@ TEST_F(FileManagerPathUtilTest, ConvertBetweenFileSystemURLAndPathInsideVM) {
EXPECT_TRUE(ConvertPathInsideVMToFileSystemURL(
profile_.get(), base::FilePath(test.inside), vm_mount,
/*map_crostini_home=*/false, &url));
EXPECT_TRUE(url.is_valid());
EXPECT_EQ("chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/",
url.origin().GetURL());
EXPECT_EQ(test.mount_name, url.filesystem_id());
EXPECT_EQ(test.mount_name + "/" + test.relative_path,
url.virtual_path().value());
......@@ -465,6 +468,9 @@ TEST_F(FileManagerPathUtilTest, ConvertBetweenFileSystemURLAndPathInsideVM) {
EXPECT_TRUE(ConvertPathInsideVMToFileSystemURL(
profile_.get(), base::FilePath("/home/testuser/path/in/crostini"),
vm_mount, /*map_crostini_home=*/true, &url));
EXPECT_TRUE(url.is_valid());
EXPECT_EQ("chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/",
url.origin().GetURL());
EXPECT_EQ("crostini_0123456789abcdef_termina_penguin/path/in/crostini",
url.virtual_path().value());
EXPECT_FALSE(ConvertPathInsideVMToFileSystemURL(
......
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