OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // Implementation of the CommandExecuteImpl class which implements the | 4 // Implementation of the CommandExecuteImpl class which implements the |
5 // IExecuteCommand and related interfaces for handling ShellExecute based | 5 // IExecuteCommand and related interfaces for handling ShellExecute based |
6 // launches of the Chrome browser. | 6 // launches of the Chrome browser. |
7 | 7 |
8 #include "win8/delegate_execute/command_execute_impl.h" | 8 #include "win8/delegate_execute/command_execute_impl.h" |
9 | 9 |
10 #include <shlguid.h> | 10 #include <shlguid.h> |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 | 109 |
110 // CommandExecuteImpl is resposible for activating chrome in Windows 8. The | 110 // CommandExecuteImpl is resposible for activating chrome in Windows 8. The |
111 // flow is complicated and this tries to highlight the important events. | 111 // flow is complicated and this tries to highlight the important events. |
112 // The current approach is to have a single instance of chrome either | 112 // The current approach is to have a single instance of chrome either |
113 // running in desktop or metro mode. If there is no current instance then | 113 // running in desktop or metro mode. If there is no current instance then |
114 // the desktop shortcut launches desktop chrome and the metro tile or search | 114 // the desktop shortcut launches desktop chrome and the metro tile or search |
115 // charm launches metro chrome. | 115 // charm launches metro chrome. |
116 // If chrome is running then focus/activation is given to the existing one | 116 // If chrome is running then focus/activation is given to the existing one |
117 // regarless of what launch point the user used. | 117 // regarless of what launch point the user used. |
118 // | 118 // |
119 // The general flow when chrome is the default browser is as follows: | 119 // The general flow when chrome is the default browser is as follows: |
cpu_(ooo_6.6-7.5)
2014/03/06 23:37:33
line 119 needs rewording.
| |
120 // | 120 // |
121 // 1- User interacts with launch point (icon, tile, search, shellexec, etc) | 121 // 1- User interacts with launch point (icon, tile, search, shellexec, etc) |
122 // 2- Windows finds the appid for launch item and resolves it to chrome | 122 // 2- Windows finds the appid for launch item and resolves it to chrome |
123 // 3- Windows activates CommandExecuteImpl inside a surrogate process | 123 // 3- Windows activates CommandExecuteImpl inside a surrogate process |
124 // 4- Windows calls the following sequence of entry points: | 124 // 4- Windows calls the following sequence of entry points: |
125 // CommandExecuteImpl::SetShowWindow | 125 // CommandExecuteImpl::SetShowWindow |
126 // CommandExecuteImpl::SetPosition | 126 // CommandExecuteImpl::SetPosition |
127 // CommandExecuteImpl::SetDirectory | 127 // CommandExecuteImpl::SetDirectory |
128 // CommandExecuteImpl::SetParameter | 128 // CommandExecuteImpl::SetParameter |
129 // CommandExecuteImpl::SetNoShowUI | 129 // CommandExecuteImpl::SetNoShowUI |
130 // CommandExecuteImpl::SetSelection | 130 // CommandExecuteImpl::SetSelection |
131 // CommandExecuteImpl::Initialize | 131 // CommandExecuteImpl::Initialize |
132 // Up to this point the code basically just gathers values passed in, like | 132 // Up to this point the code basically just gathers values passed in, like |
133 // the launch scheme (or url) and the activation verb. | 133 // the launch scheme (or url) and the activation verb. |
134 // 5- Windows calls CommandExecuteImpl::Getvalue() | 134 // 5- Windows calls CommandExecuteImpl::Getvalue() |
135 // Here we need to return AHE_IMMERSIVE or AHE_DESKTOP. That depends on: | 135 // Here we need to return AHE_IMMERSIVE or AHE_DESKTOP. That depends on: |
136 // a) if run in high-integrity return AHE_DESKTOP | 136 // a) if run in high-integrity return AHE_DESKTOP. |
137 // b) else we return what GetLaunchMode() tells us, which is: | 137 // b) else we return what GetLaunchMode() tells us, which is: |
138 // i) if the command line --force-xxx is present return that | 138 // i) if chrome is not the default browser, return AHE_DESKTOP |
139 // ii) if the registry 'launch_mode' exists return that | 139 // ii) if the command line --force-xxx is present return that |
140 // iii) else return AHE_DESKTOP | 140 // iii) if the registry 'launch_mode' exists return that |
141 // iv) else return AHE_DESKTOP | |
141 // 6- If we returned AHE_IMMERSIVE in step 5 windows might not call us back | 142 // 6- If we returned AHE_IMMERSIVE in step 5 windows might not call us back |
142 // and simply activate chrome in metro by itself, however in some cases | 143 // and simply activate chrome in metro by itself, however in some cases |
143 // it might proceed at step 7. | 144 // it might proceed at step 7. |
144 // As far as we know if we return AHE_DESKTOP then step 7 always happens. | 145 // As far as we know if we return AHE_DESKTOP then step 7 always happens. |
145 // 7- Windows calls CommandExecuteImpl::Execute() | 146 // 7- Windows calls CommandExecuteImpl::Execute() |
146 // Here we call GetLaunchMode() which returns the cached answer | 147 // Here we call GetLaunchMode() which returns the cached answer |
147 // computed at step 5c. which can be: | 148 // computed at step 5c. which can be: |
148 // a) ECHUIM_DESKTOP then we call LaunchDesktopChrome() that calls | 149 // a) ECHUIM_DESKTOP then we call LaunchDesktopChrome() that calls |
149 // ::CreateProcess and we exit at this point even on failure. | 150 // ::CreateProcess and we exit at this point even on failure. |
150 // b) else we call one of the IApplicationActivationManager activation | 151 // b) else we call one of the IApplicationActivationManager activation |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 | 203 |
203 STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) { | 204 STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) { |
204 if (!GetLaunchScheme(&display_name_, &launch_scheme_)) { | 205 if (!GetLaunchScheme(&display_name_, &launch_scheme_)) { |
205 AtlTrace("Failed to get scheme, E_FAIL\n"); | 206 AtlTrace("Failed to get scheme, E_FAIL\n"); |
206 return E_FAIL; | 207 return E_FAIL; |
207 } | 208 } |
208 | 209 |
209 EC_HOST_UI_MODE mode = GetLaunchMode(); | 210 EC_HOST_UI_MODE mode = GetLaunchMode(); |
210 *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE; | 211 *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE; |
211 | 212 |
213 // If we're going to return AHE_IMMERSIVE, then both the browser process and | |
214 // the metro viewer need to launch and connect before the user can start | |
215 // browsing. However we must not launch the metro viewer until we get a | |
216 // call to CommandExecuteImpl::Execute(). If we wait until then to launch | |
217 // the browser process as well, it will appear laggy while they connect to | |
218 // each other, so we pre-launch the browser process now. | |
212 if (*pahe == AHE_IMMERSIVE && verb_ != win8::kMetroViewerConnectVerb) | 219 if (*pahe == AHE_IMMERSIVE && verb_ != win8::kMetroViewerConnectVerb) |
213 LaunchChromeBrowserProcess(); | 220 LaunchChromeBrowserProcess(); |
214 return S_OK; | 221 return S_OK; |
215 } | 222 } |
216 | 223 |
217 STDMETHODIMP CommandExecuteImpl::Execute() { | 224 STDMETHODIMP CommandExecuteImpl::Execute() { |
218 AtlTrace("In %hs\n", __FUNCTION__); | 225 AtlTrace("In %hs\n", __FUNCTION__); |
219 | 226 |
220 if (integrity_level_ == base::HIGH_INTEGRITY) | 227 if (integrity_level_ == base::HIGH_INTEGRITY) |
221 return LaunchDesktopChrome(); | 228 return LaunchDesktopChrome(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 if (launch_mode_determined) | 415 if (launch_mode_determined) |
409 return launch_mode; | 416 return launch_mode; |
410 | 417 |
411 if (integrity_level_ == base::HIGH_INTEGRITY) { | 418 if (integrity_level_ == base::HIGH_INTEGRITY) { |
412 // Metro mode apps don't work in high integrity mode. | 419 // Metro mode apps don't work in high integrity mode. |
413 AtlTrace("High integrity: launching in desktop mode\n"); | 420 AtlTrace("High integrity: launching in desktop mode\n"); |
414 launch_mode = ECHUIM_DESKTOP; | 421 launch_mode = ECHUIM_DESKTOP; |
415 launch_mode_determined = true; | 422 launch_mode_determined = true; |
416 return launch_mode; | 423 return launch_mode; |
417 } | 424 } |
425 | |
426 base::FilePath chrome_exe; | |
427 if (!FindChromeExe(&chrome_exe) || | |
428 ShellUtil::GetChromeDefaultStateFromPath(chrome_exe) != | |
429 ShellUtil::DefaultState::IS_DEFAULT) { | |
430 AtlTrace("Chrome is not default: launching in desktop mode\n"); | |
431 launch_mode = ECHUIM_DESKTOP; | |
432 launch_mode_determined = true; | |
433 return launch_mode; | |
434 } | |
435 | |
418 if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F11)) { | 436 if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F11)) { |
419 AtlTrace("Hotkey: launching in immersive mode\n"); | 437 AtlTrace("Hotkey: launching in immersive mode\n"); |
420 launch_mode = ECHUIM_IMMERSIVE; | 438 launch_mode = ECHUIM_IMMERSIVE; |
421 launch_mode_determined = true; | 439 launch_mode_determined = true; |
422 return launch_mode; | 440 return launch_mode; |
423 } | 441 } |
424 | 442 |
425 // From here on, if we can, we will write the outcome | 443 // From here on, if we can, we will write the outcome |
426 // of this function to the registry. | 444 // of this function to the registry. |
427 if (parameters_.HasSwitch(switches::kForceImmersive)) { | 445 if (parameters_.HasSwitch(switches::kForceImmersive)) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 AtlTrace("Invalid registry launch mode value %u\n", reg_value); | 486 AtlTrace("Invalid registry launch mode value %u\n", reg_value); |
469 launch_mode = ECHUIM_DESKTOP; | 487 launch_mode = ECHUIM_DESKTOP; |
470 } else { | 488 } else { |
471 launch_mode = static_cast<EC_HOST_UI_MODE>(reg_value); | 489 launch_mode = static_cast<EC_HOST_UI_MODE>(reg_value); |
472 AtlTrace("Launch mode forced by registry to %s\n", modes[launch_mode]); | 490 AtlTrace("Launch mode forced by registry to %s\n", modes[launch_mode]); |
473 } | 491 } |
474 | 492 |
475 launch_mode_determined = true; | 493 launch_mode_determined = true; |
476 return launch_mode; | 494 return launch_mode; |
477 } | 495 } |
OLD | NEW |