mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 949590 - When switching browsers, wait for the previous instance to close the profile before launching. r=bbondy
This commit is contained in:
parent
e7e88b45f2
commit
5e155a22a4
@ -15,7 +15,7 @@
|
||||
#include <atlbase.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
//#define SHOW_CONSOLE 1
|
||||
#define SHOW_CONSOLE 1
|
||||
extern HANDLE sCon;
|
||||
extern LPCWSTR metroDX10Available;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <shellapi.h>
|
||||
#include <wininet.h>
|
||||
|
||||
#ifdef SHOW_CONSOLE
|
||||
//#ifdef SHOW_CONSOLE
|
||||
#define DEBUG_DELAY_SHUTDOWN 1
|
||||
#endif
|
||||
|
||||
|
@ -4072,12 +4072,6 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
||||
// We have an application restart don't do any shutdown checks here
|
||||
// In particular we don't want to poison IO for checking late-writes.
|
||||
gShutdownChecks = SCM_NOTHING;
|
||||
|
||||
#if defined(MOZ_METRO) && defined(XP_WIN)
|
||||
if (rv == NS_SUCCESS_RESTART_METRO_APP) {
|
||||
LaunchDefaultMetroBrowser();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!mShuttingDown) {
|
||||
@ -4114,7 +4108,15 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
||||
MOZ_gdk_display_close(mGdkDisplay);
|
||||
#endif
|
||||
|
||||
rv = LaunchChild(mNativeApp, true);
|
||||
#if defined(MOZ_METRO) && defined(XP_WIN)
|
||||
if (rv == NS_SUCCESS_RESTART_METRO_APP) {
|
||||
LaunchDefaultMetroBrowser();
|
||||
rv = NS_OK;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rv = LaunchChild(mNativeApp, true);
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
|
||||
|
@ -113,8 +113,8 @@ HRESULT SHCreateShellItemArrayFromShellItemDynamic(IShellItem *psi, REFIID riid,
|
||||
return hr;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WinLaunchDeferredMetroFirefox(bool aInMetro)
|
||||
HRESULT
|
||||
WinLaunchDeferredMetroFirefox()
|
||||
{
|
||||
// Create an instance of the Firefox Metro DEH which is used to launch the browser
|
||||
const CLSID CLSID_FirefoxMetroDEH = {0x5100FEC1,0x212B, 0x4BF5 ,{0x9B,0xF8, 0x3E,0x65, 0x0F,0xD7,0x94,0xA3}};
|
||||
@ -126,51 +126,46 @@ WinLaunchDeferredMetroFirefox(bool aInMetro)
|
||||
IID_IExecuteCommand,
|
||||
getter_AddRefs(executeCommand));
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
return hr;
|
||||
|
||||
// Get the currently running exe path
|
||||
WCHAR exePath[MAX_PATH + 1] = { L'\0' };
|
||||
if (!::GetModuleFileNameW(0, exePath, MAX_PATH))
|
||||
return FALSE;
|
||||
return hr;
|
||||
|
||||
// Convert the path to a long path since GetModuleFileNameW returns the path
|
||||
// that was used to launch Firefox which is not necessarily a long path.
|
||||
if (!::GetLongPathNameW(exePath, exePath, MAX_PATH))
|
||||
return FALSE;
|
||||
return hr;
|
||||
|
||||
// Create an IShellItem for the current browser path
|
||||
nsRefPtr<IShellItem> shellItem;
|
||||
hr = WinUtils::SHCreateItemFromParsingName(exePath, nullptr, IID_IShellItem,
|
||||
getter_AddRefs(shellItem));
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
return hr;
|
||||
|
||||
// Convert to an IShellItemArray which is used for the path to launch
|
||||
nsRefPtr<IShellItemArray> shellItemArray;
|
||||
hr = SHCreateShellItemArrayFromShellItemDynamic(shellItem, IID_IShellItemArray, getter_AddRefs(shellItemArray));
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
return hr;
|
||||
|
||||
// Set the path to launch and parameters needed
|
||||
nsRefPtr<IObjectWithSelection> selection;
|
||||
hr = executeCommand->QueryInterface(IID_IObjectWithSelection, getter_AddRefs(selection));
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
return hr;
|
||||
hr = selection->SetSelection(shellItemArray);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
return hr;
|
||||
|
||||
if (aInMetro) {
|
||||
hr = executeCommand->SetParameters(L"--metro-restart");
|
||||
} else {
|
||||
hr = executeCommand->SetParameters(L"--desktop-restart");
|
||||
}
|
||||
hr = executeCommand->SetParameters(L"--metro-restart");
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
return hr;
|
||||
|
||||
// Run the default browser through the DEH
|
||||
hr = executeCommand->Execute();
|
||||
return SUCCEEDED(hr);
|
||||
return executeCommand->Execute();
|
||||
}
|
||||
|
||||
// Called by appstartup->run in xre, which is initiated by a call to
|
||||
@ -200,22 +195,24 @@ MetroAppShell::Run(void)
|
||||
mozilla::widget::StopAudioSession();
|
||||
|
||||
nsCOMPtr<nsIAppStartup> appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID));
|
||||
bool restartingInMetro = false, restarting = false;
|
||||
bool restartingInMetro = false, restartingInDesktop = false;
|
||||
|
||||
if (appStartup && NS_SUCCEEDED(appStartup->GetRestartingTouchEnvironment(&restartingInMetro)) &&
|
||||
restartingInMetro) {
|
||||
WinLaunchDeferredMetroFirefox(true);
|
||||
}
|
||||
|
||||
if (!appStartup || NS_FAILED(appStartup->GetRestarting(&restarting))) {
|
||||
if (!appStartup || NS_FAILED(appStartup->GetRestarting(&restartingInDesktop))) {
|
||||
WinUtils::Log("appStartup->GetRestarting() unsuccessful");
|
||||
}
|
||||
|
||||
// This calls XRE_metroShutdown() in xre. This will also destroy
|
||||
// MessagePump.
|
||||
if (appStartup && NS_SUCCEEDED(appStartup->GetRestartingTouchEnvironment(&restartingInMetro)) &&
|
||||
restartingInMetro) {
|
||||
restartingInDesktop = false;
|
||||
}
|
||||
|
||||
// This calls XRE_metroShutdown() in xre. Shuts down gecko, including
|
||||
// releasing the profile, and destroys MessagePump.
|
||||
sMetroApp->ShutdownXPCOM();
|
||||
|
||||
if (restarting) {
|
||||
// Handle update restart or browser switch requests
|
||||
if (restartingInDesktop) {
|
||||
WinUtils::Log("Relaunching desktop browser");
|
||||
SHELLEXECUTEINFOW sinfo;
|
||||
memset(&sinfo, 0, sizeof(SHELLEXECUTEINFOW));
|
||||
sinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
|
||||
@ -228,6 +225,9 @@ MetroAppShell::Run(void)
|
||||
sinfo.lpParameters = L"--desktop-restart";
|
||||
sinfo.nShow = SW_SHOWNORMAL;
|
||||
ShellExecuteEx(&sinfo);
|
||||
} else if (restartingInMetro) {
|
||||
HRESULT hresult = WinLaunchDeferredMetroFirefox();
|
||||
WinUtils::Log("Relaunching metro browser (hr=%X)", hresult);
|
||||
}
|
||||
|
||||
// This will free the real main thread in CoreApplication::Run()
|
||||
|
Loading…
Reference in New Issue
Block a user