OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_ | 4 #ifndef CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_ |
5 #define CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_ | 5 #define CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_ |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 | 13 |
14 class ChromeAppViewAsh; | 14 class ChromeAppViewAsh; |
15 struct MetroViewerHostMsg_SaveAsDialogParams; | 15 struct MetroViewerHostMsg_SaveAsDialogParams; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class FilePath; | 18 class FilePath; |
19 } | 19 } |
20 | 20 |
21 // Base class for the file pickers. | 21 // Base class for the file pickers. |
22 class FilePickerSessionBase { | 22 class FilePickerSessionBase { |
23 public: | 23 public: |
24 // Creates a file picker for open_file_name. | 24 // Creates a file picker for open_file_name. |
25 explicit FilePickerSessionBase(ChromeAppViewAsh* app_view, | 25 explicit FilePickerSessionBase(ChromeAppViewAsh* app_view, |
26 const string16& title, | 26 const base::string16& title, |
27 const string16& filter, | 27 const base::string16& filter, |
28 const base::FilePath& default_path); | 28 const base::FilePath& default_path); |
29 | 29 |
30 virtual ~FilePickerSessionBase() { | 30 virtual ~FilePickerSessionBase() { |
31 } | 31 } |
32 | 32 |
33 // Runs the picker, returns true on success. | 33 // Runs the picker, returns true on success. |
34 bool Run(); | 34 bool Run(); |
35 | 35 |
36 const string16& result() const { | 36 const base::string16& result() const { |
37 return result_; | 37 return result_; |
38 } | 38 } |
39 | 39 |
40 bool success() const { | 40 bool success() const { |
41 return success_; | 41 return success_; |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 // Creates, configures and starts a file picker. | 45 // Creates, configures and starts a file picker. |
46 // If the HRESULT returned is a failure code the file picker has not started, | 46 // If the HRESULT returned is a failure code the file picker has not started, |
47 // so no callbacks should be expected. | 47 // so no callbacks should be expected. |
48 virtual HRESULT StartFilePicker() = 0; | 48 virtual HRESULT StartFilePicker() = 0; |
49 | 49 |
50 // True iff a file picker has successfully finished. | 50 // True iff a file picker has successfully finished. |
51 bool success_; | 51 bool success_; |
52 | 52 |
53 // The title of the file picker. | 53 // The title of the file picker. |
54 string16 title_; | 54 base::string16 title_; |
55 | 55 |
56 // The file type filter. | 56 // The file type filter. |
57 string16 filter_; | 57 base::string16 filter_; |
58 | 58 |
59 // The starting directory/file name. | 59 // The starting directory/file name. |
60 base::FilePath default_path_; | 60 base::FilePath default_path_; |
61 | 61 |
62 // Pointer to the ChromeAppViewAsh instance. We notify the ChromeAppViewAsh | 62 // Pointer to the ChromeAppViewAsh instance. We notify the ChromeAppViewAsh |
63 // instance when the file open/save operations complete. | 63 // instance when the file open/save operations complete. |
64 ChromeAppViewAsh* app_view_; | 64 ChromeAppViewAsh* app_view_; |
65 | 65 |
66 string16 result_; | 66 base::string16 result_; |
67 | 67 |
68 private: | 68 private: |
69 // Initiate a file picker, must be called on the main metro thread. | 69 // Initiate a file picker, must be called on the main metro thread. |
70 // Returns true on success. | 70 // Returns true on success. |
71 bool DoFilePicker(); | 71 bool DoFilePicker(); |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(FilePickerSessionBase); | 73 DISALLOW_COPY_AND_ASSIGN(FilePickerSessionBase); |
74 }; | 74 }; |
75 | 75 |
76 // Provides functionality to display the open file/multiple open file pickers | 76 // Provides functionality to display the open file/multiple open file pickers |
77 // metro dialog. | 77 // metro dialog. |
78 class OpenFilePickerSession : public FilePickerSessionBase { | 78 class OpenFilePickerSession : public FilePickerSessionBase { |
79 public: | 79 public: |
80 explicit OpenFilePickerSession(ChromeAppViewAsh* app_view, | 80 explicit OpenFilePickerSession(ChromeAppViewAsh* app_view, |
81 const string16& title, | 81 const base::string16& title, |
82 const string16& filter, | 82 const base::string16& filter, |
83 const base::FilePath& default_path, | 83 const base::FilePath& default_path, |
84 bool allow_multi_select); | 84 bool allow_multi_select); |
85 | 85 |
86 const std::vector<base::FilePath>& filenames() const { | 86 const std::vector<base::FilePath>& filenames() const { |
87 return filenames_; | 87 return filenames_; |
88 } | 88 } |
89 | 89 |
90 const bool allow_multi_select() const { | 90 const bool allow_multi_select() const { |
91 return allow_multi_select_; | 91 return allow_multi_select_; |
92 } | 92 } |
(...skipping 10 matching lines...) Expand all Loading... |
103 | 103 |
104 // Called asynchronously when a single file picker is done. | 104 // Called asynchronously when a single file picker is done. |
105 HRESULT SinglePickerDone(SingleFileAsyncOp* async, AsyncStatus status); | 105 HRESULT SinglePickerDone(SingleFileAsyncOp* async, AsyncStatus status); |
106 | 106 |
107 // Called asynchronously when a multi file picker is done. | 107 // Called asynchronously when a multi file picker is done. |
108 HRESULT MultiPickerDone(MultiFileAsyncOp* async, AsyncStatus status); | 108 HRESULT MultiPickerDone(MultiFileAsyncOp* async, AsyncStatus status); |
109 | 109 |
110 // Composes a multi-file result string suitable for returning to a | 110 // Composes a multi-file result string suitable for returning to a |
111 // from a storage file collection. | 111 // from a storage file collection. |
112 static HRESULT ComposeMultiFileResult(StorageFileVectorCollection* files, | 112 static HRESULT ComposeMultiFileResult(StorageFileVectorCollection* files, |
113 string16* result); | 113 base::string16* result); |
114 | 114 |
115 private: | 115 private: |
116 // True if the multi file picker is to be displayed. | 116 // True if the multi file picker is to be displayed. |
117 bool allow_multi_select_; | 117 bool allow_multi_select_; |
118 // If multi select is true then this member contains the list of filenames | 118 // If multi select is true then this member contains the list of filenames |
119 // to be returned back. | 119 // to be returned back. |
120 std::vector<base::FilePath> filenames_; | 120 std::vector<base::FilePath> filenames_; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(OpenFilePickerSession); | 122 DISALLOW_COPY_AND_ASSIGN(OpenFilePickerSession); |
123 }; | 123 }; |
(...skipping 18 matching lines...) Expand all Loading... |
142 | 142 |
143 int filter_index_; | 143 int filter_index_; |
144 | 144 |
145 DISALLOW_COPY_AND_ASSIGN(SaveFilePickerSession); | 145 DISALLOW_COPY_AND_ASSIGN(SaveFilePickerSession); |
146 }; | 146 }; |
147 | 147 |
148 // Provides functionality to display the folder picker. | 148 // Provides functionality to display the folder picker. |
149 class FolderPickerSession : public FilePickerSessionBase { | 149 class FolderPickerSession : public FilePickerSessionBase { |
150 public: | 150 public: |
151 explicit FolderPickerSession(ChromeAppViewAsh* app_view, | 151 explicit FolderPickerSession(ChromeAppViewAsh* app_view, |
152 const string16& title); | 152 const base::string16& title); |
153 | 153 |
154 private: | 154 private: |
155 virtual HRESULT StartFilePicker() OVERRIDE; | 155 virtual HRESULT StartFilePicker() OVERRIDE; |
156 | 156 |
157 typedef winfoundtn::IAsyncOperation<winstorage::StorageFolder*> | 157 typedef winfoundtn::IAsyncOperation<winstorage::StorageFolder*> |
158 FolderPickerAsyncOp; | 158 FolderPickerAsyncOp; |
159 | 159 |
160 // Called asynchronously when the folder picker is done. | 160 // Called asynchronously when the folder picker is done. |
161 HRESULT FolderPickerDone(FolderPickerAsyncOp* async, AsyncStatus status); | 161 HRESULT FolderPickerDone(FolderPickerAsyncOp* async, AsyncStatus status); |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(FolderPickerSession); | 163 DISALLOW_COPY_AND_ASSIGN(FolderPickerSession); |
164 }; | 164 }; |
165 | 165 |
166 #endif // CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_ | 166 #endif // CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_ |
167 | 167 |
OLD | NEW |