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

Side by Side Diff: base/mac/mac_util.mm

Issue 2271653006: base::mac::IsOSSierra() -> base::mac::IsOS10_12(), etc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Nits Created 4 years, 3 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 | « base/mac/mac_util.h ('k') | base/mac/mac_util_unittest.mm » ('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 #include "base/mac/mac_util.h" 5 #include "base/mac/mac_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #import <IOKit/IOKitLib.h> 8 #import <IOKit/IOKitLib.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // immediate death. 441 // immediate death.
442 CHECK(darwin_major_version >= 6); 442 CHECK(darwin_major_version >= 6);
443 int mac_os_x_minor_version = darwin_major_version - 4; 443 int mac_os_x_minor_version = darwin_major_version - 4;
444 DLOG_IF(WARNING, darwin_major_version > 16) << "Assuming Darwin " 444 DLOG_IF(WARNING, darwin_major_version > 16) << "Assuming Darwin "
445 << base::IntToString(darwin_major_version) << " is Mac OS X 10." 445 << base::IntToString(darwin_major_version) << " is Mac OS X 10."
446 << base::IntToString(mac_os_x_minor_version); 446 << base::IntToString(mac_os_x_minor_version);
447 447
448 return mac_os_x_minor_version; 448 return mac_os_x_minor_version;
449 } 449 }
450 450
451 // Returns the running system's Mac OS X minor version. This is the |y| value 451 } // namespace
452 // in 10.y or 10.y.z. 452
453 namespace internal {
453 int MacOSXMinorVersion() { 454 int MacOSXMinorVersion() {
454 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); 455 static int mac_os_x_minor_version = MacOSXMinorVersionInternal();
455 return mac_os_x_minor_version; 456 return mac_os_x_minor_version;
456 } 457 }
457 458 } // namespace internal
458 enum {
459 MAVERICKS_MINOR_VERSION = 9,
460 YOSEMITE_MINOR_VERSION = 10,
461 EL_CAPITAN_MINOR_VERSION = 11,
462 SIERRA_MINOR_VERSION = 12,
463 };
464
465 } // namespace
466
467 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9)
468 bool IsOSMavericks() {
469 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION;
470 }
471 #endif
472
473 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10)
474 bool IsOSYosemite() {
475 return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION;
476 }
477 #endif
478
479 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10)
480 bool IsOSYosemiteOrLater() {
481 return MacOSXMinorVersion() >= YOSEMITE_MINOR_VERSION;
482 }
483 #endif
484
485 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11)
486 bool IsOSElCapitan() {
487 return MacOSXMinorVersion() == EL_CAPITAN_MINOR_VERSION;
488 }
489 #endif
490
491 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_11)
492 bool IsOSElCapitanOrLater() {
493 return MacOSXMinorVersion() >= EL_CAPITAN_MINOR_VERSION;
494 }
495 #endif
496
497 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12)
498 bool IsOSSierra() {
499 return MacOSXMinorVersion() == SIERRA_MINOR_VERSION;
500 }
501 #endif
502
503 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_12)
504 bool IsOSSierraOrLater() {
505 return MacOSXMinorVersion() >= SIERRA_MINOR_VERSION;
506 }
507 #endif
508
509 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12)
510 bool IsOSLaterThanSierra_DontCallThis() {
511 return MacOSXMinorVersion() > SIERRA_MINOR_VERSION;
512 }
513 #endif
514 459
515 std::string GetModelIdentifier() { 460 std::string GetModelIdentifier() {
516 std::string return_string; 461 std::string return_string;
517 ScopedIOObject<io_service_t> platform_expert( 462 ScopedIOObject<io_service_t> platform_expert(
518 IOServiceGetMatchingService(kIOMasterPortDefault, 463 IOServiceGetMatchingService(kIOMasterPortDefault,
519 IOServiceMatching("IOPlatformExpertDevice"))); 464 IOServiceMatching("IOPlatformExpertDevice")));
520 if (platform_expert) { 465 if (platform_expert) {
521 ScopedCFTypeRef<CFDataRef> model_data( 466 ScopedCFTypeRef<CFDataRef> model_data(
522 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( 467 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty(
523 platform_expert, 468 platform_expert,
(...skipping 26 matching lines...) Expand all
550 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) 495 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
551 return false; 496 return false;
552 *type = ident.substr(0, number_loc); 497 *type = ident.substr(0, number_loc);
553 *major = major_tmp; 498 *major = major_tmp;
554 *minor = minor_tmp; 499 *minor = minor_tmp;
555 return true; 500 return true;
556 } 501 }
557 502
558 } // namespace mac 503 } // namespace mac
559 } // namespace base 504 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/mac_util.h ('k') | base/mac/mac_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698