| 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 <errno.h> | 9 #include <errno.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 } | 449 } |
| 450 | 450 |
| 451 // Returns the running system's Mac OS X minor version. This is the |y| value | 451 // Returns the running system's Mac OS X minor version. This is the |y| value |
| 452 // in 10.y or 10.y.z. | 452 // in 10.y or 10.y.z. |
| 453 int MacOSXMinorVersion() { | 453 int MacOSXMinorVersion() { |
| 454 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); | 454 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); |
| 455 return mac_os_x_minor_version; | 455 return mac_os_x_minor_version; |
| 456 } | 456 } |
| 457 | 457 |
| 458 enum { | 458 enum { |
| 459 SNOW_LEOPARD_MINOR_VERSION = 6, | |
| 460 LION_MINOR_VERSION = 7, | |
| 461 MOUNTAIN_LION_MINOR_VERSION = 8, | |
| 462 MAVERICKS_MINOR_VERSION = 9, | 459 MAVERICKS_MINOR_VERSION = 9, |
| 463 YOSEMITE_MINOR_VERSION = 10, | 460 YOSEMITE_MINOR_VERSION = 10, |
| 464 EL_CAPITAN_MINOR_VERSION = 11, | 461 EL_CAPITAN_MINOR_VERSION = 11, |
| 462 SIERRA_MINOR_VERSION = 12, |
| 465 }; | 463 }; |
| 466 | 464 |
| 467 } // namespace | 465 } // namespace |
| 468 | 466 |
| 469 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8) | |
| 470 bool IsOSMountainLion() { | |
| 471 return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION; | |
| 472 } | |
| 473 #endif | |
| 474 | |
| 475 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8) | |
| 476 bool IsOSMountainLionOrLater() { | |
| 477 return MacOSXMinorVersion() >= MOUNTAIN_LION_MINOR_VERSION; | |
| 478 } | |
| 479 #endif | |
| 480 | |
| 481 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9) | 467 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9) |
| 482 bool IsOSMavericks() { | 468 bool IsOSMavericks() { |
| 483 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; | 469 return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION; |
| 484 } | 470 } |
| 485 #endif | 471 #endif |
| 486 | 472 |
| 487 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9) | 473 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9) |
| 488 bool IsOSMavericksOrLater() { | 474 bool IsOSMavericksOrLater() { |
| 489 return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION; | 475 return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION; |
| 490 } | 476 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 507 return MacOSXMinorVersion() == EL_CAPITAN_MINOR_VERSION; | 493 return MacOSXMinorVersion() == EL_CAPITAN_MINOR_VERSION; |
| 508 } | 494 } |
| 509 #endif | 495 #endif |
| 510 | 496 |
| 511 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_11) | 497 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_11) |
| 512 bool IsOSElCapitanOrLater() { | 498 bool IsOSElCapitanOrLater() { |
| 513 return MacOSXMinorVersion() >= EL_CAPITAN_MINOR_VERSION; | 499 return MacOSXMinorVersion() >= EL_CAPITAN_MINOR_VERSION; |
| 514 } | 500 } |
| 515 #endif | 501 #endif |
| 516 | 502 |
| 517 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11) | 503 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12) |
| 518 bool IsOSLaterThanElCapitan_DontCallThis() { | 504 bool IsOSSierra() { |
| 519 return MacOSXMinorVersion() > EL_CAPITAN_MINOR_VERSION; | 505 return MacOSXMinorVersion() == SIERRA_MINOR_VERSION; |
| 520 } | 506 } |
| 521 #endif | 507 #endif |
| 522 | 508 |
| 509 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_12) |
| 510 bool IsOSSierraOrLater() { |
| 511 return MacOSXMinorVersion() >= SIERRA_MINOR_VERSION; |
| 512 } |
| 513 #endif |
| 514 |
| 515 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_12) |
| 516 bool IsOSLaterThanSierra_DontCallThis() { |
| 517 return MacOSXMinorVersion() > SIERRA_MINOR_VERSION; |
| 518 } |
| 519 #endif |
| 520 |
| 523 std::string GetModelIdentifier() { | 521 std::string GetModelIdentifier() { |
| 524 std::string return_string; | 522 std::string return_string; |
| 525 ScopedIOObject<io_service_t> platform_expert( | 523 ScopedIOObject<io_service_t> platform_expert( |
| 526 IOServiceGetMatchingService(kIOMasterPortDefault, | 524 IOServiceGetMatchingService(kIOMasterPortDefault, |
| 527 IOServiceMatching("IOPlatformExpertDevice"))); | 525 IOServiceMatching("IOPlatformExpertDevice"))); |
| 528 if (platform_expert) { | 526 if (platform_expert) { |
| 529 ScopedCFTypeRef<CFDataRef> model_data( | 527 ScopedCFTypeRef<CFDataRef> model_data( |
| 530 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( | 528 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( |
| 531 platform_expert, | 529 platform_expert, |
| 532 CFSTR("model"), | 530 CFSTR("model"), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 558 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) | 556 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) |
| 559 return false; | 557 return false; |
| 560 *type = ident.substr(0, number_loc); | 558 *type = ident.substr(0, number_loc); |
| 561 *major = major_tmp; | 559 *major = major_tmp; |
| 562 *minor = minor_tmp; | 560 *minor = minor_tmp; |
| 563 return true; | 561 return true; |
| 564 } | 562 } |
| 565 | 563 |
| 566 } // namespace mac | 564 } // namespace mac |
| 567 } // namespace base | 565 } // namespace base |
| OLD | NEW |