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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 int darwin_major_version = DarwinMajorVersionInternal(); | 453 int darwin_major_version = DarwinMajorVersionInternal(); |
454 | 454 |
455 // The Darwin major version is always 4 greater than the Mac OS X minor | 455 // The Darwin major version is always 4 greater than the Mac OS X minor |
456 // version for Darwin versions beginning with 6, corresponding to Mac OS X | 456 // version for Darwin versions beginning with 6, corresponding to Mac OS X |
457 // 10.2. Since this correspondence may change in the future, warn when | 457 // 10.2. Since this correspondence may change in the future, warn when |
458 // encountering a version higher than anything seen before. Older Darwin | 458 // encountering a version higher than anything seen before. Older Darwin |
459 // versions, or versions that can't be determined, result in | 459 // versions, or versions that can't be determined, result in |
460 // immediate death. | 460 // immediate death. |
461 CHECK(darwin_major_version >= 6); | 461 CHECK(darwin_major_version >= 6); |
462 int mac_os_x_minor_version = darwin_major_version - 4; | 462 int mac_os_x_minor_version = darwin_major_version - 4; |
463 DLOG_IF(WARNING, darwin_major_version > 13) << "Assuming Darwin " | 463 DLOG_IF(WARNING, darwin_major_version > 14) << "Assuming Darwin " |
464 << base::IntToString(darwin_major_version) << " is Mac OS X 10." | 464 << base::IntToString(darwin_major_version) << " is Mac OS X 10." |
465 << base::IntToString(mac_os_x_minor_version); | 465 << base::IntToString(mac_os_x_minor_version); |
466 | 466 |
467 return mac_os_x_minor_version; | 467 return mac_os_x_minor_version; |
468 } | 468 } |
469 | 469 |
470 // Returns the running system's Mac OS X minor version. This is the |y| value | 470 // Returns the running system's Mac OS X minor version. This is the |y| value |
471 // in 10.y or 10.y.z. | 471 // in 10.y or 10.y.z. |
472 int MacOSXMinorVersion() { | 472 int MacOSXMinorVersion() { |
473 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); | 473 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); |
474 return mac_os_x_minor_version; | 474 return mac_os_x_minor_version; |
475 } | 475 } |
476 | 476 |
477 enum { | 477 enum { |
478 SNOW_LEOPARD_MINOR_VERSION = 6, | 478 SNOW_LEOPARD_MINOR_VERSION = 6, |
479 LION_MINOR_VERSION = 7, | 479 LION_MINOR_VERSION = 7, |
480 MOUNTAIN_LION_MINOR_VERSION = 8, | 480 MOUNTAIN_LION_MINOR_VERSION = 8, |
481 MAVERICKS_MINOR_VERSION = 9, | 481 MAVERICKS_MINOR_VERSION = 9, |
482 YOSEMITE_MINOR_VERSION = 10, | |
482 }; | 483 }; |
483 | 484 |
484 } // namespace | 485 } // namespace |
485 | 486 |
486 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) | 487 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) |
487 bool IsOSSnowLeopard() { | 488 bool IsOSSnowLeopard() { |
488 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION; | 489 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION; |
489 } | 490 } |
490 #endif | 491 #endif |
491 | 492 |
(...skipping 26 matching lines...) Expand all Loading... | |
518 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; | 519 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; |
519 } | 520 } |
520 #endif | 521 #endif |
521 | 522 |
522 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9) | 523 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9) |
523 bool IsOSMavericksOrLater() { | 524 bool IsOSMavericksOrLater() { |
524 return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION; | 525 return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION; |
525 } | 526 } |
526 #endif | 527 #endif |
527 | 528 |
528 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9) | 529 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10) |
529 bool IsOSLaterThanMavericks_DontCallThis() { | 530 bool IsOSYosemite() { |
531 return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION; | |
532 } | |
533 #endif | |
534 | |
535 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10) | |
536 bool IsOSYosemiteOrLater() { | |
537 return MacOSXMinorVersion() >= YOSEMITE_MINOR_VERSION; | |
538 } | |
539 #endif | |
540 | |
541 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10) | |
542 bool IsOSLaterThanYosemite_DontCallThis() { | |
530 return MacOSXMinorVersion() > MAVERICKS_MINOR_VERSION; | 543 return MacOSXMinorVersion() > MAVERICKS_MINOR_VERSION; |
Mark Mentovai
2014/06/12 18:00:27
This is wrong.
Avi (use Gerrit)
2014/06/12 18:04:35
Done.
| |
531 } | 544 } |
532 #endif | 545 #endif |
533 | 546 |
534 std::string GetModelIdentifier() { | 547 std::string GetModelIdentifier() { |
535 std::string return_string; | 548 std::string return_string; |
536 ScopedIOObject<io_service_t> platform_expert( | 549 ScopedIOObject<io_service_t> platform_expert( |
537 IOServiceGetMatchingService(kIOMasterPortDefault, | 550 IOServiceGetMatchingService(kIOMasterPortDefault, |
538 IOServiceMatching("IOPlatformExpertDevice"))); | 551 IOServiceMatching("IOPlatformExpertDevice"))); |
539 if (platform_expert) { | 552 if (platform_expert) { |
540 ScopedCFTypeRef<CFDataRef> model_data( | 553 ScopedCFTypeRef<CFDataRef> model_data( |
(...skipping 28 matching lines...) Expand all Loading... | |
569 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) | 582 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) |
570 return false; | 583 return false; |
571 *type = ident.substr(0, number_loc); | 584 *type = ident.substr(0, number_loc); |
572 *major = major_tmp; | 585 *major = major_tmp; |
573 *minor = minor_tmp; | 586 *minor = minor_tmp; |
574 return true; | 587 return true; |
575 } | 588 } |
576 | 589 |
577 } // namespace mac | 590 } // namespace mac |
578 } // namespace base | 591 } // namespace base |
OLD | NEW |