Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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/. */
7 #ifndef mozilla_dom_FilePickerParent_h
8 #define mozilla_dom_FilePickerParent_h
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"
17 namespace mozilla {
18 namespace dom {
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 {}
29 virtual ~FilePickerParent();
31 void Done(int16_t aResult);
32 void SendFiles(const nsCOMArray<nsIDOMFile>& aDomfiles);
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;
41 virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
43 class FilePickerShownCallback : public nsIFilePickerShownCallback
44 {
45 public:
46 FilePickerShownCallback(FilePickerParent* aFilePickerParent)
47 : mFilePickerParent(aFilePickerParent)
48 { }
49 virtual ~FilePickerShownCallback() {}
51 NS_DECL_ISUPPORTS
52 NS_DECL_NSIFILEPICKERSHOWNCALLBACK
54 void Destroy();
56 private:
57 FilePickerParent* mFilePickerParent;
58 };
60 private:
61 bool CreateFilePicker();
63 class FileSizeAndDateRunnable : public nsRunnable
64 {
65 FilePickerParent* mFilePickerParent;
66 nsCOMArray<nsIDOMFile> mDomfiles;
67 nsCOMPtr<nsIEventTarget> mEventTarget;
69 public:
70 FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsCOMArray<nsIDOMFile>& aDomfiles);
71 bool Dispatch();
72 NS_IMETHOD Run();
73 void Destroy();
74 };
76 nsRefPtr<FileSizeAndDateRunnable> mRunnable;
77 nsRefPtr<FilePickerShownCallback> mCallback;
78 nsCOMPtr<nsIFilePicker> mFilePicker;
80 nsString mTitle;
81 int16_t mMode;
82 int16_t mResult;
83 };
85 } // namespace dom
86 } // namespace mozilla
88 #endif