diff -r 000000000000 -r 6474c204b198 widget/windows/winrt/nsMetroFilePicker.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widget/windows/winrt/nsMetroFilePicker.h Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; 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 nsMetroFilePicker_h__ +#define nsMetroFilePicker_h__ + +#include "../nsFilePicker.h" +#include "nsString.h" +#include "nsCOMArray.h" +#include "nsCOMPtr.h" +#include "nsILocalFile.h" + +#include "mozwrlbase.h" + +#include +#include +#include +#include +#include + +/** + * Metro file picker + */ + +class nsMetroFilePicker : + public nsBaseWinFilePicker +{ + typedef Microsoft::WRL::Wrappers::HString HString; + typedef ABI::Windows::Storage::StorageFile StorageFile; + typedef ABI::Windows::Foundation::AsyncStatus AsyncStatus; + +public: + nsMetroFilePicker(); + virtual ~nsMetroFilePicker(); + + NS_DECL_ISUPPORTS + + // nsIFilePicker (less what's in nsBaseFilePicker) + NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex); + NS_IMETHOD SetFilterIndex(int32_t aFilterIndex); + NS_IMETHOD GetFile(nsIFile * *aFile); + NS_IMETHOD GetFileURL(nsIURI * *aFileURL); + NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles); + NS_IMETHOD Show(int16_t *aReturnVal); + NS_IMETHOD Open(nsIFilePickerShownCallback *aCallback); + NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter); + NS_IMETHOD Init(nsIDOMWindow *parent, const nsAString& title, + int16_t mode); + + // Async callbacks + HRESULT OnPickSingleFile(ABI::Windows::Foundation::IAsyncOperation* aFile, AsyncStatus aStatus); + HRESULT OnPickMultipleFiles(ABI::Windows::Foundation::IAsyncOperation*>* aFileList, AsyncStatus aStatus); + +private: + void InitNative(nsIWidget*, const nsAString&) {}; + nsresult ParseFiltersIntoVector(Microsoft::WRL::ComPtr>& aVector, + const nsAString& aFilter, + bool aAllowAll); + nsCOMArray mFiles; + Microsoft::WRL::ComPtr mFileOpenPicker; + Microsoft::WRL::ComPtr mFileSavePicker; + HString mFilePath; + HString mFirstTitle; + nsRefPtr mCallback; +}; + +#endif // nsMetroFilePicker_h__