Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / win8 / metro_driver / file_picker_ash.h
blob2f5d996ada9369ea2fe9881f847606be2fb238a1
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
3 // found in the LICENSE file.
4 #ifndef CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_
5 #define CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_
7 #include <vector>
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "base/strings/string16.h"
14 class ChromeAppViewAsh;
15 struct MetroViewerHostMsg_SaveAsDialogParams;
17 namespace base {
18 class FilePath;
21 // Base class for the file pickers.
22 class FilePickerSessionBase {
23 public:
24 // Creates a file picker for open_file_name.
25 explicit FilePickerSessionBase(ChromeAppViewAsh* app_view,
26 const base::string16& title,
27 const base::string16& filter,
28 const base::FilePath& default_path);
30 virtual ~FilePickerSessionBase() {
33 // Runs the picker, returns true on success.
34 bool Run();
36 const base::string16& result() const {
37 return result_;
40 bool success() const {
41 return success_;
44 protected:
45 // Creates, configures and starts a file picker.
46 // If the HRESULT returned is a failure code the file picker has not started,
47 // so no callbacks should be expected.
48 virtual HRESULT StartFilePicker() = 0;
50 // True iff a file picker has successfully finished.
51 bool success_;
53 // The title of the file picker.
54 base::string16 title_;
56 // The file type filter.
57 base::string16 filter_;
59 // The starting directory/file name.
60 base::FilePath default_path_;
62 // Pointer to the ChromeAppViewAsh instance. We notify the ChromeAppViewAsh
63 // instance when the file open/save operations complete.
64 ChromeAppViewAsh* app_view_;
66 base::string16 result_;
68 private:
69 // Initiate a file picker, must be called on the main metro thread.
70 // Returns true on success.
71 bool DoFilePicker();
73 DISALLOW_COPY_AND_ASSIGN(FilePickerSessionBase);
76 // Provides functionality to display the open file/multiple open file pickers
77 // metro dialog.
78 class OpenFilePickerSession : public FilePickerSessionBase {
79 public:
80 explicit OpenFilePickerSession(ChromeAppViewAsh* app_view,
81 const base::string16& title,
82 const base::string16& filter,
83 const base::FilePath& default_path,
84 bool allow_multi_select);
86 const std::vector<base::FilePath>& filenames() const {
87 return filenames_;
90 const bool allow_multi_select() const {
91 return allow_multi_select_;
94 private:
95 virtual HRESULT StartFilePicker() override;
97 typedef winfoundtn::IAsyncOperation<winstorage::StorageFile*>
98 SingleFileAsyncOp;
99 typedef winfoundtn::Collections::IVectorView<
100 winstorage::StorageFile*> StorageFileVectorCollection;
101 typedef winfoundtn::IAsyncOperation<StorageFileVectorCollection*>
102 MultiFileAsyncOp;
104 // Called asynchronously when a single file picker is done.
105 HRESULT SinglePickerDone(SingleFileAsyncOp* async, AsyncStatus status);
107 // Called asynchronously when a multi file picker is done.
108 HRESULT MultiPickerDone(MultiFileAsyncOp* async, AsyncStatus status);
110 // Composes a multi-file result string suitable for returning to a
111 // from a storage file collection.
112 static HRESULT ComposeMultiFileResult(StorageFileVectorCollection* files,
113 base::string16* result);
115 private:
116 // True if the multi file picker is to be displayed.
117 bool allow_multi_select_;
118 // If multi select is true then this member contains the list of filenames
119 // to be returned back.
120 std::vector<base::FilePath> filenames_;
122 DISALLOW_COPY_AND_ASSIGN(OpenFilePickerSession);
125 // Provides functionality to display the save file picker.
126 class SaveFilePickerSession : public FilePickerSessionBase {
127 public:
128 explicit SaveFilePickerSession(
129 ChromeAppViewAsh* app_view,
130 const MetroViewerHostMsg_SaveAsDialogParams& params);
132 int SaveFilePickerSession::filter_index() const;
134 private:
135 virtual HRESULT StartFilePicker() override;
137 typedef winfoundtn::IAsyncOperation<winstorage::StorageFile*>
138 SaveFileAsyncOp;
140 // Called asynchronously when the save file picker is done.
141 HRESULT FilePickerDone(SaveFileAsyncOp* async, AsyncStatus status);
143 int filter_index_;
145 DISALLOW_COPY_AND_ASSIGN(SaveFilePickerSession);
148 // Provides functionality to display the folder picker.
149 class FolderPickerSession : public FilePickerSessionBase {
150 public:
151 explicit FolderPickerSession(ChromeAppViewAsh* app_view,
152 const base::string16& title);
154 private:
155 virtual HRESULT StartFilePicker() override;
157 typedef winfoundtn::IAsyncOperation<winstorage::StorageFolder*>
158 FolderPickerAsyncOp;
160 // Called asynchronously when the folder picker is done.
161 HRESULT FolderPickerDone(FolderPickerAsyncOp* async, AsyncStatus status);
163 DISALLOW_COPY_AND_ASSIGN(FolderPickerSession);
166 #endif // CHROME_BROWSER_UI_METRO_DRIVER_FILE_PICKER_ASH_H_