| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 AtlTrace("Failed to get display name\n"); | 53 AtlTrace("Failed to get display name\n"); |
| 54 return hr; | 54 return hr; |
| 55 } | 55 } |
| 56 | 56 |
| 57 *url = static_cast<const wchar_t*>(name); | 57 *url = static_cast<const wchar_t*>(name); |
| 58 AtlTrace("Retrieved url from display name %ls\n", url->c_str()); | 58 AtlTrace("Retrieved url from display name %ls\n", url->c_str()); |
| 59 return S_OK; | 59 return S_OK; |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool LaunchChromeBrowserProcess() { | 62 bool LaunchChromeBrowserProcess() { |
| 63 FilePath delegate_exe_path; | 63 base::FilePath delegate_exe_path; |
| 64 if (!PathService::Get(base::FILE_EXE, &delegate_exe_path)) | 64 if (!PathService::Get(base::FILE_EXE, &delegate_exe_path)) |
| 65 return false; | 65 return false; |
| 66 | 66 |
| 67 // First try and go up a level to find chrome.exe. | 67 // First try and go up a level to find chrome.exe. |
| 68 FilePath chrome_exe_path = | 68 base::FilePath chrome_exe_path = |
| 69 delegate_exe_path.DirName() | 69 delegate_exe_path.DirName() |
| 70 .DirName() | 70 .DirName() |
| 71 .Append(chrome::kBrowserProcessExecutableName); | 71 .Append(chrome::kBrowserProcessExecutableName); |
| 72 if (!file_util::PathExists(chrome_exe_path)) { | 72 if (!file_util::PathExists(chrome_exe_path)) { |
| 73 // Try looking in the current directory if we couldn't find it one up in | 73 // Try looking in the current directory if we couldn't find it one up in |
| 74 // order to support developer installs. | 74 // order to support developer installs. |
| 75 chrome_exe_path = | 75 chrome_exe_path = |
| 76 delegate_exe_path.DirName() | 76 delegate_exe_path.DirName() |
| 77 .Append(chrome::kBrowserProcessExecutableName); | 77 .Append(chrome::kBrowserProcessExecutableName); |
| 78 } | 78 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 return S_OK; | 236 return S_OK; |
| 237 } | 237 } |
| 238 | 238 |
| 239 if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F12)) { | 239 if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F12)) { |
| 240 AtlTrace("Using Shift-F12 debug hook, returning AHE_DESKTOP\n"); | 240 AtlTrace("Using Shift-F12 debug hook, returning AHE_DESKTOP\n"); |
| 241 *pahe = AHE_DESKTOP; | 241 *pahe = AHE_DESKTOP; |
| 242 return S_OK; | 242 return S_OK; |
| 243 } | 243 } |
| 244 | 244 |
| 245 FilePath user_data_dir; | 245 base::FilePath user_data_dir; |
| 246 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 246 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
| 247 AtlTrace("Failed to get chrome's data dir path, E_FAIL\n"); | 247 AtlTrace("Failed to get chrome's data dir path, E_FAIL\n"); |
| 248 return E_FAIL; | 248 return E_FAIL; |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool decision_made = false; | 251 bool decision_made = false; |
| 252 HWND chrome_window = ::FindWindowEx(HWND_MESSAGE, NULL, | 252 HWND chrome_window = ::FindWindowEx(HWND_MESSAGE, NULL, |
| 253 chrome::kMessageWindowClass, | 253 chrome::kMessageWindowClass, |
| 254 user_data_dir.value().c_str()); | 254 user_data_dir.value().c_str()); |
| 255 if (chrome_window) { | 255 if (chrome_window) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 return S_OK; | 369 return S_OK; |
| 370 } | 370 } |
| 371 | 371 |
| 372 STDMETHODIMP CommandExecuteImpl::AllowForegroundTransfer(void* reserved) { | 372 STDMETHODIMP CommandExecuteImpl::AllowForegroundTransfer(void* reserved) { |
| 373 AtlTrace("In %hs\n", __FUNCTION__); | 373 AtlTrace("In %hs\n", __FUNCTION__); |
| 374 return S_OK; | 374 return S_OK; |
| 375 } | 375 } |
| 376 | 376 |
| 377 // Returns false if chrome.exe cannot be found. | 377 // Returns false if chrome.exe cannot be found. |
| 378 // static | 378 // static |
| 379 bool CommandExecuteImpl::FindChromeExe(FilePath* chrome_exe) { | 379 bool CommandExecuteImpl::FindChromeExe(base::FilePath* chrome_exe) { |
| 380 AtlTrace("In %hs\n", __FUNCTION__); | 380 AtlTrace("In %hs\n", __FUNCTION__); |
| 381 // Look for chrome.exe one folder above delegate_execute.exe (as expected in | 381 // Look for chrome.exe one folder above delegate_execute.exe (as expected in |
| 382 // Chrome installs). Failing that, look for it alonside delegate_execute.exe. | 382 // Chrome installs). Failing that, look for it alonside delegate_execute.exe. |
| 383 FilePath dir_exe; | 383 base::FilePath dir_exe; |
| 384 if (!PathService::Get(base::DIR_EXE, &dir_exe)) { | 384 if (!PathService::Get(base::DIR_EXE, &dir_exe)) { |
| 385 AtlTrace("Failed to get current exe path\n"); | 385 AtlTrace("Failed to get current exe path\n"); |
| 386 return false; | 386 return false; |
| 387 } | 387 } |
| 388 | 388 |
| 389 *chrome_exe = dir_exe.DirName().Append(chrome::kBrowserProcessExecutableName); | 389 *chrome_exe = dir_exe.DirName().Append(chrome::kBrowserProcessExecutableName); |
| 390 if (!file_util::PathExists(*chrome_exe)) { | 390 if (!file_util::PathExists(*chrome_exe)) { |
| 391 *chrome_exe = dir_exe.Append(chrome::kBrowserProcessExecutableName); | 391 *chrome_exe = dir_exe.Append(chrome::kBrowserProcessExecutableName); |
| 392 if (!file_util::PathExists(*chrome_exe)) { | 392 if (!file_util::PathExists(*chrome_exe)) { |
| 393 AtlTrace("Failed to find chrome exe file\n"); | 393 AtlTrace("Failed to find chrome exe file\n"); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 AtlTrace("Invalid registry launch mode value %u\n", reg_value); | 547 AtlTrace("Invalid registry launch mode value %u\n", reg_value); |
| 548 launch_mode = ECHUIM_DESKTOP; | 548 launch_mode = ECHUIM_DESKTOP; |
| 549 } else { | 549 } else { |
| 550 AtlTrace("Launch mode forced by registry to %s\n", modes[launch_mode]); | 550 AtlTrace("Launch mode forced by registry to %s\n", modes[launch_mode]); |
| 551 launch_mode = static_cast<EC_HOST_UI_MODE>(reg_value); | 551 launch_mode = static_cast<EC_HOST_UI_MODE>(reg_value); |
| 552 } | 552 } |
| 553 | 553 |
| 554 launch_mode_determined = true; | 554 launch_mode_determined = true; |
| 555 return launch_mode; | 555 return launch_mode; |
| 556 } | 556 } |
| OLD | NEW |