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