Index: chrome/browser/ui/views/select_file_dialog_extension.cc |
diff --git a/chrome/browser/ui/views/select_file_dialog_extension.cc b/chrome/browser/ui/views/select_file_dialog_extension.cc |
index 0b7bb25bbf7d99878e61295816c3e367fa58af8e..0d283dc747a16c1c7c2f48a6c28c3242f2d85922 100644 |
--- a/chrome/browser/ui/views/select_file_dialog_extension.cc |
+++ b/chrome/browser/ui/views/select_file_dialog_extension.cc |
@@ -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(); |
} |