Index: chrome/browser/first_run/upgrade_util_win.cc |
diff --git a/chrome/browser/first_run/upgrade_util_win.cc b/chrome/browser/first_run/upgrade_util_win.cc |
index b1293360a38a62ec16427c4277891f7d72b1fc29..c44766904a9a1e4fb091605ddb076cc87d9e01ec 100644 |
--- a/chrome/browser/first_run/upgrade_util_win.cc |
+++ b/chrome/browser/first_run/upgrade_util_win.cc |
@@ -5,6 +5,7 @@ |
#include "chrome/browser/first_run/upgrade_util.h" |
#include <windows.h> |
+#include <psapi.h> |
#include <shellapi.h> |
#include <algorithm> |
@@ -123,8 +124,15 @@ bool RelaunchChromeHelper(const CommandLine& command_line, |
else |
version_str.clear(); |
+ |
grt (UTC plus 2)
2014/05/09 16:53:08
nit: remove extra newline
robertshield
2014/05/15 16:49:35
Done.
|
+ CommandLine chrome_exe_command_line = command_line; |
+ base::FilePath current_exe_path(command_line.GetProgram().DirName()); |
grt (UTC plus 2)
2014/05/09 16:53:08
i'm not sure about this. i recently fixed a bugabo
robertshield
2014/05/15 16:49:35
Done.
|
+ current_exe_path = current_exe_path.Append(installer::kChromeExe); |
+ chrome_exe_command_line.SetProgram(current_exe_path); |
+ |
if (base::win::GetVersion() < base::win::VERSION_WIN8) |
- return base::LaunchProcess(command_line, base::LaunchOptions(), NULL); |
+ return base::LaunchProcess(chrome_exe_command_line, |
+ base::LaunchOptions(), NULL); |
// On Windows 8 we always use the delegate_execute for re-launching chrome. |
// |
@@ -246,13 +254,34 @@ bool SwapNewChromeExeIfPresent() { |
return InvokeGoogleUpdateForRename(); |
} |
+bool IsRunningOldChrome() { |
+ // This figures out the actual file name that the section containing the |
+ // mapped exe refers to. This is used instead of GetModuleFileName because the |
+ // .exe may have been renamed out from under us while we've been running which |
+ // GetModuleFileName won't notice. |
+ wchar_t mapped_file_name[MAX_PATH * 2] = {}; |
+ DWORD returned_chars = |
grt (UTC plus 2)
2014/05/09 16:53:08
since returned_chars isn't really used, how about:
robertshield
2014/05/15 16:49:35
Done.
|
+ ::GetMappedFileName(::GetCurrentProcess(), |
+ reinterpret_cast<void*>(::GetModuleHandle(NULL)), |
+ mapped_file_name, |
+ MAX_PATH * 2); |
grt (UTC plus 2)
2014/05/09 16:53:08
arraysize(mapped_file_name)
robertshield
2014/05/15 16:49:35
Done.
|
+ if (returned_chars != 0) { |
+ base::FilePath file_name(base::FilePath(mapped_file_name).BaseName()); |
+ if (base::FilePath::CompareEqualIgnoreCase(file_name.value(), |
+ installer::kChromeOldExe)) { |
+ return true; |
+ } |
+ } |
+ return false; |
+} |
+ |
bool DoUpgradeTasks(const CommandLine& command_line) { |
// The DelegateExecute verb handler finalizes pending in-use updates for |
// metro mode launches, as Chrome cannot be gracefully relaunched when |
// running in this mode. |
if (base::win::IsMetroProcess()) |
return false; |
- if (!SwapNewChromeExeIfPresent()) |
+ if (!SwapNewChromeExeIfPresent() && !IsRunningOldChrome()) |
return false; |
// At this point the chrome.exe has been swapped with the new one. |
if (!RelaunchChromeBrowser(command_line)) { |