1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
7 #ifndef nsBaseFilePicker_h__
8 #define nsBaseFilePicker_h__
10 #include "nsISupports.h"
11 #include "nsIFilePicker.h"
16 class nsISimpleEnumerator
;
19 namespace mozilla::dom
{
20 class BrowsingContext
;
23 class nsBaseFilePicker
: public nsIFilePicker
{
28 NS_IMETHOD
Init(mozilla::dom::BrowsingContext
* aBrowsingContext
,
29 const nsAString
& aTitle
, nsIFilePicker::Mode aMode
) override
;
30 NS_IMETHOD
IsModeSupported(nsIFilePicker::Mode aMode
, JSContext
* aCx
,
31 mozilla::dom::Promise
** aPromise
) override
;
32 NS_IMETHOD
AppendFilters(int32_t filterMask
) override
;
33 NS_IMETHOD
AppendRawFilter(const nsAString
& aFilter
) override
;
34 NS_IMETHOD
GetCapture(nsIFilePicker::CaptureTarget
* aCapture
) override
;
35 NS_IMETHOD
SetCapture(nsIFilePicker::CaptureTarget aCapture
) override
;
36 NS_IMETHOD
GetFilterIndex(int32_t* aFilterIndex
) override
;
37 NS_IMETHOD
SetFilterIndex(int32_t aFilterIndex
) override
;
38 NS_IMETHOD
GetFiles(nsISimpleEnumerator
** aFiles
) override
;
39 NS_IMETHOD
GetDisplayDirectory(nsIFile
** aDisplayDirectory
) override
;
40 NS_IMETHOD
SetDisplayDirectory(nsIFile
* aDisplayDirectory
) override
;
41 NS_IMETHOD
GetDisplaySpecialDirectory(nsAString
& aDisplayDirectory
) override
;
42 NS_IMETHOD
SetDisplaySpecialDirectory(
43 const nsAString
& aDisplayDirectory
) override
;
44 NS_IMETHOD
GetAddToRecentDocs(bool* aFlag
) override
;
45 NS_IMETHOD
SetAddToRecentDocs(bool aFlag
) override
;
46 NS_IMETHOD
GetMode(nsIFilePicker::Mode
* aMode
) override
;
47 NS_IMETHOD
SetOkButtonLabel(const nsAString
& aLabel
) override
;
48 NS_IMETHOD
GetOkButtonLabel(nsAString
& aLabel
) override
;
50 NS_IMETHOD
GetDomFileOrDirectory(nsISupports
** aValue
) override
;
51 NS_IMETHOD
GetDomFileOrDirectoryEnumerator(
52 nsISimpleEnumerator
** aValue
) override
;
55 virtual ~nsBaseFilePicker();
57 virtual void InitNative(nsIWidget
* aParent
, const nsAString
& aTitle
) = 0;
59 virtual nsresult
ResolveSpecialDirectory(const nsAString
& aSpecialDirectory
);
60 bool MaybeBlockFilePicker(nsIFilePickerShownCallback
* aCallback
);
62 bool mAddToRecentDocs
= true;
63 nsCOMPtr
<nsIFile
> mDisplayDirectory
;
64 nsString mDisplaySpecialDirectory
;
66 RefPtr
<mozilla::dom::BrowsingContext
> mBrowsingContext
;
67 nsIFilePicker::Mode mMode
= nsIFilePicker::modeOpen
;
68 nsString mOkButtonLabel
;
69 nsTArray
<nsString
> mRawFilters
;
72 #endif // nsBaseFilePicker_h__