Commit 7093fad0 authored by Md. Hasanur Rashid's avatar Md. Hasanur Rashid Committed by Commit Bot

Change CreateExternalFileSystemURL to use url::Origin

This CL update the function CreateExternalFileSystemURL to use
url::Origin instead of GURL.

Bug: 598424
Change-Id: I0966c6dc56f7bf22a36a63c1491bb88643303c07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035516Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Md. Hasanur Rashid <hasanur.r@samsung.com>
Cr-Commit-Position: refs/heads/master@{#738825}
parent 2febd530
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "url/origin.h"
namespace crostini { namespace crostini {
...@@ -192,7 +193,7 @@ class CrostiniPackageServiceTest : public testing::Test { ...@@ -192,7 +193,7 @@ class CrostiniPackageServiceTest : public testing::Test {
storage::FileSystemMountOption(), storage::FileSystemMountOption(),
file_manager::util::GetDownloadsFolderForProfile(profile_.get())); file_manager::util::GetDownloadsFolderForProfile(profile_.get()));
package_file_url_ = mount_points->CreateExternalFileSystemURL( package_file_url_ = mount_points->CreateExternalFileSystemURL(
GURL(), mount_point_name, base::FilePath(kPackageFilePath)); url::Origin(), mount_point_name, base::FilePath(kPackageFilePath));
auto* crostini_manager = CrostiniManager::GetForProfile(profile_.get()); auto* crostini_manager = CrostiniManager::GetForProfile(profile_.get());
ASSERT_TRUE(crostini_manager); ASSERT_TRUE(crostini_manager);
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "storage/browser/file_system/external_mount_points.h" #include "storage/browser/file_system/external_mount_points.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"
using base::FilePath; using base::FilePath;
using storage::FileSystemURL; using storage::FileSystemURL;
...@@ -360,7 +361,7 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) { ...@@ -360,7 +361,7 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
mount_points->CreateExternalFileSystemURL( mount_points->CreateExternalFileSystemURL(
GURL(), "crostini_0123456789abcdef_termina_penguin", url::Origin(), "crostini_0123456789abcdef_termina_penguin",
base::FilePath("path/in/crostini")), base::FilePath("path/in/crostini")),
&inside)); &inside));
EXPECT_EQ("/home/testuser/path/in/crostini", inside.value()); EXPECT_EQ("/home/testuser/path/in/crostini", inside.value());
...@@ -368,20 +369,20 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) { ...@@ -368,20 +369,20 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
EXPECT_FALSE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_FALSE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
mount_points->CreateExternalFileSystemURL( mount_points->CreateExternalFileSystemURL(
GURL(), "unknown", base::FilePath("path/in/unknown")), url::Origin(), "unknown", base::FilePath("path/in/unknown")),
&inside)); &inside));
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
mount_points->CreateExternalFileSystemURL( mount_points->CreateExternalFileSystemURL(
GURL(), "android_files", base::FilePath("path/in/android")), url::Origin(), "android_files", base::FilePath("path/in/android")),
&inside)); &inside));
EXPECT_EQ("/mnt/chromeos/PlayFiles/path/in/android", inside.value()); EXPECT_EQ("/mnt/chromeos/PlayFiles/path/in/android", inside.value());
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
mount_points->CreateExternalFileSystemURL( mount_points->CreateExternalFileSystemURL(
GURL(), "drivefs-84675c855b63e12f384d45f033826980", url::Origin(), "drivefs-84675c855b63e12f384d45f033826980",
base::FilePath("root/path/in/mydrive")), base::FilePath("root/path/in/mydrive")),
&inside)); &inside));
EXPECT_EQ("/mnt/chromeos/GoogleDrive/MyDrive/path/in/mydrive", EXPECT_EQ("/mnt/chromeos/GoogleDrive/MyDrive/path/in/mydrive",
...@@ -390,7 +391,7 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) { ...@@ -390,7 +391,7 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
mount_points->CreateExternalFileSystemURL( mount_points->CreateExternalFileSystemURL(
GURL(), "drivefs-84675c855b63e12f384d45f033826980", url::Origin(), "drivefs-84675c855b63e12f384d45f033826980",
base::FilePath("team_drives/path/in/teamdrives")), base::FilePath("team_drives/path/in/teamdrives")),
&inside)); &inside));
EXPECT_EQ("/mnt/chromeos/GoogleDrive/SharedDrives/path/in/teamdrives", EXPECT_EQ("/mnt/chromeos/GoogleDrive/SharedDrives/path/in/teamdrives",
...@@ -399,7 +400,7 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) { ...@@ -399,7 +400,7 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
mount_points->CreateExternalFileSystemURL( mount_points->CreateExternalFileSystemURL(
GURL(), "drivefs-84675c855b63e12f384d45f033826980", url::Origin(), "drivefs-84675c855b63e12f384d45f033826980",
base::FilePath("Computers/path/in/computers")), base::FilePath("Computers/path/in/computers")),
&inside)); &inside));
EXPECT_EQ("/mnt/chromeos/GoogleDrive/Computers/path/in/computers", EXPECT_EQ("/mnt/chromeos/GoogleDrive/Computers/path/in/computers",
...@@ -408,7 +409,8 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) { ...@@ -408,7 +409,8 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
mount_points->CreateExternalFileSystemURL( mount_points->CreateExternalFileSystemURL(
GURL(), "removable", base::FilePath("MyUSB/path/in/removable")), url::Origin(), "removable",
base::FilePath("MyUSB/path/in/removable")),
&inside)); &inside));
EXPECT_EQ("/mnt/chromeos/removable/MyUSB/path/in/removable", EXPECT_EQ("/mnt/chromeos/removable/MyUSB/path/in/removable",
inside.value()); inside.value());
...@@ -422,7 +424,7 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) { ...@@ -422,7 +424,7 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
mount_points->CreateExternalFileSystemURL( mount_points->CreateExternalFileSystemURL(
GURL(), "Downloads-testing_profile-hash", url::Origin(), "Downloads-testing_profile-hash",
base::FilePath("path/in/myfiles")), base::FilePath("path/in/myfiles")),
&inside)); &inside));
EXPECT_EQ("/mnt/chromeos/MyFiles/path/in/myfiles", inside.value()); EXPECT_EQ("/mnt/chromeos/MyFiles/path/in/myfiles", inside.value());
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "components/arc/mojom/file_system.mojom.h" #include "components/arc/mojom/file_system.mojom.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "storage/browser/file_system/external_mount_points.h" #include "storage/browser/file_system/external_mount_points.h"
#include "url/origin.h"
using content::BrowserThread; using content::BrowserThread;
...@@ -44,10 +45,10 @@ const char* kMediaDocumentsProviderRootIds[] = { ...@@ -44,10 +45,10 @@ const char* kMediaDocumentsProviderRootIds[] = {
}; };
base::FilePath GetRelativeMountPath(const std::string& root_id) { base::FilePath GetRelativeMountPath(const std::string& root_id) {
base::FilePath mount_path = arc::GetDocumentsProviderMountPath( base::FilePath mount_path =
kMediaDocumentsProviderAuthority, arc::GetDocumentsProviderMountPath(kMediaDocumentsProviderAuthority,
// In MediaDocumentsProvider, |root_id| and |root_document_id| are // In MediaDocumentsProvider, |root_id|
// the same. // and |root_document_id| are the same.
root_id); root_id);
base::FilePath relative_mount_path; base::FilePath relative_mount_path;
base::FilePath(arc::kDocumentsProviderMountPointPath) base::FilePath(arc::kDocumentsProviderMountPointPath)
...@@ -284,8 +285,8 @@ RecentArcMediaSource::MediaRoot::BuildDocumentsProviderUrl( ...@@ -284,8 +285,8 @@ RecentArcMediaSource::MediaRoot::BuildDocumentsProviderUrl(
storage::ExternalMountPoints::GetSystemInstance(); storage::ExternalMountPoints::GetSystemInstance();
return mount_points->CreateExternalFileSystemURL( return mount_points->CreateExternalFileSystemURL(
params_.value().origin(), arc::kDocumentsProviderMountPointName, url::Origin::Create(params_.value().origin()),
relative_mount_path_.Append(path)); arc::kDocumentsProviderMountPointName, relative_mount_path_.Append(path));
} }
bool RecentArcMediaSource::MediaRoot::MatchesFileType( bool RecentArcMediaSource::MediaRoot::MatchesFileType(
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "storage/browser/file_system/file_system_operation.h" #include "storage/browser/file_system/file_system_operation.h"
#include "storage/browser/file_system/file_system_operation_runner.h" #include "storage/browser/file_system/file_system_operation_runner.h"
#include "storage/browser/file_system/file_system_url.h" #include "storage/browser/file_system/file_system_url.h"
#include "url/origin.h"
using content::BrowserThread; using content::BrowserThread;
...@@ -262,8 +263,8 @@ storage::FileSystemURL RecentDiskSource::BuildDiskURL( ...@@ -262,8 +263,8 @@ storage::FileSystemURL RecentDiskSource::BuildDiskURL(
storage::ExternalMountPoints* mount_points = storage::ExternalMountPoints* mount_points =
storage::ExternalMountPoints::GetSystemInstance(); storage::ExternalMountPoints::GetSystemInstance();
return mount_points->CreateExternalFileSystemURL(params_.value().origin(), return mount_points->CreateExternalFileSystemURL(
mount_point_name_, path); url::Origin::Create(params_.value().origin()), mount_point_name_, path);
} }
} // namespace chromeos } // namespace chromeos
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "storage/browser/file_system/file_observers.h" #include "storage/browser/file_system/file_observers.h"
#include "storage/browser/file_system/file_system_context.h" #include "storage/browser/file_system/file_system_context.h"
#include "storage/common/file_system/file_system_util.h" #include "storage/common/file_system/file_system_util.h"
#include "url/origin.h"
using storage::ExternalMountPoints; using storage::ExternalMountPoints;
using storage::FileSystemContext; using storage::FileSystemContext;
...@@ -34,15 +35,12 @@ const base::FilePath::CharType kSyncFileSystemDir[] = ...@@ -34,15 +35,12 @@ const base::FilePath::CharType kSyncFileSystemDir[] =
void RegisterSyncableFileSystem() { void RegisterSyncableFileSystem() {
ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
kSyncableMountName, kSyncableMountName, storage::kFileSystemTypeSyncable,
storage::kFileSystemTypeSyncable, storage::FileSystemMountOption(), base::FilePath());
storage::FileSystemMountOption(),
base::FilePath());
ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
kSyncableMountNameForInternalSync, kSyncableMountNameForInternalSync,
storage::kFileSystemTypeSyncableForInternalSync, storage::kFileSystemTypeSyncableForInternalSync,
storage::FileSystemMountOption(), storage::FileSystemMountOption(), base::FilePath());
base::FilePath());
} }
void RevokeSyncableFileSystem() { void RevokeSyncableFileSystem() {
...@@ -64,14 +62,14 @@ FileSystemURL CreateSyncableFileSystemURL(const GURL& origin, ...@@ -64,14 +62,14 @@ FileSystemURL CreateSyncableFileSystemURL(const GURL& origin,
path_for_url = base::FilePath(path.value().substr(1)); path_for_url = base::FilePath(path.value().substr(1));
return ExternalMountPoints::GetSystemInstance()->CreateExternalFileSystemURL( return ExternalMountPoints::GetSystemInstance()->CreateExternalFileSystemURL(
origin, kSyncableMountName, path_for_url); url::Origin::Create(origin), kSyncableMountName, path_for_url);
} }
FileSystemURL CreateSyncableFileSystemURLForSync( FileSystemURL CreateSyncableFileSystemURLForSync(
storage::FileSystemContext* file_system_context, storage::FileSystemContext* file_system_context,
const FileSystemURL& syncable_url) { const FileSystemURL& syncable_url) {
return ExternalMountPoints::GetSystemInstance()->CreateExternalFileSystemURL( return ExternalMountPoints::GetSystemInstance()->CreateExternalFileSystemURL(
syncable_url.origin().GetURL(), kSyncableMountNameForInternalSync, syncable_url.origin(), kSyncableMountNameForInternalSync,
syncable_url.path()); syncable_url.path());
} }
...@@ -84,8 +82,8 @@ bool SerializeSyncableFileSystemURL(const FileSystemURL& url, ...@@ -84,8 +82,8 @@ bool SerializeSyncableFileSystemURL(const FileSystemURL& url,
return true; return true;
} }
bool DeserializeSyncableFileSystemURL( bool DeserializeSyncableFileSystemURL(const std::string& serialized_url,
const std::string& serialized_url, FileSystemURL* url) { FileSystemURL* url) {
#if !defined(FILE_PATH_USES_WIN_SEPARATORS) #if !defined(FILE_PATH_USES_WIN_SEPARATORS)
DCHECK(serialized_url.find('\\') == std::string::npos); DCHECK(serialized_url.find('\\') == std::string::npos);
#endif // FILE_PATH_USES_WIN_SEPARATORS #endif // FILE_PATH_USES_WIN_SEPARATORS
......
...@@ -55,8 +55,8 @@ TEST(BrowserFileSystemHelperTest, ...@@ -55,8 +55,8 @@ TEST(BrowserFileSystemHelperTest,
kMountName, storage::FileSystemType::kFileSystemTypeTest, kMountName, storage::FileSystemType::kFileSystemTypeTest,
storage::FileSystemMountOption(), mount_path)); storage::FileSystemMountOption(), mount_path));
storage::FileSystemURL original_file = storage::FileSystemURL original_file =
external_mount_points->CreateExternalFileSystemURL(kSensitiveOrigin, external_mount_points->CreateExternalFileSystemURL(
kMountName, kTestPath); url::Origin::Create(kSensitiveOrigin), kMountName, kTestPath);
EXPECT_TRUE(original_file.is_valid()); EXPECT_TRUE(original_file.is_valid());
EXPECT_EQ(kSensitiveOrigin, original_file.origin().GetURL()); EXPECT_EQ(kSensitiveOrigin, original_file.origin().GetURL());
......
...@@ -232,11 +232,11 @@ base::FilePath ExternalMountPoints::CreateVirtualRootPath( ...@@ -232,11 +232,11 @@ base::FilePath ExternalMountPoints::CreateVirtualRootPath(
} }
FileSystemURL ExternalMountPoints::CreateExternalFileSystemURL( FileSystemURL ExternalMountPoints::CreateExternalFileSystemURL(
const GURL& origin, const url::Origin& origin,
const std::string& mount_name, const std::string& mount_name,
const base::FilePath& path) const { const base::FilePath& path) const {
return CreateCrackedFileSystemURL( return CreateCrackedFileSystemURL(
url::Origin::Create(origin), storage::kFileSystemTypeExternal, origin, storage::kFileSystemTypeExternal,
// Avoid using FilePath::Append as path may be an absolute path. // Avoid using FilePath::Append as path may be an absolute path.
base::FilePath(CreateVirtualRootPath(mount_name).value() + base::FilePath(CreateVirtualRootPath(mount_name).value() +
base::FilePath::kSeparators[0] + path.value())); base::FilePath::kSeparators[0] + path.value()));
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "storage/browser/file_system/mount_points.h" #include "storage/browser/file_system/mount_points.h"
#include "storage/common/file_system/file_system_mount_option.h" #include "storage/common/file_system/file_system_mount_option.h"
#include "storage/common/file_system/file_system_types.h" #include "storage/common/file_system/file_system_types.h"
#include "url/origin.h"
namespace base { namespace base {
class FilePath; class FilePath;
...@@ -106,7 +107,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) ExternalMountPoints ...@@ -106,7 +107,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) ExternalMountPoints
// Returns the virtual root path that looks like /<mount_name>. // Returns the virtual root path that looks like /<mount_name>.
base::FilePath CreateVirtualRootPath(const std::string& mount_name) const; base::FilePath CreateVirtualRootPath(const std::string& mount_name) const;
FileSystemURL CreateExternalFileSystemURL(const GURL& origin, FileSystemURL CreateExternalFileSystemURL(const url::Origin& origin,
const std::string& mount_name, const std::string& mount_name,
const base::FilePath& path) const; const base::FilePath& path) const;
......
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