| 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_ISOSSNOWLEOPARD) |
| 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_ISOSLION) |
| 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 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_ISOSLIONOREARLIER) |
| 630 bool IsOSLionOrEarlier() { | 631 bool IsOSLionOrEarlier() { |
| 631 return MacOSXMinorVersion() <= LION_MINOR_VERSION; | 632 return MacOSXMinorVersion() <= LION_MINOR_VERSION; |
| 632 } | 633 } |
| 633 #endif | 634 #endif |
| 634 | 635 |
| 635 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) | 636 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_ISOSLIONORLATER) |
| 636 bool IsOSLionOrLater() { | 637 bool IsOSLionOrLater() { |
| 637 return MacOSXMinorVersion() >= LION_MINOR_VERSION; | 638 return MacOSXMinorVersion() >= LION_MINOR_VERSION; |
| 638 } | 639 } |
| 639 #endif | 640 #endif |
| 640 | 641 |
| 641 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) | 642 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLION) |
| 642 bool IsOSMountainLion() { | 643 bool IsOSMountainLion() { |
| 643 return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION; | 644 return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION; |
| 644 } | 645 } |
| 645 #endif | 646 #endif |
| 646 | 647 |
| 647 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8) | 648 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLIONOREARLIER) |
| 649 bool IsOSMountainLionOrEarlier() { |
| 650 return MacOSXMinorVersion() <= MOUNTAIN_LION_MINOR_VERSION; |
| 651 } |
| 652 #endif |
| 653 |
| 654 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLIONORLATER) |
| 648 bool IsOSMountainLionOrLater() { | 655 bool IsOSMountainLionOrLater() { |
| 649 return MacOSXMinorVersion() >= MOUNTAIN_LION_MINOR_VERSION; | 656 return MacOSXMinorVersion() >= MOUNTAIN_LION_MINOR_VERSION; |
| 650 } | 657 } |
| 651 #endif | 658 #endif |
| 652 | 659 |
| 653 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) | 660 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_ISOSMAVERICKS) |
| 654 bool IsOSLaterThanMountainLion_DontCallThis() { | 661 bool IsOSMavericks() { |
| 655 return MacOSXMinorVersion() > MOUNTAIN_LION_MINOR_VERSION; | 662 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; |
| 656 } | 663 } |
| 657 #endif | 664 #endif |
| 658 | 665 |
| 666 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_ISOSMAVERICKSORLATER) |
| 667 bool IsOSMavericksOrLater() { |
| 668 return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION; |
| 669 } |
| 670 #endif |
| 671 |
| 672 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_ISLATERTHANOSMAVERICKS) |
| 673 bool IsOSLaterThanMavericks_DontCallThis() { |
| 674 return MacOSXMinorVersion() > MAVERICKS_MINOR_VERSION; |
| 675 } |
| 676 #endif |
| 677 |
| 659 std::string GetModelIdentifier() { | 678 std::string GetModelIdentifier() { |
| 660 std::string return_string; | 679 std::string return_string; |
| 661 ScopedIOObject<io_service_t> platform_expert( | 680 ScopedIOObject<io_service_t> platform_expert( |
| 662 IOServiceGetMatchingService(kIOMasterPortDefault, | 681 IOServiceGetMatchingService(kIOMasterPortDefault, |
| 663 IOServiceMatching("IOPlatformExpertDevice"))); | 682 IOServiceMatching("IOPlatformExpertDevice"))); |
| 664 if (platform_expert) { | 683 if (platform_expert) { |
| 665 ScopedCFTypeRef<CFDataRef> model_data( | 684 ScopedCFTypeRef<CFDataRef> model_data( |
| 666 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( | 685 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( |
| 667 platform_expert, | 686 platform_expert, |
| 668 CFSTR("model"), | 687 CFSTR("model"), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 694 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) | 713 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) |
| 695 return false; | 714 return false; |
| 696 *type = ident.substr(0, number_loc); | 715 *type = ident.substr(0, number_loc); |
| 697 *major = major_tmp; | 716 *major = major_tmp; |
| 698 *minor = minor_tmp; | 717 *minor = minor_tmp; |
| 699 return true; | 718 return true; |
| 700 } | 719 } |
| 701 | 720 |
| 702 } // namespace mac | 721 } // namespace mac |
| 703 } // namespace base | 722 } // namespace base |
| OLD | NEW |