| 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 12 matching lines...) Expand all Loading... |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
| 26 #include "base/win/scoped_comptr.h" | 26 #include "base/win/scoped_comptr.h" |
| 27 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
| 28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/first_run/upgrade_util_win.h" | 29 #include "chrome/browser/first_run/upgrade_util_win.h" |
| 30 #include "chrome/browser/shell_integration.h" | 30 #include "chrome/browser/shell_integration.h" |
| 31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/install_static/install_util.h" |
| 33 #include "chrome/installer/util/browser_distribution.h" | 34 #include "chrome/installer/util/browser_distribution.h" |
| 34 #include "chrome/installer/util/google_update_constants.h" | 35 #include "chrome/installer/util/google_update_constants.h" |
| 35 #include "chrome/installer/util/install_util.h" | 36 #include "chrome/installer/util/install_util.h" |
| 36 #include "chrome/installer/util/shell_util.h" | 37 #include "chrome/installer/util/shell_util.h" |
| 37 #include "chrome/installer/util/util_constants.h" | 38 #include "chrome/installer/util/util_constants.h" |
| 38 #include "components/prefs/pref_service.h" | 39 #include "components/prefs/pref_service.h" |
| 39 #include "ui/base/ui_base_switches.h" | 40 #include "ui/base/ui_base_switches.h" |
| 40 | 41 |
| 41 #if defined(GOOGLE_CHROME_BUILD) | 42 #if defined(GOOGLE_CHROME_BUILD) |
| 42 #include "google_update/google_update_idl.h" | 43 #include "google_update/google_update_idl.h" |
| 43 #endif | 44 #endif |
| 44 | 45 |
| 45 namespace { | 46 namespace { |
| 46 | 47 |
| 47 bool GetNewerChromeFile(base::FilePath* path) { | 48 bool GetNewerChromeFile(base::FilePath* path) { |
| 48 if (!PathService::Get(base::DIR_EXE, path)) | 49 if (!PathService::Get(base::DIR_EXE, path)) |
| 49 return false; | 50 return false; |
| 50 *path = path->Append(installer::kChromeNewExe); | 51 *path = path->Append(installer::kChromeNewExe); |
| 51 return true; | 52 return true; |
| 52 } | 53 } |
| 53 | 54 |
| 54 bool InvokeGoogleUpdateForRename() { | 55 bool InvokeGoogleUpdateForRename() { |
| 55 #if defined(GOOGLE_CHROME_BUILD) | 56 #if defined(GOOGLE_CHROME_BUILD) |
| 56 base::win::ScopedComPtr<IProcessLauncher> ipl; | 57 base::win::ScopedComPtr<IProcessLauncher> ipl; |
| 57 if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) { | 58 if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) { |
| 58 ULONG_PTR phandle = NULL; | 59 ULONG_PTR phandle = NULL; |
| 59 DWORD id = GetCurrentProcessId(); | 60 DWORD id = GetCurrentProcessId(); |
| 60 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 61 if (!FAILED(ipl->LaunchCmdElevated(install_static::GetAppGuid(), |
| 61 if (!FAILED(ipl->LaunchCmdElevated(dist->GetAppGuid().c_str(), | 62 google_update::kRegRenameCmdField, id, |
| 62 google_update::kRegRenameCmdField, | |
| 63 id, | |
| 64 &phandle))) { | 63 &phandle))) { |
| 65 HANDLE handle = HANDLE(phandle); | 64 HANDLE handle = HANDLE(phandle); |
| 66 WaitForSingleObject(handle, INFINITE); | 65 WaitForSingleObject(handle, INFINITE); |
| 67 DWORD exit_code; | 66 DWORD exit_code; |
| 68 ::GetExitCodeProcess(handle, &exit_code); | 67 ::GetExitCodeProcess(handle, &exit_code); |
| 69 ::CloseHandle(handle); | 68 ::CloseHandle(handle); |
| 70 if (exit_code == installer::RENAME_SUCCESSFUL) | 69 if (exit_code == installer::RENAME_SUCCESSFUL) |
| 71 return true; | 70 return true; |
| 72 } | 71 } |
| 73 } | 72 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return false; | 163 return false; |
| 165 // At this point the chrome.exe has been swapped with the new one. | 164 // At this point the chrome.exe has been swapped with the new one. |
| 166 if (!RelaunchChromeBrowser(command_line)) { | 165 if (!RelaunchChromeBrowser(command_line)) { |
| 167 // The re-launch fails. Feel free to panic now. | 166 // The re-launch fails. Feel free to panic now. |
| 168 NOTREACHED(); | 167 NOTREACHED(); |
| 169 } | 168 } |
| 170 return true; | 169 return true; |
| 171 } | 170 } |
| 172 | 171 |
| 173 } // namespace upgrade_util | 172 } // namespace upgrade_util |
| OLD | NEW |