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

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

Issue 336163005: Merge 276752 "Update OS version functions." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1985/src/
Patch Set: Created 6 years, 6 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 9
10 #include <errno.h> 10 #include <errno.h>
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 int darwin_major_version = DarwinMajorVersionInternal(); 462 int darwin_major_version = DarwinMajorVersionInternal();
463 463
464 // The Darwin major version is always 4 greater than the Mac OS X minor 464 // The Darwin major version is always 4 greater than the Mac OS X minor
465 // version for Darwin versions beginning with 6, corresponding to Mac OS X 465 // version for Darwin versions beginning with 6, corresponding to Mac OS X
466 // 10.2. Since this correspondence may change in the future, warn when 466 // 10.2. Since this correspondence may change in the future, warn when
467 // encountering a version higher than anything seen before. Older Darwin 467 // encountering a version higher than anything seen before. Older Darwin
468 // versions, or versions that can't be determined, result in 468 // versions, or versions that can't be determined, result in
469 // immediate death. 469 // immediate death.
470 CHECK(darwin_major_version >= 6); 470 CHECK(darwin_major_version >= 6);
471 int mac_os_x_minor_version = darwin_major_version - 4; 471 int mac_os_x_minor_version = darwin_major_version - 4;
472 DLOG_IF(WARNING, darwin_major_version > 13) << "Assuming Darwin " 472 DLOG_IF(WARNING, darwin_major_version > 14) << "Assuming Darwin "
473 << base::IntToString(darwin_major_version) << " is Mac OS X 10." 473 << base::IntToString(darwin_major_version) << " is Mac OS X 10."
474 << base::IntToString(mac_os_x_minor_version); 474 << base::IntToString(mac_os_x_minor_version);
475 475
476 return mac_os_x_minor_version; 476 return mac_os_x_minor_version;
477 } 477 }
478 478
479 // Returns the running system's Mac OS X minor version. This is the |y| value 479 // Returns the running system's Mac OS X minor version. This is the |y| value
480 // in 10.y or 10.y.z. 480 // in 10.y or 10.y.z.
481 int MacOSXMinorVersion() { 481 int MacOSXMinorVersion() {
482 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); 482 static int mac_os_x_minor_version = MacOSXMinorVersionInternal();
483 return mac_os_x_minor_version; 483 return mac_os_x_minor_version;
484 } 484 }
485 485
486 enum { 486 enum {
487 SNOW_LEOPARD_MINOR_VERSION = 6, 487 SNOW_LEOPARD_MINOR_VERSION = 6,
488 LION_MINOR_VERSION = 7, 488 LION_MINOR_VERSION = 7,
489 MOUNTAIN_LION_MINOR_VERSION = 8, 489 MOUNTAIN_LION_MINOR_VERSION = 8,
490 MAVERICKS_MINOR_VERSION = 9, 490 MAVERICKS_MINOR_VERSION = 9,
491 YOSEMITE_MINOR_VERSION = 10,
491 }; 492 };
492 493
493 } // namespace 494 } // namespace
494 495
495 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) 496 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7)
496 bool IsOSSnowLeopard() { 497 bool IsOSSnowLeopard() {
497 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION; 498 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION;
498 } 499 }
499 #endif 500 #endif
500 501
(...skipping 26 matching lines...) Expand all
527 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; 528 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION;
528 } 529 }
529 #endif 530 #endif
530 531
531 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9) 532 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9)
532 bool IsOSMavericksOrLater() { 533 bool IsOSMavericksOrLater() {
533 return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION; 534 return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION;
534 } 535 }
535 #endif 536 #endif
536 537
537 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9) 538 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10)
538 bool IsOSLaterThanMavericks_DontCallThis() { 539 bool IsOSYosemite() {
539 return MacOSXMinorVersion() > MAVERICKS_MINOR_VERSION; 540 return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION;
541 }
542 #endif
543
544 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10)
545 bool IsOSYosemiteOrLater() {
546 return MacOSXMinorVersion() >= YOSEMITE_MINOR_VERSION;
547 }
548 #endif
549
550 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10)
551 bool IsOSLaterThanYosemite_DontCallThis() {
552 return MacOSXMinorVersion() > YOSEMITE_MINOR_VERSION;
540 } 553 }
541 #endif 554 #endif
542 555
543 std::string GetModelIdentifier() { 556 std::string GetModelIdentifier() {
544 std::string return_string; 557 std::string return_string;
545 ScopedIOObject<io_service_t> platform_expert( 558 ScopedIOObject<io_service_t> platform_expert(
546 IOServiceGetMatchingService(kIOMasterPortDefault, 559 IOServiceGetMatchingService(kIOMasterPortDefault,
547 IOServiceMatching("IOPlatformExpertDevice"))); 560 IOServiceMatching("IOPlatformExpertDevice")));
548 if (platform_expert) { 561 if (platform_expert) {
549 ScopedCFTypeRef<CFDataRef> model_data( 562 ScopedCFTypeRef<CFDataRef> model_data(
(...skipping 28 matching lines...) Expand all
578 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) 591 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
579 return false; 592 return false;
580 *type = ident.substr(0, number_loc); 593 *type = ident.substr(0, number_loc);
581 *major = major_tmp; 594 *major = major_tmp;
582 *minor = minor_tmp; 595 *minor = minor_tmp;
583 return true; 596 return true;
584 } 597 }
585 598
586 } // namespace mac 599 } // namespace mac
587 } // namespace base 600 } // 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