OLD | NEW |
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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 // in 10.y or 10.y.z. | 603 // in 10.y or 10.y.z. |
604 int MacOSXMinorVersion() { | 604 int MacOSXMinorVersion() { |
605 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); | 605 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); |
606 return mac_os_x_minor_version; | 606 return mac_os_x_minor_version; |
607 } | 607 } |
608 | 608 |
609 enum { | 609 enum { |
610 SNOW_LEOPARD_MINOR_VERSION = 6, | 610 SNOW_LEOPARD_MINOR_VERSION = 6, |
611 LION_MINOR_VERSION = 7, | 611 LION_MINOR_VERSION = 7, |
612 MOUNTAIN_LION_MINOR_VERSION = 8, | 612 MOUNTAIN_LION_MINOR_VERSION = 8, |
| 613 MAVERICKS_MINOR_VERSION = 9, |
613 }; | 614 }; |
614 | 615 |
615 } // namespace | 616 } // namespace |
616 | 617 |
617 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) | 618 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) |
618 bool IsOSSnowLeopard() { | 619 bool IsOSSnowLeopard() { |
619 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION; | 620 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION; |
620 } | 621 } |
621 #endif | 622 #endif |
622 | 623 |
623 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) | 624 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) |
624 bool IsOSLion() { | 625 bool IsOSLion() { |
625 return MacOSXMinorVersion() == LION_MINOR_VERSION; | 626 return MacOSXMinorVersion() == LION_MINOR_VERSION; |
626 } | 627 } |
627 #endif | 628 #endif |
628 | 629 |
629 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) | |
630 bool IsOSLionOrEarlier() { | |
631 return MacOSXMinorVersion() <= LION_MINOR_VERSION; | |
632 } | |
633 #endif | |
634 | |
635 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) | 630 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) |
636 bool IsOSLionOrLater() { | 631 bool IsOSLionOrLater() { |
637 return MacOSXMinorVersion() >= LION_MINOR_VERSION; | 632 return MacOSXMinorVersion() >= LION_MINOR_VERSION; |
638 } | 633 } |
639 #endif | 634 #endif |
640 | 635 |
641 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) | 636 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) |
642 bool IsOSMountainLion() { | 637 bool IsOSMountainLion() { |
643 return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION; | 638 return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION; |
644 } | 639 } |
645 #endif | 640 #endif |
646 | 641 |
647 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8) | 642 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8) |
648 bool IsOSMountainLionOrLater() { | 643 bool IsOSMountainLionOrLater() { |
649 return MacOSXMinorVersion() >= MOUNTAIN_LION_MINOR_VERSION; | 644 return MacOSXMinorVersion() >= MOUNTAIN_LION_MINOR_VERSION; |
650 } | 645 } |
651 #endif | 646 #endif |
652 | 647 |
653 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) | 648 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9) |
654 bool IsOSLaterThanMountainLion_DontCallThis() { | 649 bool IsOSMavericks() { |
655 return MacOSXMinorVersion() > MOUNTAIN_LION_MINOR_VERSION; | 650 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; |
656 } | 651 } |
657 #endif | 652 #endif |
658 | 653 |
| 654 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9) |
| 655 bool IsOSMavericksOrLater() { |
| 656 return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION; |
| 657 } |
| 658 #endif |
| 659 |
| 660 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9) |
| 661 bool IsOSLaterThanMavericks_DontCallThis() { |
| 662 return MacOSXMinorVersion() > MAVERICKS_MINOR_VERSION; |
| 663 } |
| 664 #endif |
| 665 |
659 std::string GetModelIdentifier() { | 666 std::string GetModelIdentifier() { |
660 std::string return_string; | 667 std::string return_string; |
661 ScopedIOObject<io_service_t> platform_expert( | 668 ScopedIOObject<io_service_t> platform_expert( |
662 IOServiceGetMatchingService(kIOMasterPortDefault, | 669 IOServiceGetMatchingService(kIOMasterPortDefault, |
663 IOServiceMatching("IOPlatformExpertDevice"))); | 670 IOServiceMatching("IOPlatformExpertDevice"))); |
664 if (platform_expert) { | 671 if (platform_expert) { |
665 ScopedCFTypeRef<CFDataRef> model_data( | 672 ScopedCFTypeRef<CFDataRef> model_data( |
666 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( | 673 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( |
667 platform_expert, | 674 platform_expert, |
668 CFSTR("model"), | 675 CFSTR("model"), |
(...skipping 25 matching lines...) Expand all Loading... |
694 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) | 701 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) |
695 return false; | 702 return false; |
696 *type = ident.substr(0, number_loc); | 703 *type = ident.substr(0, number_loc); |
697 *major = major_tmp; | 704 *major = major_tmp; |
698 *minor = minor_tmp; | 705 *minor = minor_tmp; |
699 return true; | 706 return true; |
700 } | 707 } |
701 | 708 |
702 } // namespace mac | 709 } // namespace mac |
703 } // namespace base | 710 } // namespace base |
OLD | NEW |