Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsMetroFilePicker_h__
7 #define nsMetroFilePicker_h__
9 #include "../nsFilePicker.h"
10 #include "nsString.h"
11 #include "nsCOMArray.h"
12 #include "nsCOMPtr.h"
13 #include "nsILocalFile.h"
15 #include "mozwrlbase.h"
17 #include <windows.system.h>
18 #include <windows.ui.core.h>
19 #include <windows.foundation.h>
20 #include <windows.storage.pickers.h>
21 #include <windows.storage.fileproperties.h>
23 /**
24 * Metro file picker
25 */
27 class nsMetroFilePicker :
28 public nsBaseWinFilePicker
29 {
30 typedef Microsoft::WRL::Wrappers::HString HString;
31 typedef ABI::Windows::Storage::StorageFile StorageFile;
32 typedef ABI::Windows::Foundation::AsyncStatus AsyncStatus;
34 public:
35 nsMetroFilePicker();
36 virtual ~nsMetroFilePicker();
38 NS_DECL_ISUPPORTS
40 // nsIFilePicker (less what's in nsBaseFilePicker)
41 NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex);
42 NS_IMETHOD SetFilterIndex(int32_t aFilterIndex);
43 NS_IMETHOD GetFile(nsIFile * *aFile);
44 NS_IMETHOD GetFileURL(nsIURI * *aFileURL);
45 NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles);
46 NS_IMETHOD Show(int16_t *aReturnVal);
47 NS_IMETHOD Open(nsIFilePickerShownCallback *aCallback);
48 NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter);
49 NS_IMETHOD Init(nsIDOMWindow *parent, const nsAString& title,
50 int16_t mode);
52 // Async callbacks
53 HRESULT OnPickSingleFile(ABI::Windows::Foundation::IAsyncOperation<StorageFile*>* aFile, AsyncStatus aStatus);
54 HRESULT OnPickMultipleFiles(ABI::Windows::Foundation::IAsyncOperation<ABI::Windows::Foundation::Collections::IVectorView<StorageFile*>*>* aFileList, AsyncStatus aStatus);
56 private:
57 void InitNative(nsIWidget*, const nsAString&) {};
58 nsresult ParseFiltersIntoVector(Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IVector<HSTRING>>& aVector,
59 const nsAString& aFilter,
60 bool aAllowAll);
61 nsCOMArray<nsILocalFile> mFiles;
62 Microsoft::WRL::ComPtr<ABI::Windows::Storage::Pickers::IFileOpenPicker> mFileOpenPicker;
63 Microsoft::WRL::ComPtr<ABI::Windows::Storage::Pickers::IFileSavePicker> mFileSavePicker;
64 HString mFilePath;
65 HString mFirstTitle;
66 nsRefPtr<nsIFilePickerShownCallback> mCallback;
67 };
69 #endif // nsMetroFilePicker_h__