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