Bug 787808 - Create common base class for Win32 and WinRT filepickers. r=jimm

This commit is contained in:
Brian R. Bondy 2012-09-03 11:25:08 -04:00
Родитель 6589977592
Коммит 462a60f579
2 изменённых файлов: 22 добавлений и 14 удалений

Просмотреть файл

@ -1130,7 +1130,7 @@ nsFilePicker::GetFiles(nsISimpleEnumerator **aFiles)
// Get the file + path // Get the file + path
NS_IMETHODIMP NS_IMETHODIMP
nsFilePicker::SetDefaultString(const nsAString& aString) nsBaseWinFilePicker::SetDefaultString(const nsAString& aString)
{ {
mDefaultFilePath = aString; mDefaultFilePath = aString;
@ -1164,21 +1164,21 @@ nsFilePicker::SetDefaultString(const nsAString& aString)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsFilePicker::GetDefaultString(nsAString& aString) nsBaseWinFilePicker::GetDefaultString(nsAString& aString)
{ {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// The default extension to use for files // The default extension to use for files
NS_IMETHODIMP NS_IMETHODIMP
nsFilePicker::GetDefaultExtension(nsAString& aExtension) nsBaseWinFilePicker::GetDefaultExtension(nsAString& aExtension)
{ {
aExtension = mDefaultExtension; aExtension = mDefaultExtension;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsFilePicker::SetDefaultExtension(const nsAString& aExtension) nsBaseWinFilePicker::SetDefaultExtension(const nsAString& aExtension)
{ {
mDefaultExtension = aExtension; mDefaultExtension = aExtension;
return NS_OK; return NS_OK;

Просмотреть файл

@ -34,13 +34,28 @@
class nsILoadContext; 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 * Native Windows FileSelector wrapper
*/ */
class nsFilePicker : class nsFilePicker :
public nsBaseFilePicker, public IFileDialogEvents,
public IFileDialogEvents public nsBaseWinFilePicker
{ {
public: public:
nsFilePicker(); nsFilePicker();
@ -53,11 +68,7 @@ public:
// IUnknown's QueryInterface // IUnknown's QueryInterface
STDMETHODIMP QueryInterface(REFIID refiid, void** ppvResult); STDMETHODIMP QueryInterface(REFIID refiid, void** ppvResult);
// nsIFilePicker (less what's in nsBaseFilePicker) // nsIFilePicker (less what's in nsBaseFilePicker and nsBaseWinFilePicker)
NS_IMETHOD GetDefaultString(nsAString& aDefaultString);
NS_IMETHOD SetDefaultString(const nsAString& aDefaultString);
NS_IMETHOD GetDefaultExtension(nsAString& aDefaultExtension);
NS_IMETHOD SetDefaultExtension(const nsAString& aDefaultExtension);
NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex); NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex);
NS_IMETHOD SetFilterIndex(int32_t aFilterIndex); NS_IMETHOD SetFilterIndex(int32_t aFilterIndex);
NS_IMETHOD GetFile(nsIFile * *aFile); NS_IMETHOD GetFile(nsIFile * *aFile);
@ -109,9 +120,6 @@ protected:
nsString mTitle; nsString mTitle;
int16_t mMode; int16_t mMode;
nsCString mFile; nsCString mFile;
nsString mDefaultFilePath;
nsString mDefaultFilename;
nsString mDefaultExtension;
nsString mFilterList; nsString mFilterList;
int16_t mSelectedType; int16_t mSelectedType;
nsCOMArray<nsIFile> mFiles; nsCOMArray<nsIFile> mFiles;