| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 if (hr != S_OK) { | 59 if (hr != S_OK) { |
| 60 AtlTrace("Failed to get display name\n"); | 60 AtlTrace("Failed to get display name\n"); |
| 61 return hr; | 61 return hr; |
| 62 } | 62 } |
| 63 | 63 |
| 64 *url = static_cast<const wchar_t*>(name); | 64 *url = static_cast<const wchar_t*>(name); |
| 65 AtlTrace("Retrieved url from display name %ls\n", url->c_str()); | 65 AtlTrace("Retrieved url from display name %ls\n", url->c_str()); |
| 66 return S_OK; | 66 return S_OK; |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool LaunchChromeBrowserProcess() { | |
| 70 base::FilePath delegate_exe_path; | |
| 71 if (!PathService::Get(base::FILE_EXE, &delegate_exe_path)) | |
| 72 return false; | |
| 73 | |
| 74 // First try and go up a level to find chrome.exe. | |
| 75 base::FilePath chrome_exe_path = | |
| 76 delegate_exe_path.DirName() | |
| 77 .DirName() | |
| 78 .Append(chrome::kBrowserProcessExecutableName); | |
| 79 if (!base::PathExists(chrome_exe_path)) { | |
| 80 // Try looking in the current directory if we couldn't find it one up in | |
| 81 // order to support developer installs. | |
| 82 chrome_exe_path = | |
| 83 delegate_exe_path.DirName() | |
| 84 .Append(chrome::kBrowserProcessExecutableName); | |
| 85 } | |
| 86 | |
| 87 if (!base::PathExists(chrome_exe_path)) { | |
| 88 AtlTrace("Could not locate chrome.exe at: %ls\n", | |
| 89 chrome_exe_path.value().c_str()); | |
| 90 return false; | |
| 91 } | |
| 92 | |
| 93 base::CommandLine cl(chrome_exe_path); | |
| 94 | |
| 95 // Prevent a Chrome window from showing up on the desktop. | |
| 96 cl.AppendSwitch(switches::kSilentLaunch); | |
| 97 | |
| 98 // Tell Chrome to connect to the Metro viewer process. | |
| 99 cl.AppendSwitch(switches::kViewerConnect); | |
| 100 | |
| 101 base::LaunchOptions launch_options; | |
| 102 launch_options.start_hidden = true; | |
| 103 | |
| 104 return base::LaunchProcess(cl, launch_options).IsValid(); | |
| 105 } | |
| 106 | |
| 107 } // namespace | 69 } // namespace |
| 108 | 70 |
| 109 bool CommandExecuteImpl::path_provider_initialized_ = false; | 71 bool CommandExecuteImpl::path_provider_initialized_ = false; |
| 110 | 72 |
| 111 // CommandExecuteImpl is responsible for activating chrome in Windows 8. The | 73 // CommandExecuteImpl is responsible for activating chrome in Windows 8. The |
| 112 // flow is complicated and this tries to highlight the important events. | 74 // flow is complicated and this tries to highlight the important events. |
| 113 // The current approach is to have a single instance of chrome either | 75 // The current approach is to have a single instance of chrome either |
| 114 // running in desktop or metro mode. If there is no current instance then | 76 // running in desktop or metro mode. If there is no current instance then |
| 115 // the desktop shortcut launches desktop chrome and the metro tile or search | 77 // the desktop shortcut launches desktop chrome and the metro tile or search |
| 116 // charm launches metro chrome. | 78 // charm launches metro chrome. |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 AtlTrace("Launch mode forced by cmdline to %s\n", modes[launch_mode]); | 434 AtlTrace("Launch mode forced by cmdline to %s\n", modes[launch_mode]); |
| 473 reg_key.WriteValue(chrome::kLaunchModeValue, | 435 reg_key.WriteValue(chrome::kLaunchModeValue, |
| 474 static_cast<DWORD>(launch_mode)); | 436 static_cast<DWORD>(launch_mode)); |
| 475 return launch_mode; | 437 return launch_mode; |
| 476 } | 438 } |
| 477 | 439 |
| 478 launch_mode = ECHUIM_DESKTOP; | 440 launch_mode = ECHUIM_DESKTOP; |
| 479 launch_mode_determined = true; | 441 launch_mode_determined = true; |
| 480 return launch_mode; | 442 return launch_mode; |
| 481 } | 443 } |
| OLD | NEW |