widget/windows/winrt/nsMetroFilePicker.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:62cdd43abb07
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsMetroFilePicker_h__
7 #define nsMetroFilePicker_h__
8
9 #include "../nsFilePicker.h"
10 #include "nsString.h"
11 #include "nsCOMArray.h"
12 #include "nsCOMPtr.h"
13 #include "nsILocalFile.h"
14
15 #include "mozwrlbase.h"
16
17 #include <windows.system.h>
18 #include <windows.ui.core.h>
19 #include <windows.foundation.h>
20 #include <windows.storage.pickers.h>
21 #include <windows.storage.fileproperties.h>
22
23 /**
24 * Metro file picker
25 */
26
27 class nsMetroFilePicker :
28 public nsBaseWinFilePicker
29 {
30 typedef Microsoft::WRL::Wrappers::HString HString;
31 typedef ABI::Windows::Storage::StorageFile StorageFile;
32 typedef ABI::Windows::Foundation::AsyncStatus AsyncStatus;
33
34 public:
35 nsMetroFilePicker();
36 virtual ~nsMetroFilePicker();
37
38 NS_DECL_ISUPPORTS
39
40 // nsIFilePicker (less what's in nsBaseFilePicker)
41 NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex);
42 NS_IMETHOD SetFilterIndex(int32_t aFilterIndex);
43 NS_IMETHOD GetFile(nsIFile * *aFile);
44 NS_IMETHOD GetFileURL(nsIURI * *aFileURL);
45 NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles);
46 NS_IMETHOD Show(int16_t *aReturnVal);
47 NS_IMETHOD Open(nsIFilePickerShownCallback *aCallback);
48 NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter);
49 NS_IMETHOD Init(nsIDOMWindow *parent, const nsAString& title,
50 int16_t mode);
51
52 // Async callbacks
53 HRESULT OnPickSingleFile(ABI::Windows::Foundation::IAsyncOperation<StorageFile*>* aFile, AsyncStatus aStatus);
54 HRESULT OnPickMultipleFiles(ABI::Windows::Foundation::IAsyncOperation<ABI::Windows::Foundation::Collections::IVectorView<StorageFile*>*>* aFileList, AsyncStatus aStatus);
55
56 private:
57 void InitNative(nsIWidget*, const nsAString&) {};
58 nsresult ParseFiltersIntoVector(Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IVector<HSTRING>>& aVector,
59 const nsAString& aFilter,
60 bool aAllowAll);
61 nsCOMArray<nsILocalFile> mFiles;
62 Microsoft::WRL::ComPtr<ABI::Windows::Storage::Pickers::IFileOpenPicker> mFileOpenPicker;
63 Microsoft::WRL::ComPtr<ABI::Windows::Storage::Pickers::IFileSavePicker> mFileSavePicker;
64 HString mFilePath;
65 HString mFirstTitle;
66 nsRefPtr<nsIFilePickerShownCallback> mCallback;
67 };
68
69 #endif // nsMetroFilePicker_h__

mercurial