| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 NOTREACHED(); | 86 NOTREACHED(); |
| 87 return false; | 87 return false; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Explicitly make sure to relaunch chrome.exe rather than old_chrome.exe. | 90 // Explicitly make sure to relaunch chrome.exe rather than old_chrome.exe. |
| 91 // This can happen when old_chrome.exe is launched by a user. | 91 // This can happen when old_chrome.exe is launched by a user. |
| 92 base::CommandLine chrome_exe_command_line = command_line; | 92 base::CommandLine chrome_exe_command_line = command_line; |
| 93 chrome_exe_command_line.SetProgram( | 93 chrome_exe_command_line.SetProgram( |
| 94 chrome_exe.DirName().Append(installer::kChromeExe)); | 94 chrome_exe.DirName().Append(installer::kChromeExe)); |
| 95 | 95 |
| 96 return base::LaunchProcess(chrome_exe_command_line, base::LaunchOptions()) | 96 // Set the working directory to the exe's directory. This avoids a handle to |
| 97 .IsValid(); | 97 // the version directory being kept open in the relaunched child process. |
| 98 base::LaunchOptions launch_options; |
| 99 launch_options.current_directory = chrome_exe.DirName(); |
| 100 return base::LaunchProcess(chrome_exe_command_line, launch_options).IsValid(); |
| 98 } | 101 } |
| 99 | 102 |
| 100 bool IsUpdatePendingRestart() { | 103 bool IsUpdatePendingRestart() { |
| 101 base::FilePath new_chrome_exe; | 104 base::FilePath new_chrome_exe; |
| 102 if (!GetNewerChromeFile(&new_chrome_exe)) | 105 if (!GetNewerChromeFile(&new_chrome_exe)) |
| 103 return false; | 106 return false; |
| 104 return base::PathExists(new_chrome_exe); | 107 return base::PathExists(new_chrome_exe); |
| 105 } | 108 } |
| 106 | 109 |
| 107 bool SwapNewChromeExeIfPresent() { | 110 bool SwapNewChromeExeIfPresent() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return false; | 169 return false; |
| 167 // At this point the chrome.exe has been swapped with the new one. | 170 // At this point the chrome.exe has been swapped with the new one. |
| 168 if (!RelaunchChromeBrowser(command_line)) { | 171 if (!RelaunchChromeBrowser(command_line)) { |
| 169 // The re-launch fails. Feel free to panic now. | 172 // The re-launch fails. Feel free to panic now. |
| 170 NOTREACHED(); | 173 NOTREACHED(); |
| 171 } | 174 } |
| 172 return true; | 175 return true; |
| 173 } | 176 } |
| 174 | 177 |
| 175 } // namespace upgrade_util | 178 } // namespace upgrade_util |
| OLD | NEW |