OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_ | 5 #ifndef UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_ |
6 #define UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_ | 6 #define UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_ |
7 | 7 |
8 #include <Windows.h> | 8 #include <Windows.h> |
9 #include <Commdlg.h> | 9 #include <Commdlg.h> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Encapsulates an OPENFILENAME struct and related buffers. Also provides static | 24 // Encapsulates an OPENFILENAME struct and related buffers. Also provides static |
25 // methods for interpreting the properties of an OPENFILENAME. | 25 // methods for interpreting the properties of an OPENFILENAME. |
26 class OpenFileName { | 26 class OpenFileName { |
27 public: | 27 public: |
28 // Initializes the OPENFILENAME, which may be accessed using Get(). All fields | 28 // Initializes the OPENFILENAME, which may be accessed using Get(). All fields |
29 // will be NULL except for |lStructSize|, |lpstrFile|, and |nMaxFile|. The | 29 // will be NULL except for |lStructSize|, |lpstrFile|, and |nMaxFile|. The |
30 // file buffer will initially contain a null-terminated empty string. | 30 // file buffer will initially contain a null-terminated empty string. |
31 OpenFileName(HWND parent_window, DWORD flags); | 31 OpenFileName(HWND parent_window, DWORD flags); |
32 ~OpenFileName(); | 32 ~OpenFileName(); |
33 | 33 |
| 34 // Initializes |lpstrFilter| from the label/pattern pairs in |filters|. |
| 35 void SetFilters( |
| 36 const std::vector<Tuple2<base::string16, base::string16> >& filters); |
| 37 |
34 // Sets |lpstrInitialDir| and |lpstrFile|. | 38 // Sets |lpstrInitialDir| and |lpstrFile|. |
35 void SetInitialSelection(const base::FilePath& initial_directory, | 39 void SetInitialSelection(const base::FilePath& initial_directory, |
36 const base::FilePath& initial_filename); | 40 const base::FilePath& initial_filename); |
37 | 41 |
38 // Returns the single selected file, or an empty path if there are more or | 42 // Returns the single selected file, or an empty path if there are more or |
39 // less than one results. | 43 // less than one results. |
40 base::FilePath GetSingleResult(); | 44 base::FilePath GetSingleResult(); |
41 | 45 |
42 // Returns the selected file or files. | 46 // Returns the selected file or files. |
43 void GetResult(base::FilePath* directory, | 47 void GetResult(base::FilePath* directory, |
44 std::vector<base::FilePath>* filenames); | 48 std::vector<base::FilePath>* filenames); |
45 | 49 |
46 // Returns the OPENFILENAME structure. | 50 // Returns the OPENFILENAME structure. |
47 OPENFILENAME* Get(); | 51 OPENFILENAME* Get(); |
48 | 52 |
| 53 // Returns the OPENFILENAME structure. |
| 54 const OPENFILENAME* Get() const; |
| 55 |
| 56 // Stores directory and filenames in the buffer pointed to by |
| 57 // |openfilename->lpstrFile| and sized |openfilename->nMaxFile|. |
| 58 static void SetResult(const base::FilePath& directory, |
| 59 const std::vector<base::FilePath>& filenames, |
| 60 OPENFILENAME* openfilename); |
| 61 |
| 62 // Returns a vector of label/pattern pairs built from |
| 63 // |openfilename->lpstrFilter|. |
| 64 static std::vector<Tuple2<base::string16, base::string16> > GetFilters( |
| 65 const OPENFILENAME* openfilename); |
| 66 |
49 private: | 67 private: |
50 OPENFILENAME openfilename_; | 68 OPENFILENAME openfilename_; |
51 base::string16 initial_directory_buffer_; | 69 base::string16 initial_directory_buffer_; |
52 wchar_t filename_buffer_[UNICODE_STRING_MAX_CHARS]; | 70 wchar_t filename_buffer_[UNICODE_STRING_MAX_CHARS]; |
| 71 base::string16 filter_buffer_; |
53 | 72 |
54 DISALLOW_COPY_AND_ASSIGN(OpenFileName); | 73 DISALLOW_COPY_AND_ASSIGN(OpenFileName); |
55 }; | 74 }; |
56 | 75 |
57 } // namespace win | 76 } // namespace win |
58 } // namespace ui | 77 } // namespace ui |
59 | 78 |
60 #endif // UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_ | 79 #endif // UI_BASE_WIN_OPEN_FILE_NAME_WIN_H_ |
OLD | NEW |