| 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 | 4 |
| 5 #include "chrome/browser/first_run/upgrade_util.h" | 5 #include "chrome/browser/first_run/upgrade_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <psapi.h> | 8 #include <psapi.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 | 10 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 InstallUtil::IsPerUserInstall(cur_chrome_exe.value().c_str()); | 251 InstallUtil::IsPerUserInstall(cur_chrome_exe.value().c_str()); |
| 252 HKEY reg_root = user_install ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 252 HKEY reg_root = user_install ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
| 253 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); | 253 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); |
| 254 base::win::RegKey key; | 254 base::win::RegKey key; |
| 255 if (key.Open(reg_root, dist->GetVersionKey().c_str(), | 255 if (key.Open(reg_root, dist->GetVersionKey().c_str(), |
| 256 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | 256 KEY_QUERY_VALUE) == ERROR_SUCCESS) { |
| 257 // First try to rename exe by launching rename command ourselves. | 257 // First try to rename exe by launching rename command ourselves. |
| 258 std::wstring rename_cmd; | 258 std::wstring rename_cmd; |
| 259 if (key.ReadValue(google_update::kRegRenameCmdField, | 259 if (key.ReadValue(google_update::kRegRenameCmdField, |
| 260 &rename_cmd) == ERROR_SUCCESS) { | 260 &rename_cmd) == ERROR_SUCCESS) { |
| 261 base::win::ScopedHandle handle; | |
| 262 base::LaunchOptions options; | 261 base::LaunchOptions options; |
| 263 options.wait = true; | 262 options.wait = true; |
| 264 options.start_hidden = true; | 263 options.start_hidden = true; |
| 265 if (base::LaunchProcess(rename_cmd, options, &handle)) { | 264 base::Process process = base::LaunchProcess(rename_cmd, options); |
| 265 if (process.IsValid()) { |
| 266 DWORD exit_code; | 266 DWORD exit_code; |
| 267 ::GetExitCodeProcess(handle.Get(), &exit_code); | 267 ::GetExitCodeProcess(process.Handle(), &exit_code); |
| 268 if (exit_code == installer::RENAME_SUCCESSFUL) | 268 if (exit_code == installer::RENAME_SUCCESSFUL) |
| 269 return true; | 269 return true; |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Rename didn't work so try to rename by calling Google Update | 274 // Rename didn't work so try to rename by calling Google Update |
| 275 return InvokeGoogleUpdateForRename(); | 275 return InvokeGoogleUpdateForRename(); |
| 276 } | 276 } |
| 277 | 277 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 304 return false; | 304 return false; |
| 305 // At this point the chrome.exe has been swapped with the new one. | 305 // At this point the chrome.exe has been swapped with the new one. |
| 306 if (!RelaunchChromeBrowser(command_line)) { | 306 if (!RelaunchChromeBrowser(command_line)) { |
| 307 // The re-launch fails. Feel free to panic now. | 307 // The re-launch fails. Feel free to panic now. |
| 308 NOTREACHED(); | 308 NOTREACHED(); |
| 309 } | 309 } |
| 310 return true; | 310 return true; |
| 311 } | 311 } |
| 312 | 312 |
| 313 } // namespace upgrade_util | 313 } // namespace upgrade_util |
| OLD | NEW |