Chromium Code Reviews| 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)); |