Bug 1884631 - Remove macOS native sheet support. r=mac-reviewers,aleca,kaie,bradwerth
[gecko.git] / widget / nsBaseFilePicker.h
blob52b8bc779833972c1d3188aab66f572396a9e5c0
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 "mozilla/dom/BrowsingContext.h"
11 #include "nsISupports.h"
12 #include "nsIFilePicker.h"
13 #include "nsISimpleEnumerator.h"
14 #include "nsArrayEnumerator.h"
15 #include "nsCOMPtr.h"
16 #include "nsString.h"
17 #include "nsTArray.h"
19 class nsPIDOMWindowOuter;
20 class nsIWidget;
22 class nsBaseFilePicker : public nsIFilePicker {
23 #ifndef XP_WIN
24 class AsyncShowFilePicker;
25 #endif
27 public:
28 nsBaseFilePicker();
29 virtual ~nsBaseFilePicker();
31 NS_IMETHOD Init(mozilla::dom::BrowsingContext* aBrowsingContext,
32 const nsAString& aTitle, nsIFilePicker::Mode aMode) override;
33 NS_IMETHOD IsModeSupported(nsIFilePicker::Mode aMode, JSContext* aCx,
34 mozilla::dom::Promise** aPromise) override;
35 #ifndef XP_WIN
36 NS_IMETHOD Open(nsIFilePickerShownCallback* aCallback) override;
37 #endif
38 NS_IMETHOD Close() override;
39 NS_IMETHOD AppendFilters(int32_t filterMask) override;
40 NS_IMETHOD AppendRawFilter(const nsAString& aFilter) override;
41 NS_IMETHOD GetCapture(nsIFilePicker::CaptureTarget* aCapture) override;
42 NS_IMETHOD SetCapture(nsIFilePicker::CaptureTarget aCapture) override;
43 NS_IMETHOD GetFilterIndex(int32_t* aFilterIndex) override;
44 NS_IMETHOD SetFilterIndex(int32_t aFilterIndex) override;
45 NS_IMETHOD GetFiles(nsISimpleEnumerator** aFiles) override;
46 NS_IMETHOD GetDisplayDirectory(nsIFile** aDisplayDirectory) override;
47 NS_IMETHOD SetDisplayDirectory(nsIFile* aDisplayDirectory) override;
48 NS_IMETHOD GetDisplaySpecialDirectory(nsAString& aDisplayDirectory) override;
49 NS_IMETHOD SetDisplaySpecialDirectory(
50 const nsAString& aDisplayDirectory) override;
51 NS_IMETHOD GetAddToRecentDocs(bool* aFlag) override;
52 NS_IMETHOD SetAddToRecentDocs(bool aFlag) override;
53 NS_IMETHOD GetMode(nsIFilePicker::Mode* aMode) override;
54 NS_IMETHOD SetOkButtonLabel(const nsAString& aLabel) override;
55 NS_IMETHOD GetOkButtonLabel(nsAString& aLabel) override;
57 NS_IMETHOD GetDomFileOrDirectory(nsISupports** aValue) override;
58 NS_IMETHOD GetDomFileOrDirectoryEnumerator(
59 nsISimpleEnumerator** aValue) override;
61 protected:
62 virtual void InitNative(nsIWidget* aParent, const nsAString& aTitle) = 0;
63 virtual nsresult Show(nsIFilePicker::ResultCode* _retval) = 0;
65 virtual nsresult ResolveSpecialDirectory(const nsAString& aSpecialDirectory);
66 bool MaybeBlockFilePicker(nsIFilePickerShownCallback* aCallback);
68 bool mAddToRecentDocs;
69 nsCOMPtr<nsIFile> mDisplayDirectory;
70 nsString mDisplaySpecialDirectory;
72 RefPtr<mozilla::dom::BrowsingContext> mBrowsingContext;
73 nsIFilePicker::Mode mMode;
74 nsString mOkButtonLabel;
75 nsTArray<nsString> mRawFilters;
78 #endif // nsBaseFilePicker_h__