gecko-dev/widget/windows/nsFilePicker.h
Nicholas Nethercote 0b2b65edc8 Bug 1325503 - Remove Windows {XP, Server 2003, Vista} support from widget/. r=jimm.
I did my best to remove as much stuff as possible in this patch. The starting
point was to remove all the IsVistaOrLater() and IsWin7OrLater() calls, but I
also grepped for various strings and found some other removable stuff that way.
I may have still missed some things.

Notable things done by this patch.

- It removes numerous blocklist entries.

- It removes CanComputeVirtualKeyCodeFromScanCode(), because it's always true
  now.

- It removes ShowXP{Folder,File}Picker(), even though these were available as
  fallbacks on Vista+. The "when platform is built without the longhorn SDK"
  condition in the comment above nsFilePicker::ShowXPFolderPicker() sounds like
  it won't ever happen any more.

- It removes the config.trim_on_minimize preference. This requires adding a
  bool sHaveInitializedPrefs variable; previously the lack of pref
  initialization was indicated by the tri-state sTrimOnMinimize variable having
  the value 2.

Notable things *not* done by this patch.

- ClearThemeRegion() still exists. The comment suggests that it is XP/Vista
  only, but the code suggests otherwise. jimm thinks the comment is wrong.

- The comment in WinWakeLockListener::Callback() suggests that the StartTimer()
  call is no longer needed to block the screen saver. I'm uncertain about this
  and so I think it's best left to a follow-up.

--HG--
extra : rebase_source : f46645907d237423fd6115ab1b4725b023a0dce3
2016-12-23 13:13:31 +11:00

152 lines
4.5 KiB
C++

/* -*- Mode: C++; tab-width: 2; 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 nsFilePicker_h__
#define nsFilePicker_h__
#include <windows.h>
// For Vista IFileDialog interfaces which aren't exposed
// unless _WIN32_WINNT >= _WIN32_WINNT_LONGHORN.
#if _WIN32_WINNT < _WIN32_WINNT_LONGHORN
#define _WIN32_WINNT_bak _WIN32_WINNT
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_LONGHORN
#define _WIN32_IE_bak _WIN32_IE
#undef _WIN32_IE
#define _WIN32_IE _WIN32_IE_IE70
#endif
#include "nsIFile.h"
#include "nsITimer.h"
#include "nsISimpleEnumerator.h"
#include "nsCOMArray.h"
#include "nsBaseFilePicker.h"
#include "nsString.h"
#include "nsdefs.h"
#include <commdlg.h>
#include <shobjidl.h>
#undef LogSeverity // SetupAPI.h #defines this as DWORD
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 IFileDialogEvents,
public nsBaseWinFilePicker
{
virtual ~nsFilePicker();
public:
nsFilePicker();
NS_IMETHOD Init(mozIDOMWindowProxy *aParent, const nsAString& aTitle, int16_t aMode);
NS_DECL_ISUPPORTS
// IUnknown's QueryInterface
STDMETHODIMP QueryInterface(REFIID refiid, void** ppvResult);
// 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);
NS_IMETHOD GetFileURL(nsIURI * *aFileURL);
NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles);
NS_IMETHOD Show(int16_t *aReturnVal);
NS_IMETHOD ShowW(int16_t *aReturnVal);
NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter);
// IFileDialogEvents
HRESULT STDMETHODCALLTYPE OnFileOk(IFileDialog *pfd);
HRESULT STDMETHODCALLTYPE OnFolderChanging(IFileDialog *pfd, IShellItem *psiFolder);
HRESULT STDMETHODCALLTYPE OnFolderChange(IFileDialog *pfd);
HRESULT STDMETHODCALLTYPE OnSelectionChange(IFileDialog *pfd);
HRESULT STDMETHODCALLTYPE OnShareViolation(IFileDialog *pfd, IShellItem *psi, FDE_SHAREVIOLATION_RESPONSE *pResponse);
HRESULT STDMETHODCALLTYPE OnTypeChange(IFileDialog *pfd);
HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse);
protected:
/* method from nsBaseFilePicker */
virtual void InitNative(nsIWidget *aParent,
const nsAString& aTitle);
void GetFilterListArray(nsString& aFilterList);
bool ShowFolderPicker(const nsString& aInitialDir);
bool ShowFilePicker(const nsString& aInitialDir);
void RememberLastUsedDirectory();
bool IsPrivacyModeEnabled();
bool IsDefaultPathLink();
bool IsDefaultPathHtml();
void SetDialogHandle(HWND aWnd);
bool ClosePickerIfNeeded();
static void PickerCallbackTimerFunc(nsITimer *aTimer, void *aPicker);
nsCOMPtr<nsILoadContext> mLoadContext;
nsCOMPtr<nsIWidget> mParentWidget;
nsString mTitle;
nsCString mFile;
nsString mFilterList;
int16_t mSelectedType;
nsCOMArray<nsIFile> mFiles;
static char mLastUsedDirectory[];
nsString mUnicodeFile;
static char16_t *mLastUsedUnicodeDirectory;
HWND mDlgWnd;
class ComDlgFilterSpec
{
public:
ComDlgFilterSpec() {}
~ComDlgFilterSpec() {}
const uint32_t Length() {
return mSpecList.Length();
}
const bool IsEmpty() {
return (mSpecList.Length() == 0);
}
const COMDLG_FILTERSPEC* get() {
return mSpecList.Elements();
}
void Append(const nsAString& aTitle, const nsAString& aFilter);
private:
AutoTArray<COMDLG_FILTERSPEC, 1> mSpecList;
AutoTArray<nsString, 2> mStrings;
};
ComDlgFilterSpec mComFilterList;
DWORD mFDECookie;
};
#if defined(_WIN32_WINNT_bak)
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_bak
#undef _WIN32_IE
#define _WIN32_IE _WIN32_IE_bak
#endif
#endif // nsFilePicker_h__