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

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

Issue 1224283006: Update OS version functions for OS X 10.11 El Capitan. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For rsesek Created 5 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
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 9
10 #include <errno.h> 10 #include <errno.h>
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 int darwin_major_version = DarwinMajorVersionInternal(); 456 int darwin_major_version = DarwinMajorVersionInternal();
457 457
458 // The Darwin major version is always 4 greater than the Mac OS X minor 458 // The Darwin major version is always 4 greater than the Mac OS X minor
459 // version for Darwin versions beginning with 6, corresponding to Mac OS X 459 // version for Darwin versions beginning with 6, corresponding to Mac OS X
460 // 10.2. Since this correspondence may change in the future, warn when 460 // 10.2. Since this correspondence may change in the future, warn when
461 // encountering a version higher than anything seen before. Older Darwin 461 // encountering a version higher than anything seen before. Older Darwin
462 // versions, or versions that can't be determined, result in 462 // versions, or versions that can't be determined, result in
463 // immediate death. 463 // immediate death.
464 CHECK(darwin_major_version >= 6); 464 CHECK(darwin_major_version >= 6);
465 int mac_os_x_minor_version = darwin_major_version - 4; 465 int mac_os_x_minor_version = darwin_major_version - 4;
466 DLOG_IF(WARNING, darwin_major_version > 14) << "Assuming Darwin " 466 DLOG_IF(WARNING, darwin_major_version > 15) << "Assuming Darwin "
467 << base::IntToString(darwin_major_version) << " is Mac OS X 10." 467 << base::IntToString(darwin_major_version) << " is Mac OS X 10."
468 << base::IntToString(mac_os_x_minor_version); 468 << base::IntToString(mac_os_x_minor_version);
469 469
470 return mac_os_x_minor_version; 470 return mac_os_x_minor_version;
471 } 471 }
472 472
473 // Returns the running system's Mac OS X minor version. This is the |y| value 473 // Returns the running system's Mac OS X minor version. This is the |y| value
474 // in 10.y or 10.y.z. 474 // in 10.y or 10.y.z.
475 int MacOSXMinorVersion() { 475 int MacOSXMinorVersion() {
476 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); 476 static int mac_os_x_minor_version = MacOSXMinorVersionInternal();
477 return mac_os_x_minor_version; 477 return mac_os_x_minor_version;
478 } 478 }
479 479
480 enum { 480 enum {
481 SNOW_LEOPARD_MINOR_VERSION = 6, 481 SNOW_LEOPARD_MINOR_VERSION = 6,
482 LION_MINOR_VERSION = 7, 482 LION_MINOR_VERSION = 7,
483 MOUNTAIN_LION_MINOR_VERSION = 8, 483 MOUNTAIN_LION_MINOR_VERSION = 8,
484 MAVERICKS_MINOR_VERSION = 9, 484 MAVERICKS_MINOR_VERSION = 9,
485 YOSEMITE_MINOR_VERSION = 10, 485 YOSEMITE_MINOR_VERSION = 10,
486 EL_CAPITAN_MINOR_VERSION = 11,
486 }; 487 };
487 488
488 } // namespace 489 } // namespace
489 490
490 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) 491 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7)
491 bool IsOSSnowLeopard() { 492 bool IsOSSnowLeopard() {
492 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION; 493 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION;
493 } 494 }
494 #endif 495 #endif
495 496
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION; 535 return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION;
535 } 536 }
536 #endif 537 #endif
537 538
538 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10) 539 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10)
539 bool IsOSYosemiteOrLater() { 540 bool IsOSYosemiteOrLater() {
540 return MacOSXMinorVersion() >= YOSEMITE_MINOR_VERSION; 541 return MacOSXMinorVersion() >= YOSEMITE_MINOR_VERSION;
541 } 542 }
542 #endif 543 #endif
543 544
544 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10) 545 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11)
545 bool IsOSLaterThanYosemite_DontCallThis() { 546 bool IsOSElCapitan() {
546 return MacOSXMinorVersion() > YOSEMITE_MINOR_VERSION; 547 return MacOSXMinorVersion() == EL_CAPITAN_MINOR_VERSION;
547 } 548 }
548 #endif 549 #endif
549 550
551 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_11)
552 bool IsOSElCapitanOrLater() {
553 return MacOSXMinorVersion() >= EL_CAPITAN_MINOR_VERSION;
554 }
555 #endif
556
557 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11)
558 bool IsOSLaterThanElCapitan_DontCallThis() {
559 return MacOSXMinorVersion() > EL_CAPITAN_MINOR_VERSION;
560 }
561 #endif
562
550 std::string GetModelIdentifier() { 563 std::string GetModelIdentifier() {
551 std::string return_string; 564 std::string return_string;
552 ScopedIOObject<io_service_t> platform_expert( 565 ScopedIOObject<io_service_t> platform_expert(
553 IOServiceGetMatchingService(kIOMasterPortDefault, 566 IOServiceGetMatchingService(kIOMasterPortDefault,
554 IOServiceMatching("IOPlatformExpertDevice"))); 567 IOServiceMatching("IOPlatformExpertDevice")));
555 if (platform_expert) { 568 if (platform_expert) {
556 ScopedCFTypeRef<CFDataRef> model_data( 569 ScopedCFTypeRef<CFDataRef> model_data(
557 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( 570 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty(
558 platform_expert, 571 platform_expert,
559 CFSTR("model"), 572 CFSTR("model"),
(...skipping 25 matching lines...) Expand all
585 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) 598 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
586 return false; 599 return false;
587 *type = ident.substr(0, number_loc); 600 *type = ident.substr(0, number_loc);
588 *major = major_tmp; 601 *major = major_tmp;
589 *minor = minor_tmp; 602 *minor = minor_tmp;
590 return true; 603 return true;
591 } 604 }
592 605
593 } // namespace mac 606 } // namespace mac
594 } // namespace base 607 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698