| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // | 4 // |
| 5 // This file defines functions that integrate Chrome in Windows shell. These | 5 // This file defines functions that integrate Chrome in Windows shell. These |
| 6 // functions can be used by Chrome as well as Chrome installer. All of the | 6 // functions can be used by Chrome as well as Chrome installer. All of the |
| 7 // work is done by the local functions defined in anonymous namespace in | 7 // work is done by the local functions defined in anonymous namespace in |
| 8 // this class. | 8 // this class. |
| 9 | 9 |
| 10 #include "chrome/installer/util/shell_util.h" | 10 #include "chrome/installer/util/shell_util.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 } | 291 } |
| 292 return registered; | 292 return registered; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // This method registers Chrome on Vista by launching eleavated setup.exe. | 295 // This method registers Chrome on Vista by launching eleavated setup.exe. |
| 296 // That will show user standard Vista elevation prompt. If user accepts it | 296 // That will show user standard Vista elevation prompt. If user accepts it |
| 297 // the new process will make the necessary changes and return SUCCESS that | 297 // the new process will make the necessary changes and return SUCCESS that |
| 298 // we capture and return. | 298 // we capture and return. |
| 299 bool ElevateAndRegisterChrome(const std::wstring& chrome_exe, | 299 bool ElevateAndRegisterChrome(const std::wstring& chrome_exe, |
| 300 const std::wstring& suffix) { | 300 const std::wstring& suffix) { |
| 301 std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe)); | 301 FilePath exe_path = |
| 302 file_util::AppendToPath(&exe_path, installer_util::kSetupExe); | 302 FilePath::FromWStringHack(chrome_exe).DirName() |
| 303 if (!file_util::PathExists(FilePath::FromWStringHack(exe_path))) { | 303 .Append(installer_util::kSetupExe); |
| 304 if (!file_util::PathExists(exe_path)) { |
| 304 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 305 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 305 HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? | 306 HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? |
| 306 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 307 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
| 307 RegKey key(reg_root, dist->GetUninstallRegPath().c_str(), KEY_READ); | 308 RegKey key(reg_root, dist->GetUninstallRegPath().c_str(), KEY_READ); |
| 308 key.ReadValue(installer_util::kUninstallStringField, &exe_path); | 309 std::wstring uninstall_string; |
| 309 CommandLine command_line = CommandLine::FromString(exe_path); | 310 key.ReadValue(installer_util::kUninstallStringField, &uninstall_string); |
| 310 exe_path = command_line.program(); | 311 CommandLine command_line = CommandLine::FromString(uninstall_string); |
| 312 exe_path = command_line.GetProgram(); |
| 311 } | 313 } |
| 312 if (file_util::PathExists(FilePath::FromWStringHack(exe_path))) { | 314 if (file_util::PathExists(exe_path)) { |
| 313 std::wstring params(L"--"); | 315 std::wstring params(L"--"); |
| 314 params.append( | 316 params.append( |
| 315 ASCIIToWide(installer_util::switches::kRegisterChromeBrowser)); | 317 ASCIIToWide(installer_util::switches::kRegisterChromeBrowser)); |
| 316 params.append(L"=\"" + chrome_exe + L"\""); | 318 params.append(L"=\"" + chrome_exe + L"\""); |
| 317 if (!suffix.empty()) { | 319 if (!suffix.empty()) { |
| 318 params.append(L" --"); | 320 params.append(L" --"); |
| 319 params.append(ASCIIToWide( | 321 params.append(ASCIIToWide( |
| 320 installer_util::switches::kRegisterChromeBrowserSuffix)); | 322 installer_util::switches::kRegisterChromeBrowserSuffix)); |
| 321 params.append(L"=\"" + suffix + L"\""); | 323 params.append(L"=\"" + suffix + L"\""); |
| 322 } | 324 } |
| 323 | 325 |
| 324 CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 326 CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 325 if (browser_command_line.HasSwitch(switches::kChromeFrame)) { | 327 if (browser_command_line.HasSwitch(switches::kChromeFrame)) { |
| 326 params.append(L" --"); | 328 params.append(L" --"); |
| 327 params.append(installer_util::switches::kChromeFrame); | 329 params.append(installer_util::switches::kChromeFrame); |
| 328 } | 330 } |
| 329 | 331 |
| 330 DWORD ret_val = 0; | 332 DWORD ret_val = 0; |
| 331 InstallUtil::ExecuteExeAsAdmin(exe_path, params, &ret_val); | 333 InstallUtil::ExecuteExeAsAdmin(exe_path.value(), params, &ret_val); |
| 332 if (ret_val == 0) | 334 if (ret_val == 0) |
| 333 return true; | 335 return true; |
| 334 } | 336 } |
| 335 return false; | 337 return false; |
| 336 } | 338 } |
| 337 | 339 |
| 338 // This method tries to figure out if another user has already registered her | 340 // This method tries to figure out if another user has already registered her |
| 339 // own copy of Chrome so that we can avoid overwriting it and append current | 341 // own copy of Chrome so that we can avoid overwriting it and append current |
| 340 // user's login name to default browser registry entries. This function is | 342 // user's login name to default browser registry entries. This function is |
| 341 // not meant to detect all cases. It just tries to handle the most common case. | 343 // not meant to detect all cases. It just tries to handle the most common case. |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 chrome_exe.c_str(), // target | 800 chrome_exe.c_str(), // target |
| 799 shortcut.c_str(), // shortcut | 801 shortcut.c_str(), // shortcut |
| 800 chrome_path.c_str(), // working dir | 802 chrome_path.c_str(), // working dir |
| 801 NULL, // arguments | 803 NULL, // arguments |
| 802 description.c_str(), // description | 804 description.c_str(), // description |
| 803 chrome_exe.c_str(), // icon file | 805 chrome_exe.c_str(), // icon file |
| 804 icon_index, // icon index | 806 icon_index, // icon index |
| 805 dist->GetBrowserAppId().c_str()); // app id | 807 dist->GetBrowserAppId().c_str()); // app id |
| 806 } | 808 } |
| 807 } | 809 } |
| OLD | NEW |