Bug 81706 - Disable "turbo" mode when multiple profiles are present. r=law/sr=blake/a=asa
git-svn-id: svn://10.0.0.236/trunk@97241 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
0c19e11337
commit
6a21a75a68
@ -25,11 +25,21 @@
|
||||
interface nsICmdLineService;
|
||||
interface nsIFile;
|
||||
|
||||
%{C++
|
||||
#define NS_ERROR_PROFILE_REQUIRES_INTERACTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_PROFILE, 1)
|
||||
%}
|
||||
|
||||
[scriptable, uuid(2f977d42-5485-11d4-87e2-0010a4e75ef2)]
|
||||
interface nsIProfileInternal : nsIProfile {
|
||||
|
||||
[noscript] void startupWithArgs(in nsICmdLineService cmdLine);
|
||||
void startup(in wstring filename);
|
||||
/**
|
||||
* Starts up the profile manager
|
||||
*
|
||||
* @param cmdLine Arguments passed from command line - can be null
|
||||
* @param canInteract Whether dialogs can be shown during startup
|
||||
* If false and dialogs would need to be shown, returns NS_ERROR_PROFILE_REQUIRES_INTERRACTION
|
||||
*/
|
||||
[noscript] void startupWithArgs(in nsICmdLineService cmdLine, in boolean canInteract);
|
||||
|
||||
long get4xProfileCount();
|
||||
|
||||
|
||||
@ -333,10 +333,6 @@ NS_INTERFACE_MAP_END
|
||||
/*
|
||||
* nsIProfile Implementation
|
||||
*/
|
||||
NS_IMETHODIMP nsProfile::Startup(const PRUnichar *filename)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProfile::GetAutomigrate(PRBool *aAutomigrate)
|
||||
@ -355,7 +351,7 @@ nsProfile::SetAutomigrate(PRBool aAutomigrate)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProfile::StartupWithArgs(nsICmdLineService *cmdLineArgs)
|
||||
nsProfile::StartupWithArgs(nsICmdLineService *cmdLineArgs, PRBool canInteract)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -376,7 +372,7 @@ nsProfile::StartupWithArgs(nsICmdLineService *cmdLineArgs)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!profileDirSet) {
|
||||
rv = LoadDefaultProfileDir(profileURLStr);
|
||||
rv = LoadDefaultProfileDir(profileURLStr, canInteract);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
@ -430,7 +426,7 @@ nsProfile::StartupWithArgs(nsICmdLineService *cmdLineArgs)
|
||||
|
||||
|
||||
nsresult
|
||||
nsProfile::LoadDefaultProfileDir(nsCString & profileURLStr)
|
||||
nsProfile::LoadDefaultProfileDir(nsCString & profileURLStr, PRBool canInteract)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> profileURL;
|
||||
@ -471,6 +467,8 @@ nsProfile::LoadDefaultProfileDir(nsCString & profileURLStr)
|
||||
|
||||
if (profileURLStr.Length() != 0)
|
||||
{
|
||||
if (!canInteract) return NS_ERROR_PROFILE_REQUIRES_INTERACTION;
|
||||
|
||||
NS_WITH_SERVICE(nsIAppShellService, profAppShell, kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -508,7 +506,7 @@ nsProfile::LoadDefaultProfileDir(nsCString & profileURLStr)
|
||||
// so they don't want to automatically migrate
|
||||
// so call this again with the profile manager ui
|
||||
nsCString profileManagerUrl(PROFILE_MANAGER_URL);
|
||||
rv = LoadDefaultProfileDir(profileManagerUrl);
|
||||
rv = LoadDefaultProfileDir(profileManagerUrl, canInteract);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ private:
|
||||
nsresult ProcessArgs(nsICmdLineService *service,
|
||||
PRBool *profileDirSet,
|
||||
nsCString & profileURLStr);
|
||||
nsresult LoadDefaultProfileDir(nsCString & profileURLStr);
|
||||
nsresult LoadDefaultProfileDir(nsCString & profileURLStr, PRBool canInterract);
|
||||
nsresult CopyDefaultFile(nsIFile *profDefaultsDir,
|
||||
nsIFile *newProfDir,
|
||||
const char *fileName);
|
||||
|
||||
@ -206,6 +206,30 @@ nsresult NS_CreateNativeAppSupport( nsINativeAppSupport **aResult )
|
||||
|
||||
#endif
|
||||
|
||||
static nsresult GetNativeAppSupport(nsINativeAppSupport** aNativeApp)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNativeApp);
|
||||
*aNativeApp = nsnull;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID));
|
||||
if (appShellService)
|
||||
appShellService->GetNativeAppSupport(aNativeApp);
|
||||
|
||||
return *aNativeApp ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
static PRBool IsAppInServerMode()
|
||||
{
|
||||
PRBool serverMode = PR_FALSE;
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
GetNativeAppSupport(getter_AddRefs(nativeApp));
|
||||
if (nativeApp)
|
||||
nativeApp->GetIsServerMode(&serverMode);
|
||||
|
||||
return serverMode;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This routine translates the nsresult into a platform specific return
|
||||
* code for the application...
|
||||
@ -702,19 +726,13 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs)
|
||||
if ( !more )
|
||||
{
|
||||
// If starting up in server mode, then we do things differently.
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID));
|
||||
if (appShellService) {
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
appShellService->GetNativeAppSupport(getter_AddRefs(nativeApp));
|
||||
if (nativeApp) {
|
||||
PRBool serverMode = PR_FALSE;
|
||||
nativeApp->GetIsServerMode(&serverMode);
|
||||
if (serverMode) {
|
||||
// Create special Nav window.
|
||||
nativeApp->StartServerMode();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
PRBool serverMode;
|
||||
rv = GetNativeAppSupport(getter_AddRefs(nativeApp));
|
||||
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(nativeApp->GetIsServerMode(&serverMode)) && serverMode) {
|
||||
// Create special Nav window.
|
||||
nativeApp->StartServerMode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// No window exists so lets create a browser one
|
||||
@ -814,7 +832,9 @@ static nsresult InitializeProfileService(nsICmdLineService *cmdLineArgs)
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get profile manager");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = profileMgr->StartupWithArgs(cmdLineArgs);
|
||||
// If we are in server mode, profile mgr cannot show UI
|
||||
rv = profileMgr->StartupWithArgs(cmdLineArgs, !IsAppInServerMode());
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "StartupWithArgs failed\n");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// if we get here, and we don't have a current profile, return a failure so we will exit
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user