Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4558)

Unified Diff: chrome/browser/ui/views/select_file_dialog_win.cc

Issue 10697010: Make saving files from flash less annoying. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/select_file_dialog_win.cc
===================================================================
--- chrome/browser/ui/views/select_file_dialog_win.cc (revision 144786)
+++ chrome/browser/ui/views/select_file_dialog_win.cc (working copy)
@@ -77,6 +77,13 @@
}
}
+// Distinguish directories from regular files.
+bool IsDirectory(const FilePath& path) {
+ base::PlatformFileInfo file_info;
+ return file_util::GetFileInfo(path, &file_info) ?
+ file_info.is_directory : file_util::EndsWithSeparator(path);
+}
+
} // namespace
// This function takes the output of a SaveAs dialog: a filename, a filter and
@@ -332,8 +339,14 @@
// Set up the initial directory for the dialog.
std::wstring directory;
- if (!suggested_name.empty())
- directory = suggested_path.DirName().value();
+ if (!suggested_name.empty()) {
+ if (IsDirectory(suggested_path)) {
+ directory = suggested_path.value();
+ file_part.clear();
+ } else {
+ directory = suggested_path.DirName().value();
+ }
+ }
save_as.lpstrInitialDir = directory.c_str();
save_as.lpstrTitle = NULL;
@@ -762,13 +775,7 @@
FilePath dir;
// Use lpstrInitialDir to specify the initial directory
if (!path->empty()) {
- bool is_dir;
- base::PlatformFileInfo file_info;
- if (file_util::GetFileInfo(*path, &file_info))
- is_dir = file_info.is_directory;
- else
- is_dir = file_util::EndsWithSeparator(*path);
- if (is_dir) {
+ if (IsDirectory(*path)) {
ofn.lpstrInitialDir = path->value().c_str();
} else {
dir = path->DirName();

Powered by Google App Engine
This is Rietveld 408576698