OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // See the corresponding header file for description of the functions in this | 5 // See the corresponding header file for description of the functions in this |
6 // file. | 6 // file. |
7 | 7 |
8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
9 | 9 |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 bool InstallUtil::IsOSSupported() { | 139 bool InstallUtil::IsOSSupported() { |
140 // We do not support Win2K or older, or XP without service pack 2. | 140 // We do not support Win2K or older, or XP without service pack 2. |
141 VLOG(1) << base::SysInfo::OperatingSystemName() << ' ' | 141 VLOG(1) << base::SysInfo::OperatingSystemName() << ' ' |
142 << base::SysInfo::OperatingSystemVersion(); | 142 << base::SysInfo::OperatingSystemVersion(); |
143 base::win::Version version = base::win::GetVersion(); | 143 base::win::Version version = base::win::GetVersion(); |
144 return (version > base::win::VERSION_XP) || | 144 return (version > base::win::VERSION_XP) || |
145 ((version == base::win::VERSION_XP) && | 145 ((version == base::win::VERSION_XP) && |
146 (base::win::OSInfo::GetInstance()->service_pack().major >= 2)); | 146 (base::win::OSInfo::GetInstance()->service_pack().major >= 2)); |
147 } | 147 } |
148 | 148 |
149 void InstallUtil::WriteInstallerResult(bool system_install, | 149 void InstallUtil::AddInstallerResultItems(bool system_install, |
150 const std::wstring& state_key, | 150 const std::wstring& state_key, |
151 installer::InstallStatus status, | 151 installer::InstallStatus status, |
152 int string_resource_id, | 152 int string_resource_id, |
153 const std::wstring* const launch_cmd) { | 153 const std::wstring* const launch_cmd, |
| 154 WorkItemList* install_list) { |
| 155 DCHECK(install_list); |
154 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 156 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
155 DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1; | 157 DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1; |
156 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); | |
157 install_list->AddCreateRegKeyWorkItem(root, state_key); | 158 install_list->AddCreateRegKeyWorkItem(root, state_key); |
158 install_list->AddSetRegValueWorkItem(root, state_key, | 159 install_list->AddSetRegValueWorkItem(root, state_key, |
159 installer::kInstallerResult, | 160 installer::kInstallerResult, |
160 installer_result, true); | 161 installer_result, true); |
161 install_list->AddSetRegValueWorkItem(root, state_key, | 162 install_list->AddSetRegValueWorkItem(root, state_key, |
162 installer::kInstallerError, | 163 installer::kInstallerError, |
163 static_cast<DWORD>(status), true); | 164 static_cast<DWORD>(status), true); |
164 if (string_resource_id != 0) { | 165 if (string_resource_id != 0) { |
165 std::wstring msg = installer::GetLocalizedString(string_resource_id); | 166 std::wstring msg = installer::GetLocalizedString(string_resource_id); |
166 install_list->AddSetRegValueWorkItem(root, state_key, | 167 install_list->AddSetRegValueWorkItem(root, state_key, |
167 installer::kInstallerResultUIString, msg, true); | 168 installer::kInstallerResultUIString, msg, true); |
168 } | 169 } |
169 if (launch_cmd != NULL && !launch_cmd->empty()) { | 170 if (launch_cmd != NULL && !launch_cmd->empty()) { |
170 install_list->AddSetRegValueWorkItem(root, state_key, | 171 install_list->AddSetRegValueWorkItem(root, state_key, |
171 installer::kInstallerSuccessLaunchCmdLine, *launch_cmd, true); | 172 installer::kInstallerSuccessLaunchCmdLine, *launch_cmd, true); |
172 } | 173 } |
173 if (!install_list->Do()) | |
174 LOG(ERROR) << "Failed to record installer error information in registry."; | |
175 } | 174 } |
176 | 175 |
177 void InstallUtil::UpdateInstallerStage(bool system_install, | 176 void InstallUtil::UpdateInstallerStage(bool system_install, |
178 const std::wstring& state_key_path, | 177 const std::wstring& state_key_path, |
179 installer::InstallerStage stage) { | 178 installer::InstallerStage stage) { |
180 DCHECK_LE(static_cast<installer::InstallerStage>(0), stage); | 179 DCHECK_LE(static_cast<installer::InstallerStage>(0), stage); |
181 DCHECK_GT(installer::NUM_STAGES, stage); | 180 DCHECK_GT(installer::NUM_STAGES, stage); |
182 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 181 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
183 RegKey state_key; | 182 RegKey state_key; |
184 LONG result = state_key.Open(root, state_key_path.c_str(), | 183 LONG result = state_key.Open(root, state_key_path.c_str(), |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat, | 367 int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat, |
369 date_str, arraysize(date_str)); | 368 date_str, arraysize(date_str)); |
370 if (len) { | 369 if (len) { |
371 --len; // Subtract terminating \0. | 370 --len; // Subtract terminating \0. |
372 } else { | 371 } else { |
373 PLOG(DFATAL) << "GetDateFormat"; | 372 PLOG(DFATAL) << "GetDateFormat"; |
374 } | 373 } |
375 | 374 |
376 return std::wstring(date_str, len); | 375 return std::wstring(date_str, len); |
377 } | 376 } |
OLD | NEW |