Commit 786c9a15 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Remove distinction between drive and native paths

With the legacy drive sync client, drive paths had to be treated
separately from native paths in certain situations. However, since now
with DriveFS all drive paths are native, this separation can be removed.

Bug: 1003238
Change-Id: I3fbbfaf5456b292c24c3f3b3c1ea8ef253101285
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930274
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718997}
parent c9504a9b
......@@ -99,8 +99,7 @@ void CrostiniExportImport::OpenFileDialog(ExportImportType type,
unsigned title = 0;
base::FilePath default_path;
ui::SelectFileDialog::FileTypeInfo file_types;
file_types.allowed_paths =
ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH;
file_types.allowed_paths = ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH;
file_types.extensions = {{"tini", "tar.gz", "tgz"}};
switch (type) {
......
......@@ -190,10 +190,6 @@ bool IsAllowedSource(storage::FileSystemType type,
case api::file_manager_private::SOURCE_RESTRICTION_NATIVE_SOURCE:
return type == storage::kFileSystemTypeNativeLocal;
case api::file_manager_private::SOURCE_RESTRICTION_NATIVE_OR_DRIVE_SOURCE:
return type == storage::kFileSystemTypeNativeLocal ||
type == storage::kFileSystemTypeDrive;
}
}
......
......@@ -20,7 +20,7 @@ namespace util {
namespace {
const char kAllowedPaths[] = "allowedPaths";
const char kNativeOrDrivePath[] = "nativeOrDrivePath";
const char kNativePath[] = "nativePath";
const char kAnyPath[] = "anyPath";
const char kAnyPathOrUrl[] = "anyPathOrUrl";
......@@ -115,13 +115,10 @@ GURL GetFileManagerMainPageUrlWithParams(
arg_value.SetBoolean("includeAllFiles", file_types->include_all_files);
}
// If the caller cannot handle Drive path, the file chooser dialog need to
// return resolved local native paths to the selected files.
if (file_types) {
switch (file_types->allowed_paths) {
case ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH:
case ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH:
arg_value.SetString(kAllowedPaths, kNativeOrDrivePath);
arg_value.SetString(kAllowedPaths, kNativePath);
break;
case ui::SelectFileDialog::FileTypeInfo::ANY_PATH:
arg_value.SetString(kAllowedPaths, kAnyPath);
......@@ -131,7 +128,7 @@ GURL GetFileManagerMainPageUrlWithParams(
break;
}
} else {
arg_value.SetString(kAllowedPaths, kNativeOrDrivePath);
arg_value.SetString(kAllowedPaths, kNativePath);
}
std::string json_args;
......
......@@ -61,7 +61,7 @@ TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) {
// With DriveFS, Drive is always allowed where native paths are.
EXPECT_EQ(base::StringPrintf(
"{\n"
" \"allowedPaths\": \"nativeOrDrivePath\",\n"
" \"allowedPaths\": \"nativePath\",\n"
" \"currentDirectoryURL\": "
"\"filesystem:chrome-extension://abc/Downloads/\",\n"
" \"defaultExtension\": \"txt\",\n"
......
......@@ -56,7 +56,7 @@ DownloadFilePicker::DownloadFilePicker(DownloadItem* item,
}
file_type_info.include_all_files = true;
file_type_info.allowed_paths =
ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH;
ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH;
gfx::NativeWindow owning_window =
web_contents ? platform_util::GetTopLevel(web_contents->GetNativeView())
: gfx::kNullNativeWindow;
......
......@@ -145,7 +145,7 @@ SavePackageFilePicker::SavePackageFilePicker(
ui::SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.allowed_paths =
ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH;
ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH;
if (can_save_as_complete_) {
// The option index is not zero-based. Put a dummy entry.
......
......@@ -98,7 +98,7 @@ void DownloadsHandler::HandleSelectDownloadLocation(
this,
std::make_unique<ChromeSelectFilePolicy>(web_ui()->GetWebContents()));
ui::SelectFileDialog::FileTypeInfo info;
info.allowed_paths = ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH;
info.allowed_paths = ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH;
select_folder_dialog_->SelectFile(
ui::SelectFileDialog::SELECT_FOLDER,
l10n_util::GetStringUTF16(IDS_SETTINGS_DOWNLOAD_LOCATION),
......
......@@ -223,10 +223,7 @@ enum SourceRestriction {
any_source,
// Allows source with native local file system only.
native_source,
// Allows native source and Drive source.
native_or_drive_source
native_source
};
enum CrostiniEventType {
......
......@@ -239,7 +239,6 @@ chrome.fileManagerPrivate.Verb = {
chrome.fileManagerPrivate.SourceRestriction = {
ANY_SOURCE: 'any_source',
NATIVE_SOURCE: 'native_source',
NATIVE_OR_DRIVE_SOURCE: 'native_or_drive_source',
};
/** @enum {string} */
......
......@@ -116,10 +116,6 @@ class FilteredVolumeManager extends cr.EventTarget {
case AllowedPaths.ANY_PATH:
case AllowedPaths.ANY_PATH_OR_URL:
return true;
case AllowedPaths.NATIVE_OR_DRIVE_PATH:
return (
VolumeManagerCommon.VolumeType.isNative(volumeType) ||
volumeType == VolumeManagerCommon.VolumeType.DRIVE);
case AllowedPaths.NATIVE_PATH:
return VolumeManagerCommon.VolumeType.isNative(volumeType);
}
......
......@@ -14,7 +14,6 @@ const VolumeManagerCommon = {};
*/
const AllowedPaths = {
NATIVE_PATH: 'nativePath',
NATIVE_OR_DRIVE_PATH: 'nativeOrDrivePath',
ANY_PATH: 'anyPath',
ANY_PATH_OR_URL: 'anyPathOrUrl',
};
......@@ -239,6 +238,7 @@ VolumeManagerCommon.Source = {
*/
VolumeManagerCommon.VolumeType.isNative = type => {
return type === VolumeManagerCommon.VolumeType.DOWNLOADS ||
type === VolumeManagerCommon.VolumeType.DRIVE ||
type === VolumeManagerCommon.VolumeType.ANDROID_FILES ||
type === VolumeManagerCommon.VolumeType.CROSTINI ||
type === VolumeManagerCommon.VolumeType.REMOVABLE ||
......
......@@ -1480,12 +1480,10 @@ class FileManager extends cr.EventTarget {
// The native implementation of the Files app creates snapshot files for
// non-native files. But it does not work for folders (e.g., dialog for
// loading unpacked extensions).
if ((allowedPaths === AllowedPaths.NATIVE_PATH ||
allowedPaths === AllowedPaths.NATIVE_OR_DRIVE_PATH) &&
if (allowedPaths === AllowedPaths.NATIVE_PATH &&
!DialogType.isFolderDialog(this.launchParams_.type)) {
if (this.launchParams_.type == DialogType.SELECT_SAVEAS_FILE) {
// Only drive can create snapshot files for saving.
allowedPaths = AllowedPaths.NATIVE_OR_DRIVE_PATH;
allowedPaths = AllowedPaths.NATIVE_PATH;
} else {
allowedPaths = AllowedPaths.ANY_PATH;
}
......@@ -1503,9 +1501,6 @@ class FileManager extends cr.EventTarget {
if (allowedPaths == AllowedPaths.NATIVE_PATH) {
return chrome.fileManagerPrivate.SourceRestriction.NATIVE_SOURCE;
}
if (allowedPaths == AllowedPaths.NATIVE_OR_DRIVE_PATH) {
return chrome.fileManagerPrivate.SourceRestriction.NATIVE_OR_DRIVE_SOURCE;
}
return chrome.fileManagerPrivate.SourceRestriction.ANY_SOURCE;
}
......
......@@ -63,7 +63,6 @@ chrome.fileManagerPrivate = {
token_: 'token',
SourceRestriction: {
ANY_SOURCE: 'any_source',
NATIVE_OR_DRIVE_SOURCE: 'native_or_drive_source',
NATIVE_SOURCE: 'native_source',
},
addFileWatch: (entry, callback) => {
......
......@@ -144,7 +144,6 @@ class SHELL_DIALOGS_EXPORT SelectFileDialog
enum AllowedPaths {
ANY_PATH,
NATIVE_PATH,
NATIVE_OR_DRIVE_PATH,
ANY_PATH_OR_URL
};
AllowedPaths allowed_paths;
......
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