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 <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 !cmd_version.Equals(pv_version)) { | 245 !cmd_version.Equals(pv_version)) { |
246 return false; | 246 return false; |
247 } | 247 } |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 // First try to rename exe by launching rename command ourselves. | 251 // First try to rename exe by launching rename command ourselves. |
252 std::wstring rename_cmd; | 252 std::wstring rename_cmd; |
253 if (key.ReadValue(google_update::kRegRenameCmdField, | 253 if (key.ReadValue(google_update::kRegRenameCmdField, |
254 &rename_cmd) == ERROR_SUCCESS) { | 254 &rename_cmd) == ERROR_SUCCESS) { |
255 base::win::ScopedHandle handle; | 255 base::ProcessHandle handle; |
256 base::LaunchOptions options; | 256 base::LaunchOptions options; |
257 options.wait = true; | 257 options.wait = true; |
258 options.start_hidden = true; | 258 options.start_hidden = true; |
259 if (base::LaunchProcess(rename_cmd, options, &handle)) { | 259 if (base::LaunchProcess(rename_cmd, options, &handle)) { |
260 DWORD exit_code; | 260 DWORD exit_code; |
261 ::GetExitCodeProcess(handle, &exit_code); | 261 ::GetExitCodeProcess(handle, &exit_code); |
| 262 ::CloseHandle(handle); |
262 if (exit_code == installer::RENAME_SUCCESSFUL) | 263 if (exit_code == installer::RENAME_SUCCESSFUL) |
263 return true; | 264 return true; |
264 } | 265 } |
265 } | 266 } |
266 } | 267 } |
267 | 268 |
268 // Rename didn't work so try to rename by calling Google Update | 269 // Rename didn't work so try to rename by calling Google Update |
269 return InvokeGoogleUpdateForRename(); | 270 return InvokeGoogleUpdateForRename(); |
270 } | 271 } |
271 | 272 |
272 bool DoUpgradeTasks(const CommandLine& command_line) { | 273 bool DoUpgradeTasks(const CommandLine& command_line) { |
273 // The DelegateExecute verb handler finalizes pending in-use updates for | 274 // The DelegateExecute verb handler finalizes pending in-use updates for |
274 // metro mode launches, as Chrome cannot be gracefully relaunched when | 275 // metro mode launches, as Chrome cannot be gracefully relaunched when |
275 // running in this mode. | 276 // running in this mode. |
276 if (base::win::IsMetroProcess()) | 277 if (base::win::IsMetroProcess()) |
277 return false; | 278 return false; |
278 if (!SwapNewChromeExeIfPresent()) | 279 if (!SwapNewChromeExeIfPresent()) |
279 return false; | 280 return false; |
280 // At this point the chrome.exe has been swapped with the new one. | 281 // At this point the chrome.exe has been swapped with the new one. |
281 if (!RelaunchChromeBrowser(command_line)) { | 282 if (!RelaunchChromeBrowser(command_line)) { |
282 // The re-launch fails. Feel free to panic now. | 283 // The re-launch fails. Feel free to panic now. |
283 NOTREACHED(); | 284 NOTREACHED(); |
284 } | 285 } |
285 return true; | 286 return true; |
286 } | 287 } |
287 | 288 |
288 } // namespace upgrade_util | 289 } // namespace upgrade_util |
OLD | NEW |