зеркало из https://github.com/mozilla/pjs.git
Bug 86021 - enable multiple profiles in -turbo mode. r=racham/sr=alecf/a=chofmann
This commit is contained in:
Родитель
fb1391cd6d
Коммит
c02ab62d96
|
@ -251,7 +251,8 @@ NS_IMETHODIMP nsPrefService::ResetUserPrefs()
|
|||
NS_IMETHODIMP nsPrefService::SavePrefFile(nsIFile *aFile)
|
||||
{
|
||||
if (nsnull == aFile) {
|
||||
return savePrefFile(mCurrentFile);
|
||||
// It's possible that we never got a prefs file.
|
||||
return mCurrentFile ? savePrefFile(mCurrentFile) : NS_OK;
|
||||
} else {
|
||||
return savePrefFile(aFile);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ function onCancel()
|
|||
catch (ex) {
|
||||
dump("failed to forget current profile.\n");
|
||||
}
|
||||
ExitApp();
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,12 +126,11 @@ function onFinish()
|
|||
|
||||
if( window.opener ) {
|
||||
window.opener.CreateProfile(profName, profDir);
|
||||
window.close();
|
||||
}
|
||||
else {
|
||||
profile.startApprunner(profName);
|
||||
ExitApp();
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
@ -201,15 +200,3 @@ function processCreateProfileData( aProfName, aProfDir, langcode, regioncode)
|
|||
}
|
||||
}
|
||||
|
||||
/** void ExitApp( void ) ;
|
||||
* - purpose: quits the application properly and finally, stops event loop
|
||||
* - in: nothing
|
||||
* - out: nothing
|
||||
**/
|
||||
function ExitApp()
|
||||
{
|
||||
// Need to call this to stop the event loop
|
||||
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
|
||||
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService);
|
||||
appShell.Quit();
|
||||
}
|
||||
|
|
|
@ -220,7 +220,6 @@ function onStart()
|
|||
}
|
||||
|
||||
profile.startApprunner(profilename);
|
||||
ExitApp();
|
||||
}
|
||||
catch (ex) {
|
||||
//var stringA = gProfileManagerBundle.getString(failProfileStartA);
|
||||
|
@ -236,21 +235,11 @@ function onExit()
|
|||
{
|
||||
try {
|
||||
profile.forgetCurrentProfile();
|
||||
window.close();
|
||||
}
|
||||
catch (ex) {
|
||||
dump("Failed to forget current profile.\n");
|
||||
}
|
||||
ExitApp();
|
||||
}
|
||||
|
||||
// function : <profileSelection.js>::ExitApp();
|
||||
// purpose : halts startup process forcefully
|
||||
function ExitApp()
|
||||
{
|
||||
// Need to call this to stop the event loop
|
||||
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
|
||||
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService);
|
||||
appShell.Quit();
|
||||
}
|
||||
|
||||
function foo()
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
||||
#if defined (XP_UNIX)
|
||||
#elif defined (XP_MAC)
|
||||
|
@ -112,6 +113,11 @@
|
|||
#define CHROME_STYLE nsIWebBrowserChrome::CHROME_ALL | nsIWebBrowserChrome::CHROME_CENTER_SCREEN
|
||||
#endif
|
||||
|
||||
const char* kWindowWatcherContractID = "@mozilla.org/embedcomp/window-watcher;1";
|
||||
const char* kDialogParamBlockContractID = "@mozilla.org/embedcomp/dialogparam;1";
|
||||
|
||||
const char* kDefaultOpenWindowParams = "centerscreen,chrome,modal,titlebar";
|
||||
|
||||
// we want everyone to have the debugging info to the console for now
|
||||
// to help track down profile manager problems
|
||||
// when we ship, we'll turn this off
|
||||
|
@ -468,24 +474,24 @@ nsProfile::LoadDefaultProfileDir(nsCString & profileURLStr, PRBool canInteract)
|
|||
if (profileURLStr.Length() != 0)
|
||||
{
|
||||
if (!canInteract) return NS_ERROR_PROFILE_REQUIRES_INTERACTION;
|
||||
|
||||
NS_WITH_SERVICE(nsIAppShellService, profAppShell, kAppShellServiceCID, &rv);
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> windowWatcher(do_GetService(kWindowWatcherContractID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(profileURL), (const char *)profileURLStr);
|
||||
|
||||
// We need to send a param to OpenWindow if the window is to be considered
|
||||
// a dialog. It needs to be for script security reasons. This param block
|
||||
// will be made use of soon. See bug 66833.
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIXULWindow> profWindow;
|
||||
rv = profAppShell->CreateTopLevelWindow(nsnull, profileURL,
|
||||
PR_TRUE, PR_TRUE, CHROME_STYLE,
|
||||
NS_SIZETOCONTENT, // width
|
||||
NS_SIZETOCONTENT, // height
|
||||
getter_AddRefs(profWindow));
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = windowWatcher->OpenWindow(nsnull,
|
||||
profileURLStr.get(),
|
||||
"_blank",
|
||||
kDefaultOpenWindowParams,
|
||||
ioParamBlock,
|
||||
getter_AddRefs(newWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Start an event loop for the modal dialog
|
||||
rv = profAppShell->Run();
|
||||
}
|
||||
|
||||
PRBool confirmAutomigration = PR_FALSE;
|
||||
|
|
|
@ -171,4 +171,12 @@ interface nsIAppShellService : nsISupports
|
|||
* only once per application session.
|
||||
*/
|
||||
void HideSplashScreen();
|
||||
|
||||
/**
|
||||
* We may need to show a XUL dialog before there are any other windows.
|
||||
* In this case we don't nescesarily want to quit when it is closed.
|
||||
* Use with extreme caution.
|
||||
*/
|
||||
|
||||
attribute boolean quitOnLastWindowClosing;
|
||||
};
|
||||
|
|
|
@ -143,6 +143,12 @@
|
|||
* mode is currently Win32-only (and may really only make
|
||||
* sense there) and is intended to be initiated from the
|
||||
* Windows startup folder at system initialization.
|
||||
*
|
||||
* needsProfileUI - Boolean attribute used when running in "server mode."
|
||||
* If the "server mode" caused profile dialogs to be
|
||||
* suppressed, this should be set to true. When the server
|
||||
* starts a real session, it will call on the profile mgr
|
||||
* to do what it needed to do when this attribute is true.
|
||||
*/
|
||||
|
||||
interface nsIDOMWindow;
|
||||
|
@ -161,4 +167,5 @@ interface nsINativeAppSupport : nsISupports {
|
|||
// Server mode.
|
||||
attribute boolean isServerMode;
|
||||
void startServerMode();
|
||||
attribute boolean needsProfileUI;
|
||||
};
|
||||
|
|
|
@ -80,7 +80,8 @@ nsAppShellService::nsAppShellService() :
|
|||
mDeleteCalled( PR_FALSE ),
|
||||
mSplashScreen( nsnull ),
|
||||
mNativeAppSupport( nsnull ),
|
||||
mShuttingDown( PR_FALSE )
|
||||
mShuttingDown( PR_FALSE ),
|
||||
mQuitOnLastWindowClosing( PR_TRUE )
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -810,21 +811,33 @@ nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow)
|
|||
if (!hiddenWin)
|
||||
Quit();
|
||||
#else
|
||||
// Check to see if we're in server mode, first.
|
||||
if ( mNativeAppSupport ) {
|
||||
PRBool serverMode = PR_FALSE;
|
||||
mNativeAppSupport->GetIsServerMode( &serverMode );
|
||||
if ( serverMode ) {
|
||||
// Then don't quit.
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
// Check to see if we should quit in this case.
|
||||
PRBool serverMode = PR_FALSE;
|
||||
if (mNativeAppSupport)
|
||||
mNativeAppSupport->GetIsServerMode(&serverMode);
|
||||
if (!mQuitOnLastWindowClosing || serverMode)
|
||||
return NS_OK;
|
||||
|
||||
Quit();
|
||||
#endif
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShellService::GetQuitOnLastWindowClosing(PRBool *aQuitOnLastWindowClosing)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aQuitOnLastWindowClosing);
|
||||
*aQuitOnLastWindowClosing = mQuitOnLastWindowClosing;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShellService::SetQuitOnLastWindowClosing(PRBool aQuitOnLastWindowClosing)
|
||||
{
|
||||
mQuitOnLastWindowClosing = aQuitOnLastWindowClosing;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -73,6 +73,7 @@ protected:
|
|||
|
||||
// Set when the appshell service is going away.
|
||||
PRBool mShuttingDown;
|
||||
PRBool mQuitOnLastWindowClosing;
|
||||
|
||||
// A "last event" that is used to flush the appshell's event queue.
|
||||
struct ExitEvent {
|
||||
|
|
|
@ -832,10 +832,20 @@ static nsresult InitializeProfileService(nsICmdLineService *cmdLineArgs)
|
|||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get profile manager");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsINativeAppSupport> nativeApp;
|
||||
PRBool serverMode = PR_FALSE;
|
||||
GetNativeAppSupport(getter_AddRefs(nativeApp));
|
||||
if (nativeApp)
|
||||
nativeApp->GetIsServerMode(&serverMode);
|
||||
|
||||
// If we are in server mode, profile mgr cannot show UI
|
||||
rv = profileMgr->StartupWithArgs(cmdLineArgs, !IsAppInServerMode());
|
||||
rv = profileMgr->StartupWithArgs(cmdLineArgs, !serverMode);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "StartupWithArgs failed\n");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (serverMode && rv == NS_ERROR_PROFILE_REQUIRES_INTERACTION) {
|
||||
nativeApp->SetNeedsProfileUI(PR_TRUE);
|
||||
rv = NS_OK;
|
||||
}
|
||||
else 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
|
||||
// this can happen, if the user hits Cancel or Exit in the profile manager dialogs
|
||||
|
@ -1095,11 +1105,14 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appshell");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
rv = InitializeWindowCreator();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize window creator");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// So we can open and close windows during startup
|
||||
appShell->SetQuitOnLastWindowClosing(PR_FALSE);
|
||||
|
||||
// Initialize Profile Service here.
|
||||
rv = InitializeProfileService(cmdLineArgs);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -1134,7 +1147,9 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||
nsCOMPtr<nsIWalletService> walletService(do_GetService(NS_WALLETSERVICE_CONTRACTID, &rv));
|
||||
|
||||
InitCachePrefs();
|
||||
|
||||
|
||||
// From this point on, should be true
|
||||
appShell->SetQuitOnLastWindowClosing(PR_TRUE);
|
||||
// Start main event loop
|
||||
rv = appShell->Run();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appshell");
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
nsNativeAppSupportBase::nsNativeAppSupportBase()
|
||||
: mRefCnt( 0 ),
|
||||
mSplash( 0 ),
|
||||
mServerMode( PR_FALSE ) {
|
||||
mServerMode( PR_FALSE ),
|
||||
mNeedsProfileUI( PR_FALSE ) {
|
||||
}
|
||||
|
||||
nsNativeAppSupportBase::~nsNativeAppSupportBase() {
|
||||
|
@ -92,6 +93,19 @@ nsNativeAppSupportBase::GetIsServerMode(PRBool *aIsServerMode) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::GetNeedsProfileUI(PRBool *aNeedsProfileUI) {
|
||||
NS_ENSURE_ARG_POINTER(aNeedsProfileUI);
|
||||
*aNeedsProfileUI = mNeedsProfileUI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::SetNeedsProfileUI(PRBool aNeedsProfileUI) {
|
||||
mNeedsProfileUI = aNeedsProfileUI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::StartServerMode() {
|
||||
return NS_OK;
|
||||
|
|
|
@ -53,5 +53,6 @@ public:
|
|||
nsrefcnt mRefCnt;
|
||||
nsCOMPtr<nsISplashScreen> mSplash;
|
||||
PRBool mServerMode;
|
||||
PRBool mNeedsProfileUI;
|
||||
}; // class nsSplashScreenWin
|
||||
|
||||
|
|
|
@ -143,6 +143,12 @@
|
|||
* mode is currently Win32-only (and may really only make
|
||||
* sense there) and is intended to be initiated from the
|
||||
* Windows startup folder at system initialization.
|
||||
*
|
||||
* needsProfileUI - Boolean attribute used when running in "server mode."
|
||||
* If the "server mode" caused profile dialogs to be
|
||||
* suppressed, this should be set to true. When the server
|
||||
* starts a real session, it will call on the profile mgr
|
||||
* to do what it needed to do when this attribute is true.
|
||||
*/
|
||||
|
||||
interface nsIDOMWindow;
|
||||
|
@ -161,4 +167,5 @@ interface nsINativeAppSupport : nsISupports {
|
|||
// Server mode.
|
||||
attribute boolean isServerMode;
|
||||
void startServerMode();
|
||||
attribute boolean needsProfileUI;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче