summaryrefslogtreecommitdiffstats
path: root/win8/delegate_execute/command_execute_impl.cc
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-24 03:27:10 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-24 03:27:10 +0000
commitd052886b2a8e01b4b6d076dfaff43b7b50160bcb (patch)
treef364298572d1f5a5ffc25556c2d4b8f008d06688 /win8/delegate_execute/command_execute_impl.cc
parentb67550ffe0b6c36fcea2f6a95a96e8516bed8d98 (diff)
downloadchromium_src-d052886b2a8e01b4b6d076dfaff43b7b50160bcb.zip
chromium_src-d052886b2a8e01b4b6d076dfaff43b7b50160bcb.tar.gz
chromium_src-d052886b2a8e01b4b6d076dfaff43b7b50160bcb.tar.bz2
Add chrome.exe launch to delegate execute when launching Ash/Metro.
BUG=151718 TEST=The browser process launched for the metro/ash viewer process is not subject to Metro-style message-loop timeout killing. Review URL: https://chromiumcodereview.appspot.com/11419069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8/delegate_execute/command_execute_impl.cc')
-rw-r--r--win8/delegate_execute/command_execute_impl.cc71
1 files changed, 67 insertions, 4 deletions
diff --git a/win8/delegate_execute/command_execute_impl.cc b/win8/delegate_execute/command_execute_impl.cc
index d243546..96ca46b 100644
--- a/win8/delegate_execute/command_execute_impl.cc
+++ b/win8/delegate_execute/command_execute_impl.cc
@@ -59,6 +59,46 @@ HRESULT GetUrlFromShellItem(IShellItem* shell_item, string16* url) {
return S_OK;
}
+bool LaunchChromeBrowserProcess() {
+ FilePath delegate_exe_path;
+ if (!PathService::Get(base::FILE_EXE, &delegate_exe_path))
+ return false;
+
+ // First try and go up a level to find chrome.exe.
+ FilePath chrome_exe_path =
+ delegate_exe_path.DirName()
+ .DirName()
+ .Append(chrome::kBrowserProcessExecutableName);
+ if (!file_util::PathExists(chrome_exe_path)) {
+ // Try looking in the current directory if we couldn't find it one up in
+ // order to support developer installs.
+ chrome_exe_path =
+ delegate_exe_path.DirName()
+ .Append(chrome::kBrowserProcessExecutableName);
+ }
+
+ if (!file_util::PathExists(chrome_exe_path)) {
+ AtlTrace("Could not locate chrome.exe at: %ls\n",
+ chrome_exe_path.value().c_str());
+ return false;
+ }
+
+ CommandLine cl(chrome_exe_path);
+
+ // Prevent a Chrome window from showing up on the desktop.
+ cl.AppendSwitch(switches::kSilentLaunch);
+
+ // Tell Chrome the IPC channel name to use.
+ // TODO(robertshield): Figure out how to get this name to both the launched
+ // desktop browser process and the resulting activated metro process.
+ cl.AppendSwitchASCII(switches::kViewerConnection, "viewer");
+
+ base::LaunchOptions launch_options;
+ launch_options.start_hidden = true;
+
+ return base::LaunchProcess(cl, launch_options, NULL);
+}
+
} // namespace
bool CommandExecuteImpl::path_provider_initialized_ = false;
@@ -103,7 +143,7 @@ bool CommandExecuteImpl::path_provider_initialized_ = false;
// 7- Windows calls CommandExecuteImpl::Execute()
// Here we call GetLaunchMode() which returns the cached answer
// computed at step 5c. which can be:
-// a) ECHUIM_DESKTOP then we call LaunchDestopChrome() that calls
+// a) ECHUIM_DESKTOP then we call LaunchDesktopChrome() that calls
// ::CreateProcess and we exit at this point even on failure.
// b) else we call one of the IApplicationActivationManager activation
// functions depending on the parameters passed in step 4.
@@ -187,6 +227,18 @@ STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) {
if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F11)) {
AtlTrace("Using Shift-F11 debug hook, returning AHE_IMMERSIVE\n");
*pahe = AHE_IMMERSIVE;
+
+#if defined(USE_AURA)
+ // Launch the chrome browser process that metro chrome will connect to.
+ LaunchChromeBrowserProcess();
+#endif
+
+ return S_OK;
+ }
+
+ if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F12)) {
+ AtlTrace("Using Shift-F12 debug hook, returning AHE_DESKTOP\n");
+ *pahe = AHE_DESKTOP;
return S_OK;
}
@@ -196,6 +248,7 @@ STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) {
return E_FAIL;
}
+ bool decision_made = false;
HWND chrome_window = ::FindWindowEx(HWND_MESSAGE, NULL,
chrome::kMessageWindowClass,
user_data_dir.value().c_str());
@@ -217,6 +270,7 @@ STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) {
AtlTrace("Failed to open chrome's process [%d], E_FAIL\n", chrome_pid);
return E_FAIL;
}
+
if (IsImmersiveProcess(process.Get())) {
AtlTrace("Chrome [%d] is inmmersive, AHE_IMMERSIVE\n", chrome_pid);
chrome_mode_ = ECHUIM_IMMERSIVE;
@@ -226,11 +280,20 @@ STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) {
chrome_mode_ = ECHUIM_DESKTOP;
*pahe = AHE_DESKTOP;
}
- return S_OK;
+
+ decision_made = true;
}
- EC_HOST_UI_MODE mode = GetLaunchMode();
- *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE;
+ if (!decision_made) {
+ EC_HOST_UI_MODE mode = GetLaunchMode();
+ *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE;
+ }
+
+#if defined(USE_AURA)
+ if (*pahe == AHE_IMMERSIVE)
+ LaunchChromeBrowserProcess();
+#endif
+
return S_OK;
}