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

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

Issue 1224283006: Update OS version functions for OS X 10.11 El Capitan. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again Created 5 years, 5 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
« 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 int darwin_major_version = DarwinMajorVersionInternal(); 456 int darwin_major_version = DarwinMajorVersionInternal();
457 457
458 // The Darwin major version is always 4 greater than the Mac OS X minor 458 // The Darwin major version is always 4 greater than the Mac OS X minor
459 // version for Darwin versions beginning with 6, corresponding to Mac OS X 459 // version for Darwin versions beginning with 6, corresponding to Mac OS X
460 // 10.2. Since this correspondence may change in the future, warn when 460 // 10.2. Since this correspondence may change in the future, warn when
461 // encountering a version higher than anything seen before. Older Darwin 461 // encountering a version higher than anything seen before. Older Darwin
462 // versions, or versions that can't be determined, result in 462 // versions, or versions that can't be determined, result in
463 // immediate death. 463 // immediate death.
464 CHECK(darwin_major_version >= 6); 464 CHECK(darwin_major_version >= 6);
465 int mac_os_x_minor_version = darwin_major_version - 4; 465 int mac_os_x_minor_version = darwin_major_version - 4;
466 DLOG_IF(WARNING, darwin_major_version > 14) << "Assuming Darwin " 466 DLOG_IF(WARNING, darwin_major_version > 15) << "Assuming Darwin "
467 << base::IntToString(darwin_major_version) << " is Mac OS X 10." 467 << base::IntToString(darwin_major_version) << " is Mac OS X 10."
468 << base::IntToString(mac_os_x_minor_version); 468 << base::IntToString(mac_os_x_minor_version);
469 469
470 return mac_os_x_minor_version; 470 return mac_os_x_minor_version;
471 } 471 }
472 472
473 // Returns the running system's Mac OS X minor version. This is the |y| value 473 // Returns the running system's Mac OS X minor version. This is the |y| value
474 // in 10.y or 10.y.z. 474 // in 10.y or 10.y.z.
475 int MacOSXMinorVersion() { 475 int MacOSXMinorVersion() {
476 static int mac_os_x_minor_version = MacOSXMinorVersionInternal(); 476 static int mac_os_x_minor_version = MacOSXMinorVersionInternal();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION; 535 return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION;
536 } 536 }
537 #endif 537 #endif
538 538
539 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10) 539 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10)
540 bool IsOSYosemiteOrLater() { 540 bool IsOSYosemiteOrLater() {
541 return MacOSXMinorVersion() >= YOSEMITE_MINOR_VERSION; 541 return MacOSXMinorVersion() >= YOSEMITE_MINOR_VERSION;
542 } 542 }
543 #endif 543 #endif
544 544
545 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10)
546 bool IsOSLaterThanYosemite_DontCallThis() {
547 return MacOSXMinorVersion() > YOSEMITE_MINOR_VERSION;
548 }
549 #endif
550
551 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11) 545 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11)
552 bool IsOSElCapitan() { 546 bool IsOSElCapitan() {
553 return MacOSXMinorVersion() == EL_CAPITAN_MINOR_VERSION; 547 return MacOSXMinorVersion() == EL_CAPITAN_MINOR_VERSION;
554 } 548 }
555 #endif 549 #endif
556 550
557 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_11) 551 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_11)
558 bool IsOSElCapitanOrLater() { 552 bool IsOSElCapitanOrLater() {
559 return MacOSXMinorVersion() >= EL_CAPITAN_MINOR_VERSION; 553 return MacOSXMinorVersion() >= EL_CAPITAN_MINOR_VERSION;
560 } 554 }
561 #endif 555 #endif
562 556
557 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_11)
558 bool IsOSLaterThanElCapitan_DontCallThis() {
559 return MacOSXMinorVersion() > EL_CAPITAN_MINOR_VERSION;
560 }
561 #endif
562
563 std::string GetModelIdentifier() { 563 std::string GetModelIdentifier() {
564 std::string return_string; 564 std::string return_string;
565 ScopedIOObject<io_service_t> platform_expert( 565 ScopedIOObject<io_service_t> platform_expert(
566 IOServiceGetMatchingService(kIOMasterPortDefault, 566 IOServiceGetMatchingService(kIOMasterPortDefault,
567 IOServiceMatching("IOPlatformExpertDevice"))); 567 IOServiceMatching("IOPlatformExpertDevice")));
568 if (platform_expert) { 568 if (platform_expert) {
569 ScopedCFTypeRef<CFDataRef> model_data( 569 ScopedCFTypeRef<CFDataRef> model_data(
570 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( 570 static_cast<CFDataRef>(IORegistryEntryCreateCFProperty(
571 platform_expert, 571 platform_expert,
572 CFSTR("model"), 572 CFSTR("model"),
(...skipping 25 matching lines...) Expand all
598 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) 598 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
599 return false; 599 return false;
600 *type = ident.substr(0, number_loc); 600 *type = ident.substr(0, number_loc);
601 *major = major_tmp; 601 *major = major_tmp;
602 *minor = minor_tmp; 602 *minor = minor_tmp;
603 return true; 603 return true;
604 } 604 }
605 605
606 } // namespace mac 606 } // namespace mac
607 } // namespace base 607 } // 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