bug 352424. Default Application on Vista not working. r=rob_strong
This commit is contained in:
@@ -192,6 +192,7 @@ typedef struct {
|
||||
#define SOP "\\shell\\open\\command"
|
||||
#define DDE "\\shell\\open\\ddeexec\\"
|
||||
#define DDE_NAME "Firefox" // This must be kept in sync with ID_DDE_APPLICATION_NAME as defined in splash.rc
|
||||
#define APP_REG_NAME L"Firefox"
|
||||
#define DDE_COMMAND "\"%1\",,0,0,,,,"
|
||||
#define DDE_IFEXEC ",,0,0,,,,"
|
||||
#define EXE "firefox.exe"
|
||||
@@ -289,9 +290,126 @@ static SETTING gSettings[] = {
|
||||
// firefox.exe\shell\safemode (default) REG_SZ Firefox &Safe Mode
|
||||
};
|
||||
|
||||
|
||||
#ifndef __shobjidl_h__
|
||||
|
||||
// This block should be removed when our build environment
|
||||
// is migrated to the latest windows sdk.
|
||||
|
||||
typedef enum tagASSOCIATIONLEVEL
|
||||
{
|
||||
AL_MACHINE,
|
||||
AL_EFFECTIVE,
|
||||
AL_USER
|
||||
} ASSOCIATIONLEVEL;
|
||||
|
||||
typedef enum tagASSOCIATIONTYPE
|
||||
{
|
||||
AT_FILEEXTENSION,
|
||||
AT_URLPROTOCOL,
|
||||
AT_STARTMENUCLIENT,
|
||||
AT_MIMETYPE
|
||||
} ASSOCIATIONTYPE;
|
||||
|
||||
MIDL_INTERFACE("4e530b0a-e611-4c77-a3ac-9031d022281b")
|
||||
IApplicationAssociationRegistration : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryCurrentDefault(LPCWSTR pszQuery,
|
||||
ASSOCIATIONTYPE atQueryType,
|
||||
ASSOCIATIONLEVEL alQueryLevel,
|
||||
LPWSTR *ppszAssociation) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryAppIsDefault(LPCWSTR pszQuery,
|
||||
ASSOCIATIONTYPE atQueryType,
|
||||
ASSOCIATIONLEVEL alQueryLevel,
|
||||
LPCWSTR pszAppRegistryName,
|
||||
BOOL *pfDefault) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryAppIsDefaultAll(ASSOCIATIONLEVEL alQueryLevel,
|
||||
LPCWSTR pszAppRegistryName,
|
||||
BOOL *pfDefault) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetAppAsDefault(LPCWSTR pszAppRegistryName,
|
||||
LPCWSTR pszSet,
|
||||
ASSOCIATIONTYPE atSetType) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetAppAsDefaultAll(LPCWSTR pszAppRegistryName) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE ClearUserAssociations( void) = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
static const CLSID CLSID_ApplicationAssociationReg = {0x591209C7,0x767B,0x42B2,{0x9F,0xBA,0x44,0xEE,0x46,0x15,0xF2,0xC7}};
|
||||
static const IID IID_IApplicationAssociationReg = {0x4e530b0a,0xe611,0x4c77,{0xa3,0xac,0x90,0x31,0xd0,0x22,0x28,0x1b}};
|
||||
|
||||
|
||||
PRBool
|
||||
nsWindowsShellService::IsDefaultBrowserVista(PRBool aStartupCheck, PRBool* aIsDefaultBrowser)
|
||||
{
|
||||
IApplicationAssociationRegistration* pAAR;
|
||||
|
||||
HRESULT hr = CoCreateInstance (CLSID_ApplicationAssociationReg,
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IApplicationAssociationReg,
|
||||
(void**)&pAAR);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE,
|
||||
APP_REG_NAME,
|
||||
aIsDefaultBrowser);
|
||||
|
||||
// If this is the first browser window, maintain internal state that we've
|
||||
// checked this session (so that subsequent window opens don't show the
|
||||
// default browser dialog).
|
||||
if (aStartupCheck)
|
||||
mCheckedThisSession = PR_TRUE;
|
||||
|
||||
pAAR->Release();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsWindowsShellService::SetDefaultBrowserVista()
|
||||
{
|
||||
IApplicationAssociationRegistration* pAAR;
|
||||
|
||||
HRESULT hr = CoCreateInstance (CLSID_ApplicationAssociationReg,
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IApplicationAssociationReg,
|
||||
(void**)&pAAR);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = pAAR->SetAppAsDefaultAll(APP_REG_NAME);
|
||||
|
||||
pAAR->Release();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsWindowsShellService::RestoreFileSettingsVista()
|
||||
{
|
||||
// With the new vista API, there is no need to restore file setting.
|
||||
|
||||
if (GetVersion() >= 6)
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefaultBrowser)
|
||||
{
|
||||
|
||||
if (IsDefaultBrowserVista(aStartupCheck, aIsDefaultBrowser))
|
||||
return NS_OK;
|
||||
|
||||
SETTING* settings;
|
||||
SETTING* end = gSettings + sizeof(gSettings)/sizeof(SETTING);
|
||||
|
||||
@@ -358,6 +476,9 @@ nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefault
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUsers)
|
||||
{
|
||||
if (SetDefaultBrowserVista())
|
||||
return NS_OK;
|
||||
|
||||
// Locate the Backup key
|
||||
HKEY backupKey;
|
||||
nsresult rv = OpenKeyForWriting(MOZ_BACKUP_REGISTRY, &backupKey, aForAllUsers, PR_TRUE);
|
||||
@@ -474,6 +595,9 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::RestoreFileSettings(PRBool aForAllUsers)
|
||||
{
|
||||
if (RestoreFileSettingsVista())
|
||||
return NS_OK;
|
||||
|
||||
// Locate the Backup key
|
||||
HKEY backupKey;
|
||||
nsresult rv = OpenKeyForWriting(MOZ_BACKUP_REGISTRY, &backupKey, aForAllUsers, PR_FALSE);
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "nsIWindowsShellService.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <ole2.h>
|
||||
|
||||
class nsWindowsShellService : public nsIWindowsShellService
|
||||
{
|
||||
@@ -55,6 +56,10 @@ public:
|
||||
NS_DECL_NSIWINDOWSSHELLSERVICE
|
||||
|
||||
protected:
|
||||
PRBool IsDefaultBrowserVista(PRBool aStartupCheck, PRBool* aIsDefaultBrowser);
|
||||
PRBool SetDefaultBrowserVista();
|
||||
PRBool RestoreFileSettingsVista();
|
||||
|
||||
PRBool GetMailAccountKey(HKEY* aResult);
|
||||
void SetRegKey(const char* aKeyName, const char* aValueName,
|
||||
const char* aValue, PRBool aBackup, HKEY aBackupKey,
|
||||
|
||||
Reference in New Issue
Block a user