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

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

Issue 9706001: [Mac] Add the OS version check functions for 10.8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 9 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 | Annotate | Revision Log
« 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 <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
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
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_7)
622 bool IsOSLaterThanLion() { 629 bool IsOSLaterThanLion() {
623 return MacOSXMinorVersion() > LION_MINOR_VERSION; 630 return MacOSXMinorVersion() > LION_MINOR_VERSION;
624 } 631 }
625 #endif 632 #endif
626 633
634 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8)
635 bool IsOSMountainLion() {
636 return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION;
637 }
638 #endif
639
640 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8)
641 bool IsOSMountainLionOrLater() {
642 return MacOSXMinorVersion() >= MOUNTAIN_LION_MINOR_VERSION;
643 }
644 #endif
645
646 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8)
647 bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement() {
648 return MacOSXMinorVersion() > MOUNTAIN_LION_MINOR_VERSION;
649 }
650 #endif
651
627 namespace { 652 namespace {
628 653
629 // ScopedGenericObj functor for IOObjectRelease(). 654 // ScopedGenericObj functor for IOObjectRelease().
630 class ScopedReleaseIOObject { 655 class ScopedReleaseIOObject {
631 public: 656 public:
632 void operator()(io_object_t x) const { 657 void operator()(io_object_t x) const {
633 IOObjectRelease(x); 658 IOObjectRelease(x);
634 } 659 }
635 }; 660 };
636 661
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) 697 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
673 return false; 698 return false;
674 *type = ident.substr(0, number_loc); 699 *type = ident.substr(0, number_loc);
675 *major = major_tmp; 700 *major = major_tmp;
676 *minor = minor_tmp; 701 *minor = minor_tmp;
677 return true; 702 return true;
678 } 703 }
679 704
680 } // namespace mac 705 } // namespace mac
681 } // namespace base 706 } // 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