Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: set sw=4 ts=8 et tw=80 : |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_FilePickerParent_h |
michael@0 | 8 | #define mozilla_dom_FilePickerParent_h |
michael@0 | 9 | |
michael@0 | 10 | #include "nsIDOMFile.h" |
michael@0 | 11 | #include "nsIEventTarget.h" |
michael@0 | 12 | #include "nsIFilePicker.h" |
michael@0 | 13 | #include "nsCOMArray.h" |
michael@0 | 14 | #include "nsThreadUtils.h" |
michael@0 | 15 | #include "mozilla/dom/PFilePickerParent.h" |
michael@0 | 16 | |
michael@0 | 17 | namespace mozilla { |
michael@0 | 18 | namespace dom { |
michael@0 | 19 | |
michael@0 | 20 | class FilePickerParent : public PFilePickerParent |
michael@0 | 21 | { |
michael@0 | 22 | public: |
michael@0 | 23 | FilePickerParent(const nsString& aTitle, |
michael@0 | 24 | const int16_t& aMode) |
michael@0 | 25 | : mTitle(aTitle) |
michael@0 | 26 | , mMode(aMode) |
michael@0 | 27 | {} |
michael@0 | 28 | |
michael@0 | 29 | virtual ~FilePickerParent(); |
michael@0 | 30 | |
michael@0 | 31 | void Done(int16_t aResult); |
michael@0 | 32 | void SendFiles(const nsCOMArray<nsIDOMFile>& aDomfiles); |
michael@0 | 33 | |
michael@0 | 34 | virtual bool RecvOpen(const int16_t& aSelectedType, |
michael@0 | 35 | const bool& aAddToRecentDocs, |
michael@0 | 36 | const nsString& aDefaultFile, |
michael@0 | 37 | const nsString& aDefaultExtension, |
michael@0 | 38 | const InfallibleTArray<nsString>& aFilters, |
michael@0 | 39 | const InfallibleTArray<nsString>& aFilterNames) MOZ_OVERRIDE; |
michael@0 | 40 | |
michael@0 | 41 | virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; |
michael@0 | 42 | |
michael@0 | 43 | class FilePickerShownCallback : public nsIFilePickerShownCallback |
michael@0 | 44 | { |
michael@0 | 45 | public: |
michael@0 | 46 | FilePickerShownCallback(FilePickerParent* aFilePickerParent) |
michael@0 | 47 | : mFilePickerParent(aFilePickerParent) |
michael@0 | 48 | { } |
michael@0 | 49 | virtual ~FilePickerShownCallback() {} |
michael@0 | 50 | |
michael@0 | 51 | NS_DECL_ISUPPORTS |
michael@0 | 52 | NS_DECL_NSIFILEPICKERSHOWNCALLBACK |
michael@0 | 53 | |
michael@0 | 54 | void Destroy(); |
michael@0 | 55 | |
michael@0 | 56 | private: |
michael@0 | 57 | FilePickerParent* mFilePickerParent; |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | bool CreateFilePicker(); |
michael@0 | 62 | |
michael@0 | 63 | class FileSizeAndDateRunnable : public nsRunnable |
michael@0 | 64 | { |
michael@0 | 65 | FilePickerParent* mFilePickerParent; |
michael@0 | 66 | nsCOMArray<nsIDOMFile> mDomfiles; |
michael@0 | 67 | nsCOMPtr<nsIEventTarget> mEventTarget; |
michael@0 | 68 | |
michael@0 | 69 | public: |
michael@0 | 70 | FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsCOMArray<nsIDOMFile>& aDomfiles); |
michael@0 | 71 | bool Dispatch(); |
michael@0 | 72 | NS_IMETHOD Run(); |
michael@0 | 73 | void Destroy(); |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | nsRefPtr<FileSizeAndDateRunnable> mRunnable; |
michael@0 | 77 | nsRefPtr<FilePickerShownCallback> mCallback; |
michael@0 | 78 | nsCOMPtr<nsIFilePicker> mFilePicker; |
michael@0 | 79 | |
michael@0 | 80 | nsString mTitle; |
michael@0 | 81 | int16_t mMode; |
michael@0 | 82 | int16_t mResult; |
michael@0 | 83 | }; |
michael@0 | 84 | |
michael@0 | 85 | } // namespace dom |
michael@0 | 86 | } // namespace mozilla |
michael@0 | 87 | |
michael@0 | 88 | #endif |