widget/windows/winrt/nsMetroFilePicker.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

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.

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

mercurial