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

Unified Diff: ui/base/dialogs/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, 4 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
« no previous file with comments | « ui/base/dialogs/gtk/select_file_dialog_impl_gtk.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/dialogs/select_file_dialog_win.cc
===================================================================
--- ui/base/dialogs/select_file_dialog_win.cc (revision 151539)
+++ ui/base/dialogs/select_file_dialog_win.cc (working copy)
@@ -75,6 +75,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);
Ben Goodger (Google) 2012/08/14 23:06:54 4-space indent
Tom Sepez 2012/08/14 23:10:43 Done.
+}
+
// Get the file type description from the registry. This will be "Text Document"
// for .txt files, "JPEG Image" for .jpg files, etc. If the registry doesn't
// have an entry for the file type, we return false, true if the description was
@@ -286,8 +293,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;
@@ -715,13 +728,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();
« no previous file with comments | « ui/base/dialogs/gtk/select_file_dialog_impl_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698