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

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: fixing unit tests and feedback 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 | ui/base/win/open_file_name_win_unittest.cc » ('j') | 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..3914fa5cfae43951dc8ace26a60bf10565df7345 100644
--- a/ui/base/win/open_file_name_win.cc
+++ b/ui/base/win/open_file_name_win.cc
@@ -151,10 +151,19 @@ void OpenFileName::GetResult(base::FilePath* directory,
std::vector<base::FilePath>* filenames) {
DCHECK(filenames->empty());
const wchar_t* selection = openfilename_.lpstrFile;
- while (*selection) { // Empty string indicates end of list.
+ // 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.
+ if (openfilename_.Flags & OFN_ALLOWMULTISELECT) {
+ while (*selection) { // Empty string indicates end of list.
+ filenames->push_back(base::FilePath(selection));
+ // Skip over filename and null-terminator.
+ selection += filenames->back().value().length() + 1;
+ }
+ } else {
filenames->push_back(base::FilePath(selection));
- // Skip over filename and null-terminator.
- selection += filenames->back().value().length() + 1;
}
if (filenames->size() == 1) {
// When there is one file, it contains the path and filename.
« no previous file with comments | « no previous file | ui/base/win/open_file_name_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698