From 462a60f5790dfe2ce5b6d491519194a5ad4f9a69 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Mon, 3 Sep 2012 11:25:08 -0400 Subject: [PATCH] Bug 787808 - Create common base class for Win32 and WinRT filepickers. r=jimm --- widget/windows/nsFilePicker.cpp | 8 ++++---- widget/windows/nsFilePicker.h | 28 ++++++++++++++++++---------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/widget/windows/nsFilePicker.cpp b/widget/windows/nsFilePicker.cpp index 55daccdcc37b..c110a8f6dabd 100644 --- a/widget/windows/nsFilePicker.cpp +++ b/widget/windows/nsFilePicker.cpp @@ -1130,7 +1130,7 @@ nsFilePicker::GetFiles(nsISimpleEnumerator **aFiles) // Get the file + path NS_IMETHODIMP -nsFilePicker::SetDefaultString(const nsAString& aString) +nsBaseWinFilePicker::SetDefaultString(const nsAString& aString) { mDefaultFilePath = aString; @@ -1164,21 +1164,21 @@ nsFilePicker::SetDefaultString(const nsAString& aString) } NS_IMETHODIMP -nsFilePicker::GetDefaultString(nsAString& aString) +nsBaseWinFilePicker::GetDefaultString(nsAString& aString) { return NS_ERROR_FAILURE; } // The default extension to use for files NS_IMETHODIMP -nsFilePicker::GetDefaultExtension(nsAString& aExtension) +nsBaseWinFilePicker::GetDefaultExtension(nsAString& aExtension) { aExtension = mDefaultExtension; return NS_OK; } NS_IMETHODIMP -nsFilePicker::SetDefaultExtension(const nsAString& aExtension) +nsBaseWinFilePicker::SetDefaultExtension(const nsAString& aExtension) { mDefaultExtension = aExtension; return NS_OK; diff --git a/widget/windows/nsFilePicker.h b/widget/windows/nsFilePicker.h index 197184b7124f..d2213da422c1 100644 --- a/widget/windows/nsFilePicker.h +++ b/widget/windows/nsFilePicker.h @@ -34,13 +34,28 @@ class nsILoadContext; +class nsBaseWinFilePicker : + public nsBaseFilePicker +{ +public: + NS_IMETHOD GetDefaultString(nsAString& aDefaultString); + NS_IMETHOD SetDefaultString(const nsAString& aDefaultString); + NS_IMETHOD GetDefaultExtension(nsAString& aDefaultExtension); + NS_IMETHOD SetDefaultExtension(const nsAString& aDefaultExtension); + +protected: + nsString mDefaultFilePath; + nsString mDefaultFilename; + nsString mDefaultExtension; +}; + /** * Native Windows FileSelector wrapper */ class nsFilePicker : - public nsBaseFilePicker, - public IFileDialogEvents + public IFileDialogEvents, + public nsBaseWinFilePicker { public: nsFilePicker(); @@ -53,11 +68,7 @@ public: // IUnknown's QueryInterface STDMETHODIMP QueryInterface(REFIID refiid, void** ppvResult); - // nsIFilePicker (less what's in nsBaseFilePicker) - NS_IMETHOD GetDefaultString(nsAString& aDefaultString); - NS_IMETHOD SetDefaultString(const nsAString& aDefaultString); - NS_IMETHOD GetDefaultExtension(nsAString& aDefaultExtension); - NS_IMETHOD SetDefaultExtension(const nsAString& aDefaultExtension); + // nsIFilePicker (less what's in nsBaseFilePicker and nsBaseWinFilePicker) NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex); NS_IMETHOD SetFilterIndex(int32_t aFilterIndex); NS_IMETHOD GetFile(nsIFile * *aFile); @@ -109,9 +120,6 @@ protected: nsString mTitle; int16_t mMode; nsCString mFile; - nsString mDefaultFilePath; - nsString mDefaultFilename; - nsString mDefaultExtension; nsString mFilterList; int16_t mSelectedType; nsCOMArray mFiles;