| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #include "views/standard_layout.h" | 58 #include "views/standard_layout.h" |
| 59 #include "views/widget/root_view.h" | 59 #include "views/widget/root_view.h" |
| 60 #include "views/widget/widget_win.h" | 60 #include "views/widget/widget_win.h" |
| 61 #include "views/window/window.h" | 61 #include "views/window/window.h" |
| 62 | 62 |
| 63 namespace { | 63 namespace { |
| 64 | 64 |
| 65 bool GetNewerChromeFile(FilePath* path) { | 65 bool GetNewerChromeFile(FilePath* path) { |
| 66 if (!PathService::Get(base::DIR_EXE, path)) | 66 if (!PathService::Get(base::DIR_EXE, path)) |
| 67 return false; | 67 return false; |
| 68 *path = path->Append(installer::kChromeNewExe); | 68 *path = path->Append(installer_util::kChromeNewExe); |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool InvokeGoogleUpdateForRename() { | 72 bool InvokeGoogleUpdateForRename() { |
| 73 ScopedComPtr<IProcessLauncher> ipl; | 73 ScopedComPtr<IProcessLauncher> ipl; |
| 74 if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) { | 74 if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) { |
| 75 ULONG_PTR phandle = NULL; | 75 ULONG_PTR phandle = NULL; |
| 76 DWORD id = GetCurrentProcessId(); | 76 DWORD id = GetCurrentProcessId(); |
| 77 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 77 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 78 if (!FAILED(ipl->LaunchCmdElevated(dist->GetAppGuid().c_str(), | 78 if (!FAILED(ipl->LaunchCmdElevated(dist->GetAppGuid().c_str(), |
| 79 google_update::kRegRenameCmdField, | 79 google_update::kRegRenameCmdField, |
| 80 id, &phandle))) { | 80 id, &phandle))) { |
| 81 HANDLE handle = HANDLE(phandle); | 81 HANDLE handle = HANDLE(phandle); |
| 82 WaitForSingleObject(handle, INFINITE); | 82 WaitForSingleObject(handle, INFINITE); |
| 83 DWORD exit_code; | 83 DWORD exit_code; |
| 84 ::GetExitCodeProcess(handle, &exit_code); | 84 ::GetExitCodeProcess(handle, &exit_code); |
| 85 ::CloseHandle(handle); | 85 ::CloseHandle(handle); |
| 86 if (exit_code == installer::RENAME_SUCCESSFUL) | 86 if (exit_code == installer_util::RENAME_SUCCESSFUL) |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool LaunchSetupWithParam(const std::string& param, const std::wstring& value, | 93 bool LaunchSetupWithParam(const std::string& param, const std::wstring& value, |
| 94 int* ret_code) { | 94 int* ret_code) { |
| 95 FilePath exe_path; | 95 FilePath exe_path; |
| 96 if (!PathService::Get(base::DIR_MODULE, &exe_path)) | 96 if (!PathService::Get(base::DIR_MODULE, &exe_path)) |
| 97 return false; | 97 return false; |
| 98 exe_path = exe_path.Append(installer::kInstallerDir); | 98 exe_path = exe_path.Append(installer_util::kInstallerDir); |
| 99 exe_path = exe_path.Append(installer::kSetupExe); | 99 exe_path = exe_path.Append(installer_util::kSetupExe); |
| 100 base::ProcessHandle ph; | 100 base::ProcessHandle ph; |
| 101 CommandLine cl(exe_path); | 101 CommandLine cl(exe_path); |
| 102 cl.AppendSwitchNative(param, value); | 102 cl.AppendSwitchNative(param, value); |
| 103 | 103 |
| 104 CommandLine* browser_command_line = CommandLine::ForCurrentProcess(); | 104 CommandLine* browser_command_line = CommandLine::ForCurrentProcess(); |
| 105 if (browser_command_line->HasSwitch(switches::kChromeFrame)) { | 105 if (browser_command_line->HasSwitch(switches::kChromeFrame)) { |
| 106 cl.AppendSwitch(switches::kChromeFrame); | 106 cl.AppendSwitch(switches::kChromeFrame); |
| 107 } | 107 } |
| 108 | 108 |
| 109 if (!base::LaunchApp(cl, false, false, &ph)) | 109 if (!base::LaunchApp(cl, false, false, &ph)) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace | 175 } // namespace |
| 176 | 176 |
| 177 bool FirstRun::LaunchSetupWithParam(const std::string& param, | 177 bool FirstRun::LaunchSetupWithParam(const std::string& param, |
| 178 const std::wstring& value, | 178 const std::wstring& value, |
| 179 int* ret_code) { | 179 int* ret_code) { |
| 180 FilePath exe_path; | 180 FilePath exe_path; |
| 181 if (!PathService::Get(base::DIR_MODULE, &exe_path)) | 181 if (!PathService::Get(base::DIR_MODULE, &exe_path)) |
| 182 return false; | 182 return false; |
| 183 exe_path = exe_path.Append(installer::kInstallerDir); | 183 exe_path = exe_path.Append(installer_util::kInstallerDir); |
| 184 exe_path = exe_path.Append(installer::kSetupExe); | 184 exe_path = exe_path.Append(installer_util::kSetupExe); |
| 185 base::ProcessHandle ph; | 185 base::ProcessHandle ph; |
| 186 CommandLine cl(exe_path); | 186 CommandLine cl(exe_path); |
| 187 cl.AppendSwitchNative(param, value); | 187 cl.AppendSwitchNative(param, value); |
| 188 | 188 |
| 189 CommandLine* browser_command_line = CommandLine::ForCurrentProcess(); | 189 CommandLine* browser_command_line = CommandLine::ForCurrentProcess(); |
| 190 if (browser_command_line->HasSwitch(switches::kChromeFrame)) { | 190 if (browser_command_line->HasSwitch(switches::kChromeFrame)) { |
| 191 cl.AppendSwitch(switches::kChromeFrame); | 191 cl.AppendSwitch(switches::kChromeFrame); |
| 192 } | 192 } |
| 193 | 193 |
| 194 if (!base::LaunchApp(cl, false, false, &ph)) | 194 if (!base::LaunchApp(cl, false, false, &ph)) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); | 279 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); |
| 280 base::win::RegKey key; | 280 base::win::RegKey key; |
| 281 std::wstring rename_cmd; | 281 std::wstring rename_cmd; |
| 282 if (key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) && | 282 if (key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) && |
| 283 key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd)) { | 283 key.ReadValue(google_update::kRegRenameCmdField, &rename_cmd)) { |
| 284 base::ProcessHandle handle; | 284 base::ProcessHandle handle; |
| 285 if (base::LaunchApp(rename_cmd, true, true, &handle)) { | 285 if (base::LaunchApp(rename_cmd, true, true, &handle)) { |
| 286 DWORD exit_code; | 286 DWORD exit_code; |
| 287 ::GetExitCodeProcess(handle, &exit_code); | 287 ::GetExitCodeProcess(handle, &exit_code); |
| 288 ::CloseHandle(handle); | 288 ::CloseHandle(handle); |
| 289 if (exit_code == installer::RENAME_SUCCESSFUL) | 289 if (exit_code == installer_util::RENAME_SUCCESSFUL) |
| 290 return true; | 290 return true; |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 // Rename didn't work so try to rename by calling Google Update | 294 // Rename didn't work so try to rename by calling Google Update |
| 295 return InvokeGoogleUpdateForRename(); | 295 return InvokeGoogleUpdateForRename(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 // static | 298 // static |
| 299 bool Upgrade::DoUpgradeTasks(const CommandLine& command_line) { | 299 bool Upgrade::DoUpgradeTasks(const CommandLine& command_line) { |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 | 855 |
| 856 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { | 856 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { |
| 857 if (version > 10000) { | 857 if (version > 10000) { |
| 858 // This is a test value. We want to make sure we exercise | 858 // This is a test value. We want to make sure we exercise |
| 859 // returning this early. See EarlyReturnTest test harness. | 859 // returning this early. See EarlyReturnTest test harness. |
| 860 return Upgrade::TD_NOT_NOW; | 860 return Upgrade::TD_NOT_NOW; |
| 861 } | 861 } |
| 862 TryChromeDialog td(version); | 862 TryChromeDialog td(version); |
| 863 return td.ShowModal(); | 863 return td.ShowModal(); |
| 864 } | 864 } |
| OLD | NEW |