| 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 #include <string.h> | 9 #include <string.h> |
| 10 #include <sys/utsname.h> | 10 #include <sys/utsname.h> |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 int darwin_major_version = DarwinMajorVersionInternal(); | 547 int darwin_major_version = DarwinMajorVersionInternal(); |
| 548 | 548 |
| 549 // The Darwin major version is always 4 greater than the Mac OS X minor | 549 // The Darwin major version is always 4 greater than the Mac OS X minor |
| 550 // version for Darwin versions beginning with 6, corresponding to Mac OS X | 550 // version for Darwin versions beginning with 6, corresponding to Mac OS X |
| 551 // 10.2. Since this correspondence may change in the future, warn when | 551 // 10.2. Since this correspondence may change in the future, warn when |
| 552 // encountering a version higher than anything seen before. Older Darwin | 552 // encountering a version higher than anything seen before. Older Darwin |
| 553 // versions, or versions that can't be determined, result in | 553 // versions, or versions that can't be determined, result in |
| 554 // immediate death. | 554 // immediate death. |
| 555 CHECK(darwin_major_version >= 6); | 555 CHECK(darwin_major_version >= 6); |
| 556 int mac_os_x_minor_version = darwin_major_version - 4; | 556 int mac_os_x_minor_version = darwin_major_version - 4; |
| 557 DLOG_IF(WARNING, darwin_major_version > 11) << "Assuming Darwin " | 557 DLOG_IF(WARNING, darwin_major_version > 12) << "Assuming Darwin " |
| 558 << base::IntToString(darwin_major_version) << " is Mac OS X 10." | 558 << base::IntToString(darwin_major_version) << " is Mac OS X 10." |
| 559 << base::IntToString(mac_os_x_minor_version); | 559 << base::IntToString(mac_os_x_minor_version); |
| 560 | 560 |
| 561 return mac_os_x_minor_version; | 561 return mac_os_x_minor_version; |
| 562 } | 562 } |
| 563 | 563 |
| 564 // Returns the running system's Mac OS X minor version. This is the |y| value | 564 // Returns the running system's Mac OS X minor version. This is the |y| value |
| 565 // in 10.y or 10.y.z. | 565 // in 10.y or 10.y.z. |
| 566 int MacOSXMinorVersion() { | 566 int MacOSXMinorVersion() { |
| 567 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); | 567 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); |
| 568 return mac_os_x_minor_version; | 568 return mac_os_x_minor_version; |
| 569 } | 569 } |
| 570 | 570 |
| 571 enum { | 571 enum { |
| 572 LEOPARD_MINOR_VERSION = 5, | 572 LEOPARD_MINOR_VERSION = 5, |
| 573 SNOW_LEOPARD_MINOR_VERSION = 6, | 573 SNOW_LEOPARD_MINOR_VERSION = 6, |
| 574 LION_MINOR_VERSION = 7 | 574 LION_MINOR_VERSION = 7, |
| 575 MOUNTAIN_LION_MINOR_VERSION = 8, |
| 575 }; | 576 }; |
| 576 | 577 |
| 577 } // namespace | 578 } // namespace |
| 578 | 579 |
| 579 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6) | 580 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6) |
| 580 bool IsOSLeopard() { | 581 bool IsOSLeopard() { |
| 581 return MacOSXMinorVersion() == LEOPARD_MINOR_VERSION; | 582 return MacOSXMinorVersion() == LEOPARD_MINOR_VERSION; |
| 582 } | 583 } |
| 583 #endif | 584 #endif |
| 584 | 585 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 605 return MacOSXMinorVersion() >= SNOW_LEOPARD_MINOR_VERSION; | 606 return MacOSXMinorVersion() >= SNOW_LEOPARD_MINOR_VERSION; |
| 606 } | 607 } |
| 607 #endif | 608 #endif |
| 608 | 609 |
| 609 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) | 610 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) |
| 610 bool IsOSLion() { | 611 bool IsOSLion() { |
| 611 return MacOSXMinorVersion() == LION_MINOR_VERSION; | 612 return MacOSXMinorVersion() == LION_MINOR_VERSION; |
| 612 } | 613 } |
| 613 #endif | 614 #endif |
| 614 | 615 |
| 616 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) |
| 617 bool IsOSLionOrEarlier() { |
| 618 return MacOSXMinorVersion() <= LION_MINOR_VERSION; |
| 619 } |
| 620 #endif |
| 621 |
| 615 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) | 622 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) |
| 616 bool IsOSLionOrLater() { | 623 bool IsOSLionOrLater() { |
| 617 return MacOSXMinorVersion() >= LION_MINOR_VERSION; | 624 return MacOSXMinorVersion() >= LION_MINOR_VERSION; |
| 618 } | 625 } |
| 619 #endif | 626 #endif |
| 620 | 627 |
| 621 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) | 628 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) |
| 622 bool IsOSLaterThanLion() { | 629 bool IsOSMountainLion() { |
| 623 return MacOSXMinorVersion() > LION_MINOR_VERSION; | 630 return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION; |
| 624 } | 631 } |
| 625 #endif | 632 #endif |
| 626 | 633 |
| 634 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8) |
| 635 bool IsOSMountainLionOrLater() { |
| 636 return MacOSXMinorVersion() >= MOUNTAIN_LION_MINOR_VERSION; |
| 637 } |
| 638 #endif |
| 639 |
| 640 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) |
| 641 bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement() { |
| 642 return MacOSXMinorVersion() > MOUNTAIN_LION_MINOR_VERSION; |
| 643 } |
| 644 #endif |
| 645 |
| 627 namespace { | 646 namespace { |
| 628 | 647 |
| 629 // ScopedGenericObj functor for IOObjectRelease(). | 648 // ScopedGenericObj functor for IOObjectRelease(). |
| 630 class ScopedReleaseIOObject { | 649 class ScopedReleaseIOObject { |
| 631 public: | 650 public: |
| 632 void operator()(io_object_t x) const { | 651 void operator()(io_object_t x) const { |
| 633 IOObjectRelease(x); | 652 IOObjectRelease(x); |
| 634 } | 653 } |
| 635 }; | 654 }; |
| 636 | 655 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) | 691 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) |
| 673 return false; | 692 return false; |
| 674 *type = ident.substr(0, number_loc); | 693 *type = ident.substr(0, number_loc); |
| 675 *major = major_tmp; | 694 *major = major_tmp; |
| 676 *minor = minor_tmp; | 695 *minor = minor_tmp; |
| 677 return true; | 696 return true; |
| 678 } | 697 } |
| 679 | 698 |
| 680 } // namespace mac | 699 } // namespace mac |
| 681 } // namespace base | 700 } // namespace base |
| OLD | NEW |