Commit 537cfb7c authored by kinaba@chromium.org's avatar kinaba@chromium.org

Use last_selected_directory() when invalid path is passed to CrOS file picker.

This is for working around the case when <input type="file"/> control is used
twice; CrOS file picker kindly resolves a remote file path to a local cache
and the type=file control tries to default to the path, but the cache path
itself is out of user-visible directory. In such a case, we just use the
last_selected_directory(), rather than going back to the very default directory.

BUG=178013

Review URL: https://chromiumcodereview.appspot.com/13614002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192492 0039d316-1c4b-4281-b951-d872f2087c98
parent 8273a85b
......@@ -321,10 +321,20 @@ void SelectFileDialogExtension::SelectFileImpl(
}
base::FilePath virtual_path;
if (file_manager_util::ConvertFileToRelativeFileSystemPath(
profile_, kFileBrowserDomain, default_dialog_path, &virtual_path)) {
// If an absolute path is specified as the default path, convert it to the
// virtual path in the file browser extension. Due to the current design,
// an invalid temporal cache file path may passed as |default_dialog_path|
// (crbug.com/178013 #9-#11). In such a case, we use the last selected
// directory as a workaround. Real fix is tracked at crbug.com/110119.
if (default_dialog_path.IsAbsolute() &&
(file_manager_util::ConvertFileToRelativeFileSystemPath(
profile_, kFileBrowserDomain, default_dialog_path, &virtual_path) ||
file_manager_util::ConvertFileToRelativeFileSystemPath(
profile_, kFileBrowserDomain, profile_->last_selected_directory(),
&virtual_path))) {
virtual_path = base::FilePath("/").Append(virtual_path);
} else {
// If the path was relative, or failed to convert, just use the base name,
virtual_path = default_dialog_path.BaseName();
}
......
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