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 <objbase.h> |
8 #include <psapi.h> | 9 #include <psapi.h> |
9 #include <shellapi.h> | 10 #include <shellapi.h> |
10 | 11 |
11 #include <algorithm> | 12 #include <algorithm> |
12 #include <string> | 13 #include <string> |
13 | 14 |
14 #include "base/base_paths.h" | 15 #include "base/base_paths.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
17 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
(...skipping 29 matching lines...) Expand all Loading... |
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(::CoCreateInstance(__uuidof(ProcessLauncherClass), nullptr, |
| 59 CLSCTX_ALL, IID_PPV_ARGS(&ipl)))) { |
58 ULONG_PTR phandle = NULL; | 60 ULONG_PTR phandle = NULL; |
59 DWORD id = GetCurrentProcessId(); | 61 DWORD id = GetCurrentProcessId(); |
60 if (!FAILED(ipl->LaunchCmdElevated(install_static::GetAppGuid(), | 62 if (!FAILED(ipl->LaunchCmdElevated(install_static::GetAppGuid(), |
61 google_update::kRegRenameCmdField, id, | 63 google_update::kRegRenameCmdField, id, |
62 &phandle))) { | 64 &phandle))) { |
63 HANDLE handle = HANDLE(phandle); | 65 HANDLE handle = HANDLE(phandle); |
64 WaitForSingleObject(handle, INFINITE); | 66 WaitForSingleObject(handle, INFINITE); |
65 DWORD exit_code; | 67 DWORD exit_code; |
66 ::GetExitCodeProcess(handle, &exit_code); | 68 ::GetExitCodeProcess(handle, &exit_code); |
67 ::CloseHandle(handle); | 69 ::CloseHandle(handle); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return false; | 164 return false; |
163 // At this point the chrome.exe has been swapped with the new one. | 165 // At this point the chrome.exe has been swapped with the new one. |
164 if (!RelaunchChromeBrowser(command_line)) { | 166 if (!RelaunchChromeBrowser(command_line)) { |
165 // The re-launch fails. Feel free to panic now. | 167 // The re-launch fails. Feel free to panic now. |
166 NOTREACHED(); | 168 NOTREACHED(); |
167 } | 169 } |
168 return true; | 170 return true; |
169 } | 171 } |
170 | 172 |
171 } // namespace upgrade_util | 173 } // namespace upgrade_util |
OLD | NEW |