Commit 5092f4c7 authored by hirono's avatar hirono Committed by Commit bot

Stop fallback for empty local path in ui::SelectedFileInfo's constructor.

Previously ui::SelectedFileInfo's constructor has a fallback to use the file
path instead of an emtpy local path. But this fallback can assign non-native
paths like '/special/drive/xxx' to local_path variable when the file does not
have a snapshot.

The CL removes the fallback, and modify the default behavior of
FileSelectDialog::Lister so that it routes an empty local_path to file_path.

BUG=126902
TEST=manually

Review URL: https://codereview.chromium.org/666693004

Cr-Commit-Position: refs/heads/master@{#300628}
parent d1d50225
......@@ -119,7 +119,10 @@ void GetSelectedFileInfoInternal(Profile* profile,
// MTP, or provided file system), we should resolve the path.
switch (params->local_path_option) {
case NO_LOCAL_PATH_RESOLUTION:
break; // No special handling needed.
// Pass empty local path.
params->selected_files.push_back(
ui::SelectedFileInfo(file_path, base::FilePath()));
break;
case NEED_LOCAL_PATH_FOR_OPENING:
GetFileNativeLocalPathForOpening(
profile,
......@@ -137,9 +140,10 @@ void GetSelectedFileInfoInternal(Profile* profile,
base::Passed(&params)));
return; // Remaining work is done in ContinueGetSelectedFileInfo.
}
} else {
params->selected_files.push_back(
ui::SelectedFileInfo(file_path, file_path));
}
params->selected_files.push_back(
ui::SelectedFileInfo(file_path, base::FilePath()));
}
params->callback.Run(params->selected_files);
}
......
......@@ -46,7 +46,10 @@ void SelectFileDialog::Listener::FileSelectedWithExtraInfo(
int index,
void* params) {
// Most of the dialogs need actual local path, so default to it.
FileSelected(file.local_path, index, params);
// If local path is empty, use file_path instead.
FileSelected(file.local_path.empty() ? file.file_path : file.local_path,
index,
params);
}
void SelectFileDialog::Listener::MultiFilesSelectedWithExtraInfo(
......@@ -54,7 +57,8 @@ void SelectFileDialog::Listener::MultiFilesSelectedWithExtraInfo(
void* params) {
std::vector<base::FilePath> file_paths;
for (size_t i = 0; i < files.size(); ++i)
file_paths.push_back(files[i].local_path);
file_paths.push_back(files[i].local_path.empty() ? files[i].file_path
: files[i].local_path);
MultiFilesSelected(file_paths, params);
}
......
......@@ -12,8 +12,6 @@ SelectedFileInfo::SelectedFileInfo(const base::FilePath& in_file_path,
const base::FilePath& in_local_path)
: file_path(in_file_path),
local_path(in_local_path) {
if (local_path.empty())
local_path = file_path;
display_name = in_file_path.BaseName().value();
}
......
......@@ -20,10 +20,9 @@ struct SHELL_DIALOGS_EXPORT SelectedFileInfo {
// The actual local path to the selected file. This can be a snapshot file
// with a human unreadable name like /blah/.d41d8cd98f00b204e9800998ecf8427e.
// |real_path| can differ from |file_path| for drive files (e.g.
// |local_path| can differ from |file_path| for drive files (e.g.
// /drive_cache/temporary/d41d8cd98f00b204e9800998ecf8427e vs.
// /special/drive/foo.txt).
// If not set, defaults to |file_path|.
base::FilePath local_path;
// This field is optional. The display name contains only the base name
......@@ -41,4 +40,3 @@ struct SHELL_DIALOGS_EXPORT SelectedFileInfo {
} // namespace ui
#endif // UI_SHELL_DIALOGS_SELECTED_FILE_INFO_H_
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