summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--image/decoders/icon/win/nsIconChannel.cpp53
-rw-r--r--toolkit/components/alerts/nsAlertsService.cpp23
-rw-r--r--toolkit/components/alerts/nsAlertsService.h17
-rw-r--r--toolkit/xre/nsEmbedFunctions.cpp24
-rw-r--r--widget/windows/WinTaskbar.cpp47
5 files changed, 31 insertions, 133 deletions
diff --git a/image/decoders/icon/win/nsIconChannel.cpp b/image/decoders/icon/win/nsIconChannel.cpp
index 9ddcbbc48..04680627a 100644
--- a/image/decoders/icon/win/nsIconChannel.cpp
+++ b/image/decoders/icon/win/nsIconChannel.cpp
@@ -29,11 +29,6 @@
#include "nsContentSecurityManager.h"
#include "nsContentUtils.h"
-#ifdef _WIN32_WINNT
-#undef _WIN32_WINNT
-#endif
-#define _WIN32_WINNT 0x0600
-
// we need windows.h to read out registry information...
#include <windows.h>
#include <shellapi.h>
@@ -416,41 +411,27 @@ nsIconChannel::GetStockHIcon(nsIMozIconURI* aIconURI,
{
nsresult rv = NS_OK;
- // We can only do this on Vista or above
- HMODULE hShellDLL = ::LoadLibraryW(L"shell32.dll");
- decltype(SHGetStockIconInfo)* pSHGetStockIconInfo =
- (decltype(SHGetStockIconInfo)*) ::GetProcAddress(hShellDLL,
- "SHGetStockIconInfo");
-
- if (pSHGetStockIconInfo) {
- uint32_t desiredImageSize;
- aIconURI->GetImageSize(&desiredImageSize);
- nsAutoCString stockIcon;
- aIconURI->GetStockIcon(stockIcon);
-
- SHSTOCKICONID stockIconID = GetStockIconIDForName(stockIcon);
- if (stockIconID == SIID_INVALID) {
- return NS_ERROR_NOT_AVAILABLE;
- }
+ uint32_t desiredImageSize;
+ aIconURI->GetImageSize(&desiredImageSize);
+ nsAutoCString stockIcon;
+ aIconURI->GetStockIcon(stockIcon);
- UINT infoFlags = SHGSI_ICON;
- infoFlags |= GetSizeInfoFlag(desiredImageSize);
+ SHSTOCKICONID stockIconID = GetStockIconIDForName(stockIcon);
+ if (stockIconID == SIID_INVALID) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
- SHSTOCKICONINFO sii = {0};
- sii.cbSize = sizeof(sii);
- HRESULT hr = pSHGetStockIconInfo(stockIconID, infoFlags, &sii);
+ UINT infoFlags = SHGSI_ICON;
+ infoFlags |= GetSizeInfoFlag(desiredImageSize);
- if (SUCCEEDED(hr)) {
- *hIcon = sii.hIcon;
- } else {
- rv = NS_ERROR_FAILURE;
- }
- } else {
- rv = NS_ERROR_NOT_AVAILABLE;
- }
+ SHSTOCKICONINFO sii = {0};
+ sii.cbSize = sizeof(sii);
+ HRESULT hr = SHGetStockIconInfo(stockIconID, infoFlags, &sii);
- if (hShellDLL) {
- ::FreeLibrary(hShellDLL);
+ if (SUCCEEDED(hr)) {
+ *hIcon = sii.hIcon;
+ } else {
+ rv = NS_ERROR_FAILURE;
}
return rv;
diff --git a/toolkit/components/alerts/nsAlertsService.cpp b/toolkit/components/alerts/nsAlertsService.cpp
index 35418dd17..dd67ad983 100644
--- a/toolkit/components/alerts/nsAlertsService.cpp
+++ b/toolkit/components/alerts/nsAlertsService.cpp
@@ -22,6 +22,10 @@
#include "nsIFaviconService.h"
#endif // MOZ_PLACES
+#ifdef XP_WIN
+#include <shellapi.h>
+#endif
+
using namespace mozilla;
using mozilla::dom::ContentChild;
@@ -154,23 +158,12 @@ bool nsAlertsService::ShouldShowAlert()
bool result = true;
#ifdef XP_WIN
- HMODULE shellDLL = ::LoadLibraryW(L"shell32.dll");
- if (!shellDLL)
- return result;
-
- SHQueryUserNotificationStatePtr pSHQueryUserNotificationState =
- (SHQueryUserNotificationStatePtr) ::GetProcAddress(shellDLL, "SHQueryUserNotificationState");
-
- if (pSHQueryUserNotificationState) {
- MOZ_QUERY_USER_NOTIFICATION_STATE qstate;
- if (SUCCEEDED(pSHQueryUserNotificationState(&qstate))) {
- if (qstate != QUNS_ACCEPTS_NOTIFICATIONS) {
- result = false;
- }
+ QUERY_USER_NOTIFICATION_STATE qstate;
+ if (SUCCEEDED(SHQueryUserNotificationState(&qstate))) {
+ if (qstate != QUNS_ACCEPTS_NOTIFICATIONS) {
+ result = false;
}
}
-
- ::FreeLibrary(shellDLL);
#endif
return result;
diff --git a/toolkit/components/alerts/nsAlertsService.h b/toolkit/components/alerts/nsAlertsService.h
index 3f23eaabf..d2b2e1e6c 100644
--- a/toolkit/components/alerts/nsAlertsService.h
+++ b/toolkit/components/alerts/nsAlertsService.h
@@ -10,23 +10,6 @@
#include "nsCOMPtr.h"
#include "nsXULAlerts.h"
-#ifdef XP_WIN
-typedef enum tagMOZ_QUERY_USER_NOTIFICATION_STATE {
- QUNS_NOT_PRESENT = 1,
- QUNS_BUSY = 2,
- QUNS_RUNNING_D3D_FULL_SCREEN = 3,
- QUNS_PRESENTATION_MODE = 4,
- QUNS_ACCEPTS_NOTIFICATIONS = 5,
- QUNS_QUIET_TIME = 6,
- QUNS_IMMERSIVE = 7
-} MOZ_QUERY_USER_NOTIFICATION_STATE;
-
-extern "C" {
-// This function is Windows Vista or later
-typedef HRESULT (__stdcall *SHQueryUserNotificationStatePtr)(MOZ_QUERY_USER_NOTIFICATION_STATE *pquns);
-}
-#endif // defined(XP_WIN)
-
class nsAlertsService : public nsIAlertsService,
public nsIAlertsDoNotDisturb
{
diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp
index 0e85532b9..1e67ea7ce 100644
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -24,6 +24,7 @@
#ifdef XP_WIN
#include <process.h>
+#include <shobjidl.h>
#include "mozilla/ipc/WindowsMessageLoop.h"
#endif
@@ -119,10 +120,6 @@ using mozilla::startup::sChildProcessType;
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
-#ifdef XP_WIN
-static const wchar_t kShellLibraryName[] = L"shell32.dll";
-#endif
-
nsresult
XRE_LockProfileDirectory(nsIFile* aDirectory,
nsISupports* *aLockObject)
@@ -270,26 +267,9 @@ XRE_SetRemoteExceptionHandler(const char* aPipe/*= 0*/)
void
SetTaskbarGroupId(const nsString& aId)
{
- typedef HRESULT (WINAPI * SetCurrentProcessExplicitAppUserModelIDPtr)(PCWSTR AppID);
-
- SetCurrentProcessExplicitAppUserModelIDPtr funcAppUserModelID = nullptr;
-
- HMODULE hDLL = ::LoadLibraryW(kShellLibraryName);
-
- funcAppUserModelID = (SetCurrentProcessExplicitAppUserModelIDPtr)
- GetProcAddress(hDLL, "SetCurrentProcessExplicitAppUserModelID");
-
- if (!funcAppUserModelID) {
- ::FreeLibrary(hDLL);
- return;
- }
-
- if (FAILED(funcAppUserModelID(aId.get()))) {
+ if (FAILED(SetCurrentProcessExplicitAppUserModelID(aId.get()))) {
NS_WARNING("SetCurrentProcessExplicitAppUserModelID failed for child process.");
}
-
- if (hDLL)
- ::FreeLibrary(hDLL);
}
#endif
diff --git a/widget/windows/WinTaskbar.cpp b/widget/windows/WinTaskbar.cpp
index a2c553dea..530cfd5b9 100644
--- a/widget/windows/WinTaskbar.cpp
+++ b/widget/windows/WinTaskbar.cpp
@@ -34,8 +34,6 @@
#include <propkey.h>
#include <shellapi.h>
-const wchar_t kShellLibraryName[] = L"shell32.dll";
-
static NS_DEFINE_CID(kJumpListBuilderCID, NS_WIN_JUMPLISTBUILDER_CID);
namespace {
@@ -77,30 +75,14 @@ SetWindowAppUserModelProp(mozIDOMWindow *aParent,
if (!toplevelHWND)
return NS_ERROR_INVALID_ARG;
- typedef HRESULT (WINAPI * SHGetPropertyStoreForWindowPtr)
- (HWND hwnd, REFIID riid, void** ppv);
- SHGetPropertyStoreForWindowPtr funcGetProStore = nullptr;
-
- HMODULE hDLL = ::LoadLibraryW(kShellLibraryName);
- funcGetProStore = (SHGetPropertyStoreForWindowPtr)
- GetProcAddress(hDLL, "SHGetPropertyStoreForWindow");
-
- if (!funcGetProStore) {
- FreeLibrary(hDLL);
- return NS_ERROR_NO_INTERFACE;
- }
-
- IPropertyStore* pPropStore;
- if (FAILED(funcGetProStore(toplevelHWND,
- IID_PPV_ARGS(&pPropStore)))) {
- FreeLibrary(hDLL);
+ RefPtr<IPropertyStore> pPropStore;
+ if (FAILED(SHGetPropertyStoreForWindow(toplevelHWND, IID_IPropertyStore,
+ getter_AddRefs(pPropStore)))) {
return NS_ERROR_INVALID_ARG;
}
PROPVARIANT pv;
if (FAILED(InitPropVariantFromString(aIdentifier.get(), &pv))) {
- pPropStore->Release();
- FreeLibrary(hDLL);
return NS_ERROR_UNEXPECTED;
}
@@ -111,8 +93,6 @@ SetWindowAppUserModelProp(mozIDOMWindow *aParent,
}
PropVariantClear(&pv);
- pPropStore->Release();
- FreeLibrary(hDLL);
return rv;
}
@@ -339,30 +319,11 @@ WinTaskbar::GetDefaultGroupId(nsAString & aDefaultGroupId) {
// (static) Called from AppShell
bool
WinTaskbar::RegisterAppUserModelID() {
- SetCurrentProcessExplicitAppUserModelIDPtr funcAppUserModelID = nullptr;
- bool retVal = false;
-
nsAutoString uid;
if (!GetAppUserModelID(uid))
return false;
- HMODULE hDLL = ::LoadLibraryW(kShellLibraryName);
-
- funcAppUserModelID = (SetCurrentProcessExplicitAppUserModelIDPtr)
- GetProcAddress(hDLL, "SetCurrentProcessExplicitAppUserModelID");
-
- if (!funcAppUserModelID) {
- ::FreeLibrary(hDLL);
- return false;
- }
-
- if (SUCCEEDED(funcAppUserModelID(uid.get())))
- retVal = true;
-
- if (hDLL)
- ::FreeLibrary(hDLL);
-
- return retVal;
+ return SUCCEEDED(SetCurrentProcessExplicitAppUserModelID(uid.get()));
}
NS_IMETHODIMP