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

Side by Side Diff: ui/base/win/open_file_name_win.h

Issue 426673003: Introduce a helper for OPENFILENAME struct to make certain logic testable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unittests. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/ui_base.gyp ('k') | ui/base/win/open_file_name_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_
6 #define UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_
7
8 #include <Windows.h>
9 #include <Commdlg.h>
10
11 #include <vector>
12
13 #include "base/macros.h"
14 #include "base/strings/string16.h"
15 #include "base/tuple.h"
16
17 namespace base {
18 class FilePath;
19 } // namespace base
20
21 namespace ui {
22 namespace win {
23
24 // Encapsulates an OPENFILENAME struct and related buffers. Also provides static
25 // methods for interpreting the properties of an OPENFILENAME.
26 class OpenFileName {
27 public:
28 // Initializes the OPENFILENAME, which may be accessed using Get(). All fields
29 // will be NULL except for |lStructSize|, |lpstrFile|, and |nMaxFile|. The
30 // file buffer will initially contain a null-terminated empty string.
31 OpenFileName(HWND parent_window, DWORD flags);
32 ~OpenFileName();
33
34 // Sets |lpstrInitialDir| and |lpstrFile|.
35 void SetInitialSelection(const base::FilePath& initial_directory,
36 const base::FilePath& initial_filename);
37
38 // Returns the single selected file, or an empty path if there are more or
39 // less than one results.
40 base::FilePath GetSingleResult();
41
42 // Returns the selected file or files.
43 void GetResult(base::FilePath* directory,
sky 2014/07/31 16:27:31 const FilePath&? Also, is there a reason you separ
erikwright (departed) 2014/07/31 16:39:29 Both parameters are out-parameters, unless this is
44 std::vector<base::FilePath>* filenames);
45
46 // Returns the OPENFILENAME structure.
47 OPENFILENAME* Get();
sky 2014/07/31 16:27:31 nit: inline this and name it name it to match fiel
erikwright (departed) 2014/08/01 13:26:09 Renamed to GetOPENFILENAME(). Which seems a little
48
49 private:
50 OPENFILENAME openfilename_;
51 base::string16 initial_directory_buffer_;
52 wchar_t filename_buffer_[UNICODE_STRING_MAX_CHARS];
53
54 DISALLOW_COPY_AND_ASSIGN(OpenFileName);
55 };
56
57 } // namespace win
58 } // namespace ui
59
60 #endif // UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_
OLDNEW
« no previous file with comments | « ui/base/ui_base.gyp ('k') | ui/base/win/open_file_name_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698