зеркало из https://github.com/mozilla/pjs.git
Bug 86922 - app hangs after profile migration dialog. r=danm/sr=alecf/a=chofmann
This commit is contained in:
Родитель
ac6bfbd8f6
Коммит
8cc6ac99dc
|
@ -57,7 +57,7 @@
|
|||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
||||
#if defined(XP_MAC) && !defined(DEBUG)
|
||||
//lower silly optimization level which takes an age for this file.
|
||||
|
@ -309,38 +309,19 @@ NS_IMETHODIMP
|
|||
nsPrefMigration::ProcessPrefs(PRBool showProgressAsModalWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> pmprogressURL;
|
||||
|
||||
NS_WITH_SERVICE(nsIAppShellService, PMProgressAppShell,
|
||||
kAppShellServiceCID, &rv);
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> windowWatcher(do_GetService("@mozilla.org/embedcomp/window-watcher;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(pmprogressURL), PREF_MIGRATION_PROGRESS_URL);
|
||||
// WindowWatcher can work with or without parent window
|
||||
rv = windowWatcher->OpenWindow(nsnull,
|
||||
PREF_MIGRATION_PROGRESS_URL,
|
||||
"_blank",
|
||||
"centerscreen,modal,titlebar",
|
||||
nsnull,
|
||||
getter_AddRefs(mPMProgressWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = PMProgressAppShell->CreateTopLevelWindow(nsnull, pmprogressURL,
|
||||
PR_TRUE, PR_TRUE, CHROME_STYLE,
|
||||
NS_SIZETOCONTENT, NS_SIZETOCONTENT,
|
||||
getter_AddRefs(mPMProgressWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (showProgressAsModalWindow) {
|
||||
nsCOMPtr<nsIInterfaceRequestor> progressRequestor(do_QueryInterface(mPMProgressWindow));
|
||||
nsCOMPtr<nsIWebBrowserChrome> progressChrome;
|
||||
|
||||
if (progressRequestor)
|
||||
progressRequestor->GetInterface(NS_GET_IID(nsIWebBrowserChrome), getter_AddRefs(progressChrome));
|
||||
|
||||
if (progressChrome)
|
||||
progressChrome->ShowAsModal();
|
||||
NS_ASSERTION(progressChrome, "show modal window failed: no available chrome");
|
||||
}
|
||||
else {
|
||||
// we are automatically migrating the profile, so there is no
|
||||
// profile manager window to run the dialog as modal in front of.
|
||||
PMProgressAppShell->Run();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -435,19 +416,22 @@ extern "C" void ProfileMigrationController(void *data)
|
|||
NS_IMETHODIMP
|
||||
nsPrefMigration::WindowCloseCallback()
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsresult rv = mPMProgressWindow->GetDocShell(getter_AddRefs(docShell));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(docShell));
|
||||
if (treeItem) {
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||
rv = treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(treeOwner));
|
||||
if (baseWindow) (void)baseWindow->Destroy();
|
||||
}
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptGO(do_QueryInterface(mPMProgressWindow));
|
||||
if (!scriptGO) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
rv = scriptGO->GetDocShell(getter_AddRefs(docShell));
|
||||
if (!docShell) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(docShell));
|
||||
if (!treeItem) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||
treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||
if (!treeOwner) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(treeOwner));
|
||||
if (baseWindow)
|
||||
baseWindow->Destroy();
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("end of pref migration\n");
|
||||
#endif
|
||||
|
@ -458,62 +442,30 @@ nsPrefMigration::WindowCloseCallback()
|
|||
NS_IMETHODIMP
|
||||
nsPrefMigration::ShowSpaceDialog(PRInt32 *choice)
|
||||
{
|
||||
// Get the DocShell
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsresult rv = mPMProgressWindow->GetDocShell(getter_AddRefs(docShell));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWindowWatcher> windowWatcher(do_GetService("@mozilla.org/embedcomp/window-watcher;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Now convert the DocShell to an nsIDOMWindowInternal
|
||||
nsCOMPtr<nsIDOMWindowInternal> PMDOMWindow(do_GetInterface(docShell));
|
||||
if (!PMDOMWindow) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the script global object for the window
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo;
|
||||
sgo = do_QueryInterface(PMDOMWindow);
|
||||
if (!sgo) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the script context from the global context
|
||||
nsCOMPtr<nsIScriptContext> scriptContext;
|
||||
sgo->GetContext( getter_AddRefs(scriptContext));
|
||||
if (!scriptContext) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the JSContext from the script context
|
||||
JSContext* jsContext = (JSContext*)scriptContext->GetNativeContext();
|
||||
if (!jsContext) return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Create the nsIDialogParamBlock to pass the trigger
|
||||
// list to the dialog
|
||||
//-----------------------------------------------------
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock;
|
||||
rv = nsComponentManager::CreateInstance("@mozilla.org/embedcomp/dialogparam;1",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDialogParamBlock),
|
||||
getter_AddRefs(ioParamBlock));
|
||||
|
||||
|
||||
if ( NS_SUCCEEDED( rv ) )
|
||||
ioParamBlock->SetInt(0,3); //set the Retry, CreateNew and Cancel buttons
|
||||
|
||||
nsCOMPtr<nsISupportsInterfacePointer> ifptr =
|
||||
do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ifptr->SetData(ioParamBlock);
|
||||
ifptr->SetDataIID(&NS_GET_IID(nsIDialogParamBlock));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = PMDOMWindow->OpenDialog(NS_ConvertASCIItoUCS2(PREF_MIGRATION_NO_SPACE_URL),
|
||||
NS_LITERAL_STRING("_blank"),
|
||||
NS_LITERAL_STRING("chrome,modal"),
|
||||
ifptr, getter_AddRefs(newWindow));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
//Now get which button was pressed from the ParamBlock
|
||||
ioParamBlock->GetInt( 0, choice );
|
||||
}
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return rv;
|
||||
ioParamBlock->SetInt(0,3); //set the Retry, CreateNew and Cancel buttons
|
||||
|
||||
// WindowWatcher can work with or without parent window
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = windowWatcher->OpenWindow(mPMProgressWindow,
|
||||
PREF_MIGRATION_NO_SPACE_URL,
|
||||
"_blank",
|
||||
"dialog,chrome,centerscreen,modal,titlebar",
|
||||
ioParamBlock,
|
||||
getter_AddRefs(newWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Now get which button was pressed from the ParamBlock
|
||||
if (NS_SUCCEEDED(rv))
|
||||
ioParamBlock->GetInt( 0, choice );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ class nsPrefMigration: public nsIPrefMigration
|
|||
nsCOMPtr<nsIPref> m_prefs;
|
||||
nsCOMPtr<nsILocalFile> m_prefsFile;
|
||||
nsCOMPtr<nsIDOMWindowInternal> m_parentWindow;
|
||||
nsCOMPtr<nsIXULWindow> mPMProgressWindow;
|
||||
nsCOMPtr<nsIDOMWindow> mPMProgressWindow;
|
||||
};
|
||||
|
||||
#endif /* nsPrefMigration_h___ */
|
||||
|
|
|
@ -1919,114 +1919,22 @@ nsProfile::MigrateProfile(const PRUnichar* profileName, PRBool showProgressAsMod
|
|||
nsresult
|
||||
nsProfile::ShowProfileWizard(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool hasParentWindow = PR_FALSE;
|
||||
nsCOMPtr<nsIDOMWindowInternal> PMDOMWindow;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWindowWatcher> windowWatcher(do_GetService(kWindowWatcherContractID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the window mediator
|
||||
NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||
|
||||
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator))))
|
||||
{
|
||||
// Get each dom window
|
||||
PRBool more;
|
||||
windowEnumerator->HasMoreElements(&more);
|
||||
while (more)
|
||||
{
|
||||
nsCOMPtr<nsISupports> protoWindow;
|
||||
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
||||
if (NS_SUCCEEDED(rv) && protoWindow)
|
||||
{
|
||||
PMDOMWindow = do_QueryInterface(protoWindow);
|
||||
if (PMDOMWindow)
|
||||
{
|
||||
hasParentWindow = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
windowEnumerator->HasMoreElements(&more);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasParentWindow)
|
||||
{
|
||||
// Get the script global object for the window
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo;
|
||||
sgo = do_QueryInterface(PMDOMWindow);
|
||||
if (!sgo) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the script context from the global context
|
||||
nsCOMPtr<nsIScriptContext> scriptContext;
|
||||
sgo->GetContext( getter_AddRefs(scriptContext));
|
||||
if (!scriptContext) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the JSContext from the script context
|
||||
JSContext* jsContext = (JSContext*)scriptContext->GetNativeContext();
|
||||
if (!jsContext) return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Create the nsIDialogParamBlock to pass the trigger
|
||||
// list to the dialog
|
||||
//-----------------------------------------------------
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock;
|
||||
rv = nsComponentManager::CreateInstance("@mozilla.org/embedcomp/dialogparam;1",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDialogParamBlock),
|
||||
getter_AddRefs(ioParamBlock));
|
||||
|
||||
|
||||
if ( NS_SUCCEEDED( rv ) )
|
||||
ioParamBlock->SetInt(0,4); // standard wizard buttons
|
||||
|
||||
nsCOMPtr<nsISupportsInterfacePointer> ifptr =
|
||||
do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ifptr->SetData(ioParamBlock);
|
||||
ifptr->SetDataIID(&NS_GET_IID(nsIDialogParamBlock));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = PMDOMWindow->OpenDialog(NS_ConvertUTF8toUCS2(PROFILE_WIZARD_URL),
|
||||
NS_LITERAL_STRING("_blank"),
|
||||
NS_LITERAL_STRING("chrome,modal"),
|
||||
ifptr, getter_AddRefs(newWindow));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No parent window is available.
|
||||
// So, Create top level window with create profile wizard
|
||||
NS_WITH_SERVICE(nsIAppShellService, wizAppShell,
|
||||
kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIURI> profURI;
|
||||
rv = NS_NewURI(getter_AddRefs(profURI), NS_LITERAL_CSTRING(PROFILE_WIZARD_URL).get());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
rv = wizAppShell->CreateTopLevelWindow(nsnull, profURI,
|
||||
PR_TRUE, PR_TRUE, CHROME_STYLE,
|
||||
NS_SIZETOCONTENT, // width
|
||||
NS_SIZETOCONTENT, // height
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
/*
|
||||
* Bring up the wizard...
|
||||
*/
|
||||
rv = wizAppShell->Run();
|
||||
}
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
ioParamBlock->SetInt(0,4); // standard wizard buttons
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = windowWatcher->OpenWindow(nsnull,
|
||||
PROFILE_WIZARD_URL,
|
||||
"_blank",
|
||||
kDefaultOpenWindowParams,
|
||||
ioParamBlock,
|
||||
getter_AddRefs(newWindow));
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsProfile::ProfileExists(const PRUnichar *profileName, PRBool *exists)
|
||||
|
|
|
@ -802,6 +802,9 @@ nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
if (0 == cnt)
|
||||
{
|
||||
if (!mQuitOnLastWindowClosing)
|
||||
return NS_OK;
|
||||
|
||||
#if XP_MAC
|
||||
// if no hidden window is available (perhaps due to initial
|
||||
// Profile Manager window being cancelled), then just quit. We don't have
|
||||
|
@ -815,7 +818,7 @@ nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow)
|
|||
PRBool serverMode = PR_FALSE;
|
||||
if (mNativeAppSupport)
|
||||
mNativeAppSupport->GetIsServerMode(&serverMode);
|
||||
if (!mQuitOnLastWindowClosing || serverMode)
|
||||
if (serverMode)
|
||||
return NS_OK;
|
||||
|
||||
Quit();
|
||||
|
|
Загрузка…
Ссылка в новой задаче