diff options
author | Moonchild <moonchild@palemoon.org> | 2020-09-17 15:24:50 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-09-17 15:25:44 +0000 |
commit | 8151bb2b05f71c7fac9aefc94b97d7b703c8d803 (patch) | |
tree | 5b36af1946702a7a439fd1fd113913b9cee4d395 | |
parent | b6b868b1bda0d82b85647f3e9ff2ab1f788eeb46 (diff) | |
download | uxp-8151bb2b05f71c7fac9aefc94b97d7b703c8d803.tar.gz |
Issue #1653 - Part 1: Remove WinUtils::SHGetKnownFolderPath
Instead of doing the whole dll-load, replace function dance, we can just use the
shlobj.h version of Windows.
-rw-r--r-- | dom/plugins/ipc/PluginModuleChild.cpp | 6 | ||||
-rw-r--r-- | widget/windows/WinIMEHandler.cpp | 4 | ||||
-rw-r--r-- | widget/windows/WinUtils.cpp | 28 | ||||
-rw-r--r-- | widget/windows/WinUtils.h | 14 |
4 files changed, 5 insertions, 47 deletions
diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index f943dfc427..98c9cd4949 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -40,8 +40,8 @@ #ifdef XP_WIN #include "nsWindowsDllInterceptor.h" #include "mozilla/widget/AudioSession.h" -#include "WinUtils.h" #include <knownfolders.h> +#include <shlobj.h> #endif #ifdef MOZ_WIDGET_COCOA @@ -1918,8 +1918,8 @@ GetLocalLowTempPath(size_t aLen, LPWSTR aPath) { NS_NAMED_LITERAL_STRING(tempname, "\\Temp"); LPWSTR path; - if (SUCCEEDED(WinUtils::SHGetKnownFolderPath(FOLDERID_LocalAppDataLow, 0, - nullptr, &path))) { + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_LocalAppDataLow, 0, + nullptr, &path))) { if (wcslen(path) + tempname.Length() < aLen) { wcscpy(aPath, path); wcscat(aPath, tempname.get()); diff --git a/widget/windows/WinIMEHandler.cpp b/widget/windows/WinIMEHandler.cpp index 9debaa2dda..f411cdd509 100644 --- a/widget/windows/WinIMEHandler.cpp +++ b/widget/windows/WinIMEHandler.cpp @@ -961,8 +961,8 @@ IMEHandler::ShowOnScreenKeyboard() } else { PWSTR path = nullptr; HRESULT hres = - WinUtils::SHGetKnownFolderPath(FOLDERID_ProgramFilesCommon, 0, - nullptr, &path); + SHGetKnownFolderPath(FOLDERID_ProgramFilesCommon, 0, + nullptr, &path); if (FAILED(hres) || !path) { return; } diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index bd42e78f66..6d9aab50db 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -419,8 +419,6 @@ const char FaviconHelper::kShortcutCacheDir[] = "shortcutCache"; // apis available on vista and up. WinUtils::SHCreateItemFromParsingNamePtr WinUtils::sCreateItemFromParsingName = nullptr; -WinUtils::SHGetKnownFolderPathPtr WinUtils::sGetKnownFolderPath = nullptr; - // We just leak these DLL HMODULEs. There's no point in calling FreeLibrary // on them during shutdown anyway. static const wchar_t kShellLibraryName[] = L"shell32.dll"; @@ -1179,32 +1177,6 @@ WinUtils::SHCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc, return sCreateItemFromParsingName(pszPath, pbc, riid, ppv); } -/* static */ -HRESULT -WinUtils::SHGetKnownFolderPath(REFKNOWNFOLDERID rfid, - DWORD dwFlags, - HANDLE hToken, - PWSTR *ppszPath) -{ - if (sGetKnownFolderPath) { - return sGetKnownFolderPath(rfid, dwFlags, hToken, ppszPath); - } - - if (!sShellDll) { - sShellDll = ::LoadLibraryW(kShellLibraryName); - if (!sShellDll) { - return false; - } - } - - sGetKnownFolderPath = (SHGetKnownFolderPathPtr) - GetProcAddress(sShellDll, "SHGetKnownFolderPath"); - if (!sGetKnownFolderPath) - return E_FAIL; - - return sGetKnownFolderPath(rfid, dwFlags, hToken, ppszPath); -} - static BOOL WINAPI EnumFirstChild(HWND hwnd, LPARAM lParam) { diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h index 37469ce079..9aa2c1c8ad 100644 --- a/widget/windows/WinUtils.h +++ b/widget/windows/WinUtils.h @@ -399,14 +399,6 @@ public: REFIID riid, void **ppv); /** - * SHGetKnownFolderPath() calls native SHGetKnownFolderPath() - * API which is available on Vista and up. - */ - static HRESULT SHGetKnownFolderPath(REFKNOWNFOLDERID rfid, - DWORD dwFlags, - HANDLE hToken, - PWSTR *ppszPath); - /** * GetShellItemPath return the file or directory path of a shell item. * Internally calls IShellItem's GetDisplayName. * @@ -529,12 +521,6 @@ private: REFIID riid, void **ppv); static SHCreateItemFromParsingNamePtr sCreateItemFromParsingName; - typedef HRESULT (WINAPI * SHGetKnownFolderPathPtr)(REFKNOWNFOLDERID rfid, - DWORD dwFlags, - HANDLE hToken, - PWSTR *ppszPath); - static SHGetKnownFolderPathPtr sGetKnownFolderPath; - static void GetWhitelistedPaths( nsTArray<mozilla::Pair<nsString,nsDependentString>>& aOutput); }; |