|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * vim: set sw=4 ts=8 et tw=80 : |
|
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 |
|
7 #ifndef mozilla_dom_FilePickerParent_h |
|
8 #define mozilla_dom_FilePickerParent_h |
|
9 |
|
10 #include "nsIDOMFile.h" |
|
11 #include "nsIEventTarget.h" |
|
12 #include "nsIFilePicker.h" |
|
13 #include "nsCOMArray.h" |
|
14 #include "nsThreadUtils.h" |
|
15 #include "mozilla/dom/PFilePickerParent.h" |
|
16 |
|
17 namespace mozilla { |
|
18 namespace dom { |
|
19 |
|
20 class FilePickerParent : public PFilePickerParent |
|
21 { |
|
22 public: |
|
23 FilePickerParent(const nsString& aTitle, |
|
24 const int16_t& aMode) |
|
25 : mTitle(aTitle) |
|
26 , mMode(aMode) |
|
27 {} |
|
28 |
|
29 virtual ~FilePickerParent(); |
|
30 |
|
31 void Done(int16_t aResult); |
|
32 void SendFiles(const nsCOMArray<nsIDOMFile>& aDomfiles); |
|
33 |
|
34 virtual bool RecvOpen(const int16_t& aSelectedType, |
|
35 const bool& aAddToRecentDocs, |
|
36 const nsString& aDefaultFile, |
|
37 const nsString& aDefaultExtension, |
|
38 const InfallibleTArray<nsString>& aFilters, |
|
39 const InfallibleTArray<nsString>& aFilterNames) MOZ_OVERRIDE; |
|
40 |
|
41 virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; |
|
42 |
|
43 class FilePickerShownCallback : public nsIFilePickerShownCallback |
|
44 { |
|
45 public: |
|
46 FilePickerShownCallback(FilePickerParent* aFilePickerParent) |
|
47 : mFilePickerParent(aFilePickerParent) |
|
48 { } |
|
49 virtual ~FilePickerShownCallback() {} |
|
50 |
|
51 NS_DECL_ISUPPORTS |
|
52 NS_DECL_NSIFILEPICKERSHOWNCALLBACK |
|
53 |
|
54 void Destroy(); |
|
55 |
|
56 private: |
|
57 FilePickerParent* mFilePickerParent; |
|
58 }; |
|
59 |
|
60 private: |
|
61 bool CreateFilePicker(); |
|
62 |
|
63 class FileSizeAndDateRunnable : public nsRunnable |
|
64 { |
|
65 FilePickerParent* mFilePickerParent; |
|
66 nsCOMArray<nsIDOMFile> mDomfiles; |
|
67 nsCOMPtr<nsIEventTarget> mEventTarget; |
|
68 |
|
69 public: |
|
70 FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsCOMArray<nsIDOMFile>& aDomfiles); |
|
71 bool Dispatch(); |
|
72 NS_IMETHOD Run(); |
|
73 void Destroy(); |
|
74 }; |
|
75 |
|
76 nsRefPtr<FileSizeAndDateRunnable> mRunnable; |
|
77 nsRefPtr<FilePickerShownCallback> mCallback; |
|
78 nsCOMPtr<nsIFilePicker> mFilePicker; |
|
79 |
|
80 nsString mTitle; |
|
81 int16_t mMode; |
|
82 int16_t mResult; |
|
83 }; |
|
84 |
|
85 } // namespace dom |
|
86 } // namespace mozilla |
|
87 |
|
88 #endif |