Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/installer/util/install_util.cc

Issue 10683005: Remove two deprecated methods from base::Version (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/install_util.h ('k') | chrome/installer/util/installation_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 CommandLine InstallUtil::GetChromeUninstallCmd( 165 CommandLine InstallUtil::GetChromeUninstallCmd(
166 bool system_install, BrowserDistribution::Type distribution_type) { 166 bool system_install, BrowserDistribution::Type distribution_type) {
167 ProductState state; 167 ProductState state;
168 if (state.Initialize(system_install, distribution_type)) { 168 if (state.Initialize(system_install, distribution_type)) {
169 return state.uninstall_command(); 169 return state.uninstall_command();
170 } 170 }
171 return CommandLine(CommandLine::NO_PROGRAM); 171 return CommandLine(CommandLine::NO_PROGRAM);
172 } 172 }
173 173
174 Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, 174 void InstallUtil::GetChromeVersion(BrowserDistribution* dist,
175 bool system_install) { 175 bool system_install,
176 Version* version) {
176 DCHECK(dist); 177 DCHECK(dist);
177 RegKey key; 178 RegKey key;
178 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 179 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
179 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(), 180 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(),
180 KEY_QUERY_VALUE); 181 KEY_QUERY_VALUE);
181 182
182 string16 version_str; 183 string16 version_str;
183 if (result == ERROR_SUCCESS) 184 if (result == ERROR_SUCCESS)
184 result = key.ReadValue(google_update::kRegVersionField, &version_str); 185 result = key.ReadValue(google_update::kRegVersionField, &version_str);
185 186
186 Version* ret = NULL; 187 *version = Version();
187 if (result == ERROR_SUCCESS && !version_str.empty()) { 188 if (result == ERROR_SUCCESS && !version_str.empty()) {
188 VLOG(1) << "Existing " << dist->GetAppShortCutName() << " version found " 189 VLOG(1) << "Existing " << dist->GetAppShortCutName() << " version found "
189 << version_str; 190 << version_str;
190 ret = Version::GetVersionFromString(WideToASCII(version_str)); 191 *version = Version(WideToASCII(version_str));
191 } else { 192 } else {
192 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); 193 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result);
193 VLOG(1) << "No existing " << dist->GetAppShortCutName() 194 VLOG(1) << "No existing " << dist->GetAppShortCutName()
194 << " install found."; 195 << " install found.";
195 } 196 }
196
197 return ret;
198 } 197 }
199 198
200 Version* InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, 199 void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist,
201 bool system_install) { 200 bool system_install,
201 Version* version) {
202 DCHECK(dist); 202 DCHECK(dist);
203 RegKey key; 203 RegKey key;
204 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 204 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
205 LONG result = 205 LONG result =
206 key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_QUERY_VALUE); 206 key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_QUERY_VALUE);
207 207
208 string16 version_str; 208 string16 version_str;
209 if (result == ERROR_SUCCESS) 209 if (result == ERROR_SUCCESS)
210 result = key.ReadValue(google_update::kRegCriticalVersionField, 210 result = key.ReadValue(google_update::kRegCriticalVersionField,
211 &version_str); 211 &version_str);
212 212
213 Version* ret = NULL; 213 *version = Version();
214 if (result == ERROR_SUCCESS && !version_str.empty()) { 214 if (result == ERROR_SUCCESS && !version_str.empty()) {
215 VLOG(1) << "Critical Update version for " << dist->GetAppShortCutName() 215 VLOG(1) << "Critical Update version for " << dist->GetAppShortCutName()
216 << " found " << version_str; 216 << " found " << version_str;
217 ret = Version::GetVersionFromString(WideToASCII(version_str)); 217 *version = Version(WideToASCII(version_str));
218 } else { 218 } else {
219 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); 219 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result);
220 VLOG(1) << "No existing " << dist->GetAppShortCutName() 220 VLOG(1) << "No existing " << dist->GetAppShortCutName()
221 << " install found."; 221 << " install found.";
222 } 222 }
223
224 return ret;
225 } 223 }
226 224
227 bool InstallUtil::IsOSSupported() { 225 bool InstallUtil::IsOSSupported() {
228 // We do not support Win2K or older, or XP without service pack 2. 226 // We do not support Win2K or older, or XP without service pack 2.
229 VLOG(1) << base::SysInfo::OperatingSystemName() << ' ' 227 VLOG(1) << base::SysInfo::OperatingSystemName() << ' '
230 << base::SysInfo::OperatingSystemVersion(); 228 << base::SysInfo::OperatingSystemVersion();
231 base::win::Version version = base::win::GetVersion(); 229 base::win::Version version = base::win::GetVersion();
232 return (version > base::win::VERSION_XP) || 230 return (version > base::win::VERSION_XP) ||
233 ((version == base::win::VERSION_XP) && 231 ((version == base::win::VERSION_XP) &&
234 (base::win::OSInfo::GetInstance()->service_pack().major >= 2)); 232 (base::win::OSInfo::GetInstance()->service_pack().major >= 2));
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 336
339 bool InstallUtil::IsChromeSxSProcess() { 337 bool InstallUtil::IsChromeSxSProcess() {
340 static bool sxs = CheckIsChromeSxSProcess(); 338 static bool sxs = CheckIsChromeSxSProcess();
341 return sxs; 339 return sxs;
342 } 340 }
343 341
344 bool InstallUtil::HasDelegateExecuteHandler(BrowserDistribution* dist, 342 bool InstallUtil::HasDelegateExecuteHandler(BrowserDistribution* dist,
345 const string16& chrome_exe) { 343 const string16& chrome_exe) {
346 bool found = false; 344 bool found = false;
347 bool system_install = !IsPerUserInstall(chrome_exe.c_str()); 345 bool system_install = !IsPerUserInstall(chrome_exe.c_str());
348 scoped_ptr<Version> version(GetChromeVersion(dist, system_install)); 346 Version version;
349 if (!version.get()) { 347 GetChromeVersion(dist, system_install, &version);
348 if (!version.IsValid()) {
350 LOG(ERROR) << __FUNCTION__ << " failed to determine version of " 349 LOG(ERROR) << __FUNCTION__ << " failed to determine version of "
351 << dist->GetAppShortCutName() << " installed at " << chrome_exe; 350 << dist->GetAppShortCutName() << " installed at " << chrome_exe;
352 } else { 351 } else {
353 FilePath handler( 352 FilePath handler(
354 FilePath(chrome_exe).DirName() 353 FilePath(chrome_exe).DirName()
355 .AppendASCII(version->GetString()) 354 .AppendASCII(version.GetString())
356 .Append(installer::kDelegateExecuteExe)); 355 .Append(installer::kDelegateExecuteExe));
357 found = file_util::PathExists(handler); 356 found = file_util::PathExists(handler);
358 } 357 }
359 return found; 358 return found;
360 } 359 }
361 360
362 // This method tries to delete a registry key and logs an error message 361 // This method tries to delete a registry key and logs an error message
363 // in case of failure. It returns true if deletion is successful (or the key did 362 // in case of failure. It returns true if deletion is successful (or the key did
364 // not exist), otherwise false. 363 // not exist), otherwise false.
365 bool InstallUtil::DeleteRegistryKey(HKEY root_key, 364 bool InstallUtil::DeleteRegistryKey(HKEY root_key,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // Open the program and see if it references the expected file. 541 // Open the program and see if it references the expected file.
543 base::win::ScopedHandle handle; 542 base::win::ScopedHandle handle;
544 BY_HANDLE_FILE_INFORMATION info = {}; 543 BY_HANDLE_FILE_INFORMATION info = {};
545 544
546 return (OpenForInfo(program, &handle) && 545 return (OpenForInfo(program, &handle) &&
547 GetInfo(handle, &info) && 546 GetInfo(handle, &info) &&
548 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && 547 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber &&
549 info.nFileIndexHigh == file_info_.nFileIndexHigh && 548 info.nFileIndexHigh == file_info_.nFileIndexHigh &&
550 info.nFileIndexLow == file_info_.nFileIndexLow); 549 info.nFileIndexLow == file_info_.nFileIndexLow);
551 } 550 }
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util.h ('k') | chrome/installer/util/installation_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698