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

Unified Diff: ui/base/win/open_file_name_win.cc

Issue 618503002: Fix the open file dialog on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/open_file_name_win.cc
diff --git a/ui/base/win/open_file_name_win.cc b/ui/base/win/open_file_name_win.cc
index 5b78a8e465198fd5376da96af3bcc7b4bd0dc625..a5526fc1a1ca553554da4407a11ef9bb1d4c4891 100644
--- a/ui/base/win/open_file_name_win.cc
+++ b/ui/base/win/open_file_name_win.cc
@@ -139,17 +139,26 @@ void OpenFileName::MaybeInstallWindowPositionHookForSaveAsOnXP() {
}
base::FilePath OpenFileName::GetSingleResult() {
sky 2014/09/29 23:53:03 I would rather we always do the right thing here,
luken 2014/09/30 17:25:07 Agreed, your idea is better. I've refactored to ju
- base::FilePath directory;
- std::vector<base::FilePath> filenames;
- GetResult(&directory, &filenames);
- if (filenames.size() != 1)
- return base::FilePath();
- return directory.Append(filenames[0]);
+ // The return value of |openfilename_.lpstrFile| is dependent on the
+ // value of the Multi-Select flag within |openfilename_|. If the flag is
+ // not set the return value will be a single null-terminated wide string.
+ // If it is set it will be more than one null-terminated wide string, itself
+ // terminated by an empty null-terminated wide string. We assert that
+ // GetSingleResult() is assuming there is only a single result to return.
+ DCHECK_EQ(0U, openfilename_.Flags & OFN_ALLOWMULTISELECT);
+ return base::FilePath(openfilename_.lpstrFile);
}
void OpenFileName::GetResult(base::FilePath* directory,
std::vector<base::FilePath>* filenames) {
DCHECK(filenames->empty());
+ // The return value of |openfilename_.lpstrFile| is dependent on the
sky 2014/09/29 23:53:03 nit: don't duplicate almost the whole comment. Do
luken 2014/09/30 17:25:07 Done.
+ // value of the Multi-Select flag within |openfilename_|. If the flag is
+ // not set the return value will be a single null-terminated wide string.
+ // If it is set it will be more than one null-terminated wide string, itself
+ // terminated by an empty null-terminated wide string. We assert that
+ // GetResult() is assuming there is more than one result to return.
+ DCHECK_NE(0U, openfilename_.Flags & OFN_ALLOWMULTISELECT);
const wchar_t* selection = openfilename_.lpstrFile;
while (*selection) { // Empty string indicates end of list.
filenames->push_back(base::FilePath(selection));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698