|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 #ifndef NSFILEPICKERPROXY_H |
|
7 #define NSFILEPICKERPROXY_H |
|
8 |
|
9 #include "nsBaseFilePicker.h" |
|
10 #include "nsString.h" |
|
11 #include "nsIURI.h" |
|
12 #include "nsTArray.h" |
|
13 #include "nsCOMArray.h" |
|
14 |
|
15 #include "mozilla/dom/PFilePickerChild.h" |
|
16 |
|
17 class nsIWidget; |
|
18 class nsIFile; |
|
19 |
|
20 /** |
|
21 This class creates a proxy file picker to be used in content processes. |
|
22 The file picker just collects the initialization data and when Show() is |
|
23 called, remotes everything to the chrome process which in turn can show a |
|
24 platform specific file picker. |
|
25 */ |
|
26 class nsFilePickerProxy : public nsBaseFilePicker, |
|
27 public mozilla::dom::PFilePickerChild |
|
28 { |
|
29 public: |
|
30 nsFilePickerProxy(); |
|
31 |
|
32 NS_DECL_ISUPPORTS |
|
33 |
|
34 // nsIFilePicker (less what's in nsBaseFilePicker) |
|
35 NS_IMETHODIMP Init(nsIDOMWindow* aParent, const nsAString& aTitle, int16_t aMode); |
|
36 NS_IMETHODIMP AppendFilter(const nsAString& aTitle, const nsAString& aFilter); |
|
37 NS_IMETHODIMP GetDefaultString(nsAString& aDefaultString); |
|
38 NS_IMETHODIMP SetDefaultString(const nsAString& aDefaultString); |
|
39 NS_IMETHODIMP GetDefaultExtension(nsAString& aDefaultExtension); |
|
40 NS_IMETHODIMP SetDefaultExtension(const nsAString& aDefaultExtension); |
|
41 NS_IMETHODIMP GetFilterIndex(int32_t* aFilterIndex); |
|
42 NS_IMETHODIMP SetFilterIndex(int32_t aFilterIndex); |
|
43 NS_IMETHODIMP GetFile(nsIFile** aFile); |
|
44 NS_IMETHODIMP GetFileURL(nsIURI** aFileURL); |
|
45 NS_IMETHODIMP GetFiles(nsISimpleEnumerator** aFiles); |
|
46 |
|
47 NS_IMETHODIMP GetDomfile(nsIDOMFile** aFile); |
|
48 NS_IMETHODIMP GetDomfiles(nsISimpleEnumerator** aFiles); |
|
49 |
|
50 NS_IMETHODIMP Show(int16_t* aReturn); |
|
51 NS_IMETHODIMP Open(nsIFilePickerShownCallback* aCallback); |
|
52 |
|
53 // PFilePickerChild |
|
54 virtual bool |
|
55 Recv__delete__(const MaybeInputFiles& aFiles, const int16_t& aResult); |
|
56 |
|
57 private: |
|
58 ~nsFilePickerProxy(); |
|
59 void InitNative(nsIWidget*, const nsAString&); |
|
60 |
|
61 nsCOMArray<nsIDOMFile> mDomfiles; |
|
62 nsCOMPtr<nsIFilePickerShownCallback> mCallback; |
|
63 |
|
64 int16_t mSelectedType; |
|
65 nsString mFile; |
|
66 nsString mDefault; |
|
67 nsString mDefaultExtension; |
|
68 |
|
69 InfallibleTArray<nsString> mFilters; |
|
70 InfallibleTArray<nsString> mFilterNames; |
|
71 }; |
|
72 |
|
73 #endif // NSFILEPICKERPROXY_H |