blob: 3d26a1822e6ed091f4b7daf8bf63fff7bac500b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsBaseFilePicker_h__
#define nsBaseFilePicker_h__
#include "mozilla/dom/BrowsingContext.h"
#include "nsISupports.h"
#include "nsIFilePicker.h"
#include "nsISimpleEnumerator.h"
#include "nsArrayEnumerator.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsTArray.h"
class nsPIDOMWindowOuter;
class nsIWidget;
class nsBaseFilePicker : public nsIFilePicker {
#ifndef XP_WIN
class AsyncShowFilePicker;
#endif
public:
nsBaseFilePicker();
virtual ~nsBaseFilePicker();
NS_IMETHOD Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle,
nsIFilePicker::Mode aMode,
mozilla::dom::BrowsingContext* aBrowsingContext) override;
NS_IMETHOD IsModeSupported(nsIFilePicker::Mode aMode, JSContext* aCx,
mozilla::dom::Promise** aPromise) override;
#ifndef XP_WIN
NS_IMETHOD Open(nsIFilePickerShownCallback* aCallback) override;
#endif
NS_IMETHOD Close() override;
NS_IMETHOD AppendFilters(int32_t filterMask) override;
NS_IMETHOD AppendRawFilter(const nsAString& aFilter) override;
NS_IMETHOD GetCapture(nsIFilePicker::CaptureTarget* aCapture) override;
NS_IMETHOD SetCapture(nsIFilePicker::CaptureTarget aCapture) override;
NS_IMETHOD GetFilterIndex(int32_t* aFilterIndex) override;
NS_IMETHOD SetFilterIndex(int32_t aFilterIndex) override;
NS_IMETHOD GetFiles(nsISimpleEnumerator** aFiles) override;
NS_IMETHOD GetDisplayDirectory(nsIFile** aDisplayDirectory) override;
NS_IMETHOD SetDisplayDirectory(nsIFile* aDisplayDirectory) override;
NS_IMETHOD GetDisplaySpecialDirectory(nsAString& aDisplayDirectory) override;
NS_IMETHOD SetDisplaySpecialDirectory(
const nsAString& aDisplayDirectory) override;
NS_IMETHOD GetAddToRecentDocs(bool* aFlag) override;
NS_IMETHOD SetAddToRecentDocs(bool aFlag) override;
NS_IMETHOD GetMode(nsIFilePicker::Mode* aMode) override;
NS_IMETHOD SetOkButtonLabel(const nsAString& aLabel) override;
NS_IMETHOD GetOkButtonLabel(nsAString& aLabel) override;
NS_IMETHOD GetDomFileOrDirectory(nsISupports** aValue) override;
NS_IMETHOD GetDomFileOrDirectoryEnumerator(
nsISimpleEnumerator** aValue) override;
protected:
virtual void InitNative(nsIWidget* aParent, const nsAString& aTitle) = 0;
virtual nsresult Show(nsIFilePicker::ResultCode* _retval) = 0;
virtual nsresult ResolveSpecialDirectory(const nsAString& aSpecialDirectory);
bool MaybeBlockFilePicker(nsIFilePickerShownCallback* aCallback);
bool mAddToRecentDocs;
nsCOMPtr<nsIFile> mDisplayDirectory;
nsString mDisplaySpecialDirectory;
nsCOMPtr<nsPIDOMWindowOuter> mParent;
// The BrowsingContext from which the file picker is being opened.
// Used for content analysis.
RefPtr<mozilla::dom::BrowsingContext> mBrowsingContext;
nsIFilePicker::Mode mMode;
nsString mOkButtonLabel;
nsTArray<nsString> mRawFilters;
};
#endif // nsBaseFilePicker_h__
|