From 054164d5ba844bfa5470bd650b90c12035699c35 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 15 Dec 2005 10:26:11 +0100 Subject: [PATCH] mshtml: Set Gecko's profile. Make sure that Gecko components are registered. --- dlls/mshtml/nsembed.c | 52 +++++++++++++++++++++++++++++++++++++---- dlls/mshtml/nsiface.idl | 20 ++++++++++++++++ 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index bd36126a5da..bce48ed0ea2 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -38,6 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); #define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1" #define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1" #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1" +#define NS_PROFILE_CONTRACTID "@mozilla.org/profile/manager;1" #define APPSTARTUP_TOPIC "app-startup" @@ -210,11 +211,40 @@ static BOOL get_wine_gecko_path(PRUnichar *gre_path) return TRUE; } +static void set_profile(void) +{ + nsIProfile *profile; + PRBool exists = FALSE; + nsresult nsres; + + static const WCHAR wszMSHTML[] = {'M','S','H','T','M','L',0}; + + nsres = nsIServiceManager_GetServiceByContactID(pServMgr, NS_PROFILE_CONTRACTID, + &IID_nsIProfile, (void**)&profile); + if(NS_FAILED(nsres)) { + ERR("Could not get profile service: %08lx\n", nsres); + return; + } + + nsres = nsIProfile_ProfileExists(profile, wszMSHTML, &exists); + if(!exists) { + nsres = nsIProfile_CreateNewProfile(profile, wszMSHTML, NULL, NULL, FALSE); + if(NS_FAILED(nsres)) + ERR("CreateNewProfile failed: %08lx\n", nsres); + } + + nsres = nsIProfile_SetCurrentProfile(profile, wszMSHTML); + if(NS_FAILED(nsres)) + ERR("SetCurrentProfile failed: %08lx\n", nsres); + + nsIProfile_Release(profile); +} + static BOOL load_gecko() { nsresult nsres; nsIObserver *pStartNotif; - nsIComponentRegistrar *registrar; + nsIComponentRegistrar *registrar = NULL; nsString path; nsIFile *gre_dir; PRUnichar gre_path[MAX_PATH]; @@ -292,6 +322,19 @@ static BOOL load_gecko() if(NS_FAILED(nsres)) ERR("Could not get nsIComponentManager: %08lx\n", nsres); + nsres = NS_GetComponentRegistrar(®istrar); + if(NS_SUCCEEDED(nsres)) { + nsres = nsIComponentRegistrar_AutoRegister(registrar, NULL); + if(NS_FAILED(nsres)) + ERR("AutoRegister(NULL) failed: %08lx\n", nsres); + + nsres = nsIComponentRegistrar_AutoRegister(registrar, gre_dir); + if(NS_FAILED(nsres)) + ERR("AutoRegister(gre_dir) failed: %08lx\n", nsres); + }else { + ERR("NS_GetComponentRegistrar failed: %08lx\n", nsres); + } + nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_APPSTARTUPNOTIFIER_CONTRACTID, NULL, &IID_nsIObserver, (void**)&pStartNotif); if(NS_SUCCEEDED(nsres)) { @@ -304,14 +347,13 @@ static BOOL load_gecko() ERR("could not get appstartup-notifier: %08lx\n", nsres); } - nsres = NS_GetComponentRegistrar(®istrar); - if(NS_SUCCEEDED(nsres)) { + if(registrar) { register_nsservice(registrar); nsIComponentRegistrar_Release(registrar); - }else { - ERR("NS_GetComponentRegistrar failed: %08lx\n", nsres); } + set_profile(); + return TRUE; } diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 390e115b600..077ed2549de 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -515,3 +515,23 @@ interface nsIPromptService : nsISupports const PRUnichar *aText, PRUint32 aCount, const PRUnichar **aSelectList, PRInt32 *aOutSelection, PRBool *_retval); } + +[ + object, + uuid(02b0625a-e7f3-11d2-9f5a-006008a6efe9) +] +interface nsIProfile : nsISupports +{ + nsresult GetProfileCount(PRInt32 *aProfileCount); + nsresult GetProfileList(PRUint32 *length, PRUnichar ***profileNames); + nsresult ProfileExists(const PRUnichar *profileName, PRBool *_retval); + nsresult GetCurrentProfile(PRUnichar * *aCurrentProfile); + nsresult SetCurrentProfile(const PRUnichar * aCurrentProfile); + nsresult ShutDownCurrentProfile(PRUint32 shutDownType); + nsresult CreateNewProfile(const PRUnichar *profileName, + const PRUnichar *nativeProfileDir, const PRUnichar *langcode, + PRBool useExistingDir); + nsresult RenameProfile(const PRUnichar *oldName, const PRUnichar *newName); + nsresult DeleteProfile(const PRUnichar *name, PRBool canDeleteFiles); + nsresult CloneProfile(const PRUnichar *profileName); +}