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

Side by Side Diff: chrome/installer/gcapi/gcapi.cc

Issue 1953103002: GoogleChromeCompatibilityCheck in gcapi return false for Windows XP and Vista (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | 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 // NOTE: This code is a legacy utility API for partners to check whether 5 // NOTE: This code is a legacy utility API for partners to check whether
6 // Chrome can be installed and launched. Recent updates are being made 6 // Chrome can be installed and launched. Recent updates are being made
7 // to add new functionality. These updates use code from Chromium, the old 7 // to add new functionality. These updates use code from Chromium, the old
8 // coded against the win32 api directly. If you have an itch to shave a 8 // coded against the win32 api directly. If you have an itch to shave a
9 // yak, feel free to re-write the old code too. 9 // yak, feel free to re-write the old code too.
10 10
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // The C1F RLZ key can either be in HKCU or in HKLM (the HKLM RLZ key is made 220 // The C1F RLZ key can either be in HKCU or in HKLM (the HKLM RLZ key is made
221 // readable to all-users via rlz_lib::CreateMachineState()) and can either be 221 // readable to all-users via rlz_lib::CreateMachineState()) and can either be
222 // in sent or pending state. Return true if there is a match for any of these 222 // in sent or pending state. Return true if there is a match for any of these
223 // 4 states. 223 // 4 states.
224 return RegKeyHasC1F(HKEY_CURRENT_USER, kC1FSentKey) || 224 return RegKeyHasC1F(HKEY_CURRENT_USER, kC1FSentKey) ||
225 RegKeyHasC1F(HKEY_CURRENT_USER, kC1FPendingKey) || 225 RegKeyHasC1F(HKEY_CURRENT_USER, kC1FPendingKey) ||
226 RegKeyHasC1F(HKEY_LOCAL_MACHINE, kC1FSentKey) || 226 RegKeyHasC1F(HKEY_LOCAL_MACHINE, kC1FSentKey) ||
227 RegKeyHasC1F(HKEY_LOCAL_MACHINE, kC1FPendingKey); 227 RegKeyHasC1F(HKEY_LOCAL_MACHINE, kC1FPendingKey);
228 } 228 }
229 229
230 enum WindowsVersion { 230 bool IsWindowsVersionSupported() {
231 VERSION_BELOW_XP_SP2,
232 VERSION_XP_SP2_UP_TO_VISTA, // "but not including"
233 VERSION_VISTA_OR_HIGHER,
234 };
235 WindowsVersion GetWindowsVersion() {
236 OSVERSIONINFOEX version_info = { sizeof version_info }; 231 OSVERSIONINFOEX version_info = { sizeof version_info };
237 GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info)); 232 GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info));
238 233
239 // Windows Vista is version 6.0. 234 // Windows 7 is version 6.1.
240 if (version_info.dwMajorVersion >= 6) 235 if (version_info.dwMajorVersion > 6 ||
241 return VERSION_VISTA_OR_HIGHER; 236 (version_info.dwMajorVersion == 6 && version_info.dwMinorVersion > 0))
237 return true;
242 238
243 // Windows XP is version 5.1. (5.2 is Windows Server 2003/XP Pro x64.) 239 return false;
244 if ((version_info.dwMajorVersion < 5) || (version_info.dwMinorVersion < 1))
245 return VERSION_BELOW_XP_SP2;
246
247 // For XP itself, we only support SP2 and above.
248 return ((version_info.dwMinorVersion > 1) ||
249 (version_info.wServicePackMajor >= 2)) ?
250 VERSION_XP_SP2_UP_TO_VISTA : VERSION_BELOW_XP_SP2;
251 } 240 }
252 241
253 // Note this function should not be called on old Windows versions where these 242 // Note this function should not be called on old Windows versions where these
254 // Windows API are not available. We always invoke this function after checking 243 // Windows API are not available. We always invoke this function after checking
255 // that current OS is Vista or later. 244 // that current OS is Vista or later.
256 bool VerifyAdminGroup() { 245 bool VerifyAdminGroup() {
257 SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; 246 SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
258 PSID Group; 247 PSID Group;
259 BOOL check = ::AllocateAndInitializeSid(&NtAuthority, 2, 248 BOOL check = ::AllocateAndInitializeSid(&NtAuthority, 2,
260 SECURITY_BUILTIN_DOMAIN_RID, 249 SECURITY_BUILTIN_DOMAIN_RID,
(...skipping 29 matching lines...) Expand all
290 // If we create the main key, delete the entire key. 279 // If we create the main key, delete the entire key.
291 if (disposition == REG_CREATED_NEW_KEY) 280 if (disposition == REG_CREATED_NEW_KEY)
292 RegDeleteKey(HKEY_LOCAL_MACHINE, kGCAPITempKey); 281 RegDeleteKey(HKEY_LOCAL_MACHINE, kGCAPITempKey);
293 } 282 }
294 283
295 return result; 284 return result;
296 } 285 }
297 286
298 bool IsRunningElevated() { 287 bool IsRunningElevated() {
299 // This method should be called only for Vista or later. 288 // This method should be called only for Vista or later.
300 if ((GetWindowsVersion() < VERSION_VISTA_OR_HIGHER) || 289 if (!IsWindowsVersionSupported() || !VerifyAdminGroup())
301 !VerifyAdminGroup())
302 return false; 290 return false;
303 291
304 HANDLE process_token; 292 HANDLE process_token;
305 if (!::OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &process_token)) 293 if (!::OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &process_token))
306 return false; 294 return false;
307 295
308 TOKEN_ELEVATION_TYPE elevation_type = TokenElevationTypeDefault; 296 TOKEN_ELEVATION_TYPE elevation_type = TokenElevationTypeDefault;
309 DWORD size_returned = 0; 297 DWORD size_returned = 0;
310 if (!::GetTokenInformation(process_token, TokenElevationType, 298 if (!::GetTokenInformation(process_token, TokenElevationType,
311 &elevation_type, sizeof(elevation_type), 299 &elevation_type, sizeof(elevation_type),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 return !chrome_exe_path->empty(); 387 return !chrome_exe_path->empty();
400 } 388 }
401 389
402 } // namespace 390 } // namespace
403 391
404 BOOL __stdcall GoogleChromeCompatibilityCheck(BOOL set_flag, 392 BOOL __stdcall GoogleChromeCompatibilityCheck(BOOL set_flag,
405 int shell_mode, 393 int shell_mode,
406 DWORD* reasons) { 394 DWORD* reasons) {
407 DWORD local_reasons = 0; 395 DWORD local_reasons = 0;
408 396
409 WindowsVersion windows_version = GetWindowsVersion(); 397 bool is_windows_version_supported = IsWindowsVersionSupported();
410 // System requirements? 398 // System requirements?
411 if (windows_version == VERSION_BELOW_XP_SP2) 399 if (!is_windows_version_supported)
412 local_reasons |= GCCC_ERROR_OSNOTSUPPORTED; 400 local_reasons |= GCCC_ERROR_OSNOTSUPPORTED;
413 401
414 if (IsChromeInstalled(HKEY_LOCAL_MACHINE)) 402 if (IsChromeInstalled(HKEY_LOCAL_MACHINE))
415 local_reasons |= GCCC_ERROR_SYSTEMLEVELALREADYPRESENT; 403 local_reasons |= GCCC_ERROR_SYSTEMLEVELALREADYPRESENT;
416 404
417 if (IsChromeInstalled(HKEY_CURRENT_USER)) 405 if (IsChromeInstalled(HKEY_CURRENT_USER))
418 local_reasons |= GCCC_ERROR_USERLEVELALREADYPRESENT; 406 local_reasons |= GCCC_ERROR_USERLEVELALREADYPRESENT;
419 407
420 if (shell_mode == GCAPI_INVOKED_UAC_ELEVATION) { 408 if (shell_mode == GCAPI_INVOKED_UAC_ELEVATION) {
421 // Only check that we have HKLM write permissions if we specify that 409 // Only check that we have HKLM write permissions if we specify that
422 // GCAPI is being invoked from an elevated shell, or in admin mode 410 // GCAPI is being invoked from an elevated shell, or in admin mode
423 if (!VerifyHKLMAccess()) { 411 if (!VerifyHKLMAccess()) {
424 local_reasons |= GCCC_ERROR_ACCESSDENIED; 412 local_reasons |= GCCC_ERROR_ACCESSDENIED;
425 } else if ((windows_version == VERSION_VISTA_OR_HIGHER) && 413 } else if (is_windows_version_supported && !VerifyAdminGroup()) {
426 !VerifyAdminGroup()) { 414 // For Vista or later check for elevation since even for admin user we
427 // For Vista or later check for elevation since even for admin user we could 415 // could be running in non-elevated mode. We require integrity level High.
428 // be running in non-elevated mode. We require integrity level High. 416 local_reasons |= GCCC_ERROR_INTEGRITYLEVEL;
429 local_reasons |= GCCC_ERROR_INTEGRITYLEVEL;
430 } 417 }
431 } 418 }
432 419
433 // Then only check whether we can re-offer, if everything else is OK. 420 // Then only check whether we can re-offer, if everything else is OK.
434 if (local_reasons == 0 && !CanReOfferChrome(set_flag)) 421 if (local_reasons == 0 && !CanReOfferChrome(set_flag))
435 local_reasons |= GCCC_ERROR_ALREADYOFFERED; 422 local_reasons |= GCCC_ERROR_ALREADYOFFERED;
436 423
437 // Done. Copy/return results. 424 // Done. Copy/return results.
438 if (reasons != NULL) 425 if (reasons != NULL)
439 *reasons = local_reasons; 426 *reasons = local_reasons;
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 key.WriteValue(kRelaunchAllowedAfterValue, 776 key.WriteValue(kRelaunchAllowedAfterValue,
790 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS || 777 FormatDateOffsetByMonths(6)) != ERROR_SUCCESS ||
791 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) { 778 !SetRelaunchExperimentLabels(relaunch_brandcode, shell_mode)) {
792 if (error_code) 779 if (error_code)
793 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED; 780 *error_code = RELAUNCH_ERROR_RELAUNCH_FAILED;
794 return FALSE; 781 return FALSE;
795 } 782 }
796 783
797 return TRUE; 784 return TRUE;
798 } 785 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698