mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 760680 - Update shell integration default browser check for Windows 8. r=jimm
This commit is contained in:
parent
a5c6b246c7
commit
a6c8a636a0
@ -321,11 +321,20 @@ nsWindowsShellService::ShortcutMaintenance()
|
||||
return LaunchHelper(appHelperPath);
|
||||
}
|
||||
|
||||
static bool
|
||||
IsWin8OrLater()
|
||||
{
|
||||
OSVERSIONINFOW osInfo;
|
||||
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
||||
GetVersionExW(&osInfo);
|
||||
return osInfo.dwMajorVersion > 6 ||
|
||||
osInfo.dwMajorVersion >= 6 && osInfo.dwMinorVersion >= 2;
|
||||
}
|
||||
|
||||
bool
|
||||
nsWindowsShellService::IsDefaultBrowserVista(bool* aIsDefaultBrowser)
|
||||
{
|
||||
IApplicationAssociationRegistration* pAAR;
|
||||
|
||||
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
@ -339,6 +348,20 @@ nsWindowsShellService::IsDefaultBrowserVista(bool* aIsDefaultBrowser)
|
||||
&res);
|
||||
*aIsDefaultBrowser = res;
|
||||
|
||||
if (*aIsDefaultBrowser && IsWin8OrLater()) {
|
||||
// Make sure the Prog ID matches what we have
|
||||
LPWSTR registeredApp;
|
||||
hr = pAAR->QueryCurrentDefault(L"http", AT_URLPROTOCOL, AL_EFFECTIVE,
|
||||
®isteredApp);
|
||||
if (SUCCEEDED(hr)) {
|
||||
LPCWSTR firefoxHTTPProgID = L"FirefoxURL";
|
||||
*aIsDefaultBrowser = !wcsicmp(registeredApp, firefoxHTTPProgID);
|
||||
CoTaskMemFree(registeredApp);
|
||||
} else {
|
||||
*aIsDefaultBrowser = false;
|
||||
}
|
||||
}
|
||||
|
||||
pAAR->Release();
|
||||
return true;
|
||||
}
|
||||
@ -354,7 +377,12 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
|
||||
// default browser dialog).
|
||||
if (aStartupCheck)
|
||||
mCheckedThisSession = true;
|
||||
return IsDefaultBrowser(aIsDefaultBrowser);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWindowsShellService::IsDefaultBrowser(bool* aIsDefaultBrowser)
|
||||
{
|
||||
*aIsDefaultBrowser = true;
|
||||
|
||||
PRUnichar exePath[MAX_BUF];
|
||||
@ -544,9 +572,51 @@ nsWindowsShellService::GetCanSetDesktopBackground(bool* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
DynSHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
|
||||
{
|
||||
typedef HRESULT (WINAPI * SHOpenWithDialogPtr)(HWND hwndParent,
|
||||
const OPENASINFO *poainfo);
|
||||
static SHOpenWithDialogPtr SHOpenWithDialogFn = NULL;
|
||||
if (!SHOpenWithDialogFn) {
|
||||
// shell32.dll is in the knownDLLs list so will always be loaded from the
|
||||
// system32 directory.
|
||||
static const PRUnichar kSehllLibraryName[] = L"shell32.dll";
|
||||
HMODULE shellDLL = ::LoadLibraryW(kSehllLibraryName);
|
||||
if (!shellDLL) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
SHOpenWithDialogFn =
|
||||
(SHOpenWithDialogPtr)GetProcAddress(shellDLL, "SHOpenWithDialog");
|
||||
FreeLibrary(shellDLL);
|
||||
|
||||
if (!SHOpenWithDialogFn) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCEEDED(SHOpenWithDialogFn(hwndParent, poainfo)) ? NS_OK :
|
||||
NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers)
|
||||
{
|
||||
if (IsWin8OrLater()) {
|
||||
OPENASINFO info;
|
||||
info.pcszFile = L"http";
|
||||
info.pcszClass = NULL;
|
||||
info.oaifInFlags = OAIF_FORCE_REGISTRATION |
|
||||
OAIF_URL_PROTOCOL |
|
||||
OAIF_REGISTER_EXT;
|
||||
nsresult rv = DynSHOpenWithDialog(NULL, &info);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
bool isDefaultBrowser = false;
|
||||
return SUCCEEDED(IsDefaultBrowser(&isDefaultBrowser)) &&
|
||||
isDefaultBrowser ? S_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString appHelperPath;
|
||||
if (NS_FAILED(GetHelperPath(appHelperPath)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -25,7 +25,8 @@ public:
|
||||
NS_DECL_NSIWINDOWSSHELLSERVICE
|
||||
|
||||
protected:
|
||||
bool IsDefaultBrowserVista(bool* aIsDefaultBrowser);
|
||||
static nsresult IsDefaultBrowser(bool* aIsDefaultBrowser);
|
||||
static bool IsDefaultBrowserVista(bool* aIsDefaultBrowser);
|
||||
|
||||
private:
|
||||
#if defined(MOZ_MAINTENANCE_SERVICE)
|
||||
|
Loading…
Reference in New Issue
Block a user