diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-24 03:27:10 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-24 03:27:10 +0000 |
commit | d052886b2a8e01b4b6d076dfaff43b7b50160bcb (patch) | |
tree | f364298572d1f5a5ffc25556c2d4b8f008d06688 /win8 | |
parent | b67550ffe0b6c36fcea2f6a95a96e8516bed8d98 (diff) | |
download | chromium_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')
-rw-r--r-- | win8/delegate_execute/command_execute_impl.cc | 71 | ||||
-rw-r--r-- | win8/metro_driver/chrome_app_view_ash.cc | 46 |
2 files changed, 80 insertions, 37 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; } diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc index 2214185..5733ce1 100644 --- a/win8/metro_driver/chrome_app_view_ash.cc +++ b/win8/metro_driver/chrome_app_view_ash.cc @@ -78,38 +78,14 @@ class ChromeChannelListener : public IPC::Listener { } }; -bool LaunchChromeAndWaitForIPCConnection(const std::string& channel_name) { - FilePath chrome_path; - if (!PathService::Get(base::FILE_EXE, &chrome_path)) - return false; - CommandLine cl(chrome_path); - - FilePath user_data_dir = CommandLine::ForCurrentProcess()-> - GetSwitchValuePath(switches::kUserDataDir); - if (!user_data_dir.empty()) - cl.AppendSwitchPath(switches::kUserDataDir, user_data_dir); - - // Prevent a Chrome window from showing up on the desktop. - cl.AppendSwitch(switches::kSilentLaunch); - - // Tell Chrome the IPC channel name to use. - cl.AppendSwitchASCII(switches::kViewerConnection, channel_name); - - base::LaunchOptions launch_options; - launch_options.force_breakaway_from_job_ = true; - launch_options.start_hidden = true; - - if (base::LaunchProcess(cl, launch_options, NULL)) { - int ms_elapsed = 0; - while (!IPC::Channel::IsNamedServerInitialized(channel_name) && - ms_elapsed < 10000) { - ms_elapsed += 500; - Sleep(500); - } - return IPC::Channel::IsNamedServerInitialized(channel_name); +bool WaitForChromeIPCConnection(const std::string& channel_name) { + int ms_elapsed = 0; + while (!IPC::Channel::IsNamedServerInitialized(channel_name) && + ms_elapsed < 10000) { + ms_elapsed += 500; + Sleep(500); } - - return false; + return IPC::Channel::IsNamedServerInitialized(channel_name); } // This class helps decoding the pointer properties of an event. @@ -329,10 +305,14 @@ ChromeAppViewAsh::Run() { io_thread.StartWithOptions(options); std::string ipc_channel_name("viewer"); - ipc_channel_name.append(IPC::Channel::GenerateUniqueRandomChannelID()); + + // TODO(robertshield): Figure out how to receive and append the channel ID + // from the delegate_execute instance that launched the browser process. + // See http://crbug.com/162474 + // ipc_channel_name.append(IPC::Channel::GenerateUniqueRandomChannelID()); // Start up Chrome and wait for the desired IPC server connection to exist. - LaunchChromeAndWaitForIPCConnection(ipc_channel_name); + WaitForChromeIPCConnection(ipc_channel_name); // In Aura mode we create an IPC channel to the browser, then ask it to // connect to us. |