Bug 932664 - Link clicks and file activations should open in the currently opened browser no matter which environment. r=bbondy
authorMarina Samuel <msamuel@mozilla.com>
Tue, 19 Nov 2013 13:14:40 -0500
changeset 158063 ef5ef338cfcf733f8b35d73690915a672a848c98
parent 158062 bd024cf6af34e48f619313ae6f4178b8fd1284b1
child 158064 fb3ae66def36f3781fed5d4d819f07c279912ca0
push id25732
push usercbook@mozilla.com
push dateFri, 29 Nov 2013 09:13:44 +0000
treeherdermozilla-central@0e6b2fa40378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs932664
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 932664 - Link clicks and file activations should open in the currently opened browser no matter which environment. r=bbondy
browser/metro/shell/commandexecutehandler/CEHHelper.cpp
browser/metro/shell/commandexecutehandler/CEHHelper.h
browser/metro/shell/commandexecutehandler/CommandExecuteHandler.cpp
widget/windows/winrt/MetroAppShell.cpp
--- a/browser/metro/shell/commandexecutehandler/CEHHelper.cpp
+++ b/browser/metro/shell/commandexecutehandler/CEHHelper.cpp
@@ -76,29 +76,31 @@ IsImmersiveProcessDynamic(HANDLE process
   }
 
   BOOL bImmersiveProcess = IsImmersiveProcessPtr(process);
   FreeLibrary(user32DLL);
   return bImmersiveProcess;
 }
 
 bool
-IsImmersiveProcessRunning(const wchar_t *processName)
+IsProcessRunning(const wchar_t *processName, bool bCheckIfMetro)
 {
   bool exists = false;
   PROCESSENTRY32W entry;
   entry.dwSize = sizeof(PROCESSENTRY32W);
 
   HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
 
   if (Process32First(snapshot, &entry)) {
     while (!exists && Process32Next(snapshot, &entry)) {
       if (!_wcsicmp(entry.szExeFile, processName)) {
         HANDLE process = OpenProcess(GENERIC_READ, FALSE, entry.th32ProcessID);
-        if (IsImmersiveProcessDynamic(process)) {
+        bool isImmersiveProcess = IsImmersiveProcessDynamic(process);
+        if ((bCheckIfMetro && isImmersiveProcess) ||
+            (!bCheckIfMetro && !isImmersiveProcess)) {
           exists = true;
         }
         CloseHandle(process);
       }
     }
   }
 
   CloseHandle(snapshot);
--- a/browser/metro/shell/commandexecutehandler/CEHHelper.h
+++ b/browser/metro/shell/commandexecutehandler/CEHHelper.h
@@ -23,9 +23,9 @@ void Log(const wchar_t *fmt, ...);
 #if defined(SHOW_CONSOLE)
 void SetupConsole();
 #endif
 
 bool IsDX10Available();
 bool GetDWORDRegKey(LPCWSTR name, DWORD &value);
 bool SetDWORDRegKey(LPCWSTR name, DWORD value);
 bool IsImmersiveProcessDynamic(HANDLE process);
-bool IsImmersiveProcessRunning(const wchar_t *processName);
+bool IsProcessRunning(const wchar_t *processName, bool bCheckIfMetro);
--- a/browser/metro/shell/commandexecutehandler/CommandExecuteHandler.cpp
+++ b/browser/metro/shell/commandexecutehandler/CommandExecuteHandler.cpp
@@ -260,16 +260,24 @@ public:
 
   // IExecuteCommandApplicationHostEnvironment
   IFACEMETHODIMP GetValue(AHE_TYPE *aLaunchType)
   {
     Log(L"IExecuteCommandApplicationHostEnvironment::GetValue()");
     *aLaunchType = AHE_DESKTOP;
     mIsDesktopRequest = true;
 
+    if (!mIsRestartMetroRequest && IsProcessRunning(kFirefoxExe, false)) {
+      return S_OK;
+    } else if (!mIsRestartDesktopRequest && IsProcessRunning(kMetroFirefoxExe, true)) {
+      *aLaunchType = AHE_IMMERSIVE;
+      mIsDesktopRequest = false;
+      return S_OK;
+    }
+
     if (!mUnkSite) {
       Log(L"No mUnkSite.");
       return S_OK;
     }
 
     if (mIsRestartDesktopRequest) {
       Log(L"Restarting in desktop host environment.");
       return S_OK;
@@ -679,17 +687,17 @@ DelayedExecuteThread(LPVOID param)
 
   CComPtr<IApplicationActivationManager> activateMgr;
   if (FAILED(PrepareActivationManager(activateMgr))) {
       Log(L"Warning: Could not prepare activation manager");
   }
 
   size_t currentWaitTime = 0;
   while(currentWaitTime < RESTART_WAIT_TIMEOUT) {
-    if (!IsImmersiveProcessRunning(kMetroFirefoxExe))
+    if (!IsProcessRunning(kMetroFirefoxExe, true))
       break;
     currentWaitTime += RESTART_WAIT_PER_RETRY;
     Sleep(RESTART_WAIT_PER_RETRY);
   }
 
   Log(L"Done waiting, getting app ID");
   // Activate the application as long as we can obtian the appModelID
   WCHAR appModelID[256];
--- a/widget/windows/winrt/MetroAppShell.cpp
+++ b/widget/windows/winrt/MetroAppShell.cpp
@@ -220,16 +220,17 @@ MetroAppShell::Run(void)
         memset(&sinfo, 0, sizeof(SHELLEXECUTEINFOW));
         sinfo.cbSize       = sizeof(SHELLEXECUTEINFOW);
         // Per the Metro style enabled desktop browser, for some reason,
         // SEE_MASK_FLAG_LOG_USAGE is needed to change from immersive mode
         // to desktop.
         sinfo.fMask        = SEE_MASK_FLAG_LOG_USAGE;
         sinfo.lpFile       = L"http://-desktop";
         sinfo.lpVerb       = L"open";
+        sinfo.lpParameters = L"--desktop-restart";
         sinfo.nShow        = SW_SHOWNORMAL;
         ShellExecuteEx(&sinfo);
       }
 
       // This will free the real main thread in CoreApplication::Run()
       // once winrt cleans up this thread.
       sMetroApp->CoreExit();
     }