Chromium Code Reviews| Index: base/sys_info_mac.mm |
| diff --git a/base/sys_info_mac.cc b/base/sys_info_mac.mm |
| similarity index 66% |
| rename from base/sys_info_mac.cc |
| rename to base/sys_info_mac.mm |
| index ff1ec5c1e69bb8b1cdce2eb08fc1db703c780402..b44bb5bbe29ac186a9392db4889728ed5e09ca4f 100644 |
| --- a/base/sys_info_mac.cc |
| +++ b/base/sys_info_mac.mm |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -6,6 +6,7 @@ |
| #include <ApplicationServices/ApplicationServices.h> |
| #include <CoreServices/CoreServices.h> |
| +#import <Foundation/Foundation.h> |
| #include <mach/mach_host.h> |
| #include <mach/mach_init.h> |
| #include <stddef.h> |
| @@ -14,7 +15,9 @@ |
| #include <sys/types.h> |
| #include "base/logging.h" |
| +#include "base/mac/mac_util.h" |
| #include "base/mac/scoped_mach_port.h" |
| +#import "base/mac/sdk_forward_declarations.h" |
| #include "base/macros.h" |
| #include "base/strings/stringprintf.h" |
| @@ -36,12 +39,29 @@ std::string SysInfo::OperatingSystemVersion() { |
| void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version, |
| int32_t* minor_version, |
| int32_t* bugfix_version) { |
| - Gestalt(gestaltSystemVersionMajor, |
| - reinterpret_cast<SInt32*>(major_version)); |
| - Gestalt(gestaltSystemVersionMinor, |
| - reinterpret_cast<SInt32*>(minor_version)); |
| - Gestalt(gestaltSystemVersionBugFix, |
| - reinterpret_cast<SInt32*>(bugfix_version)); |
| + NSProcessInfo* processInfo = [NSProcessInfo processInfo]; |
| + if ([processInfo respondsToSelector:@selector(operatingSystemVersion)]) { |
| + NSOperatingSystemVersion version = [processInfo operatingSystemVersion]; |
| + *major_version = version.majorVersion; |
| + *minor_version = version.minorVersion; |
| + *bugfix_version = version.patchVersion; |
| + } else { |
| + // -[NSProcessInfo operatingSystemVersion] is documented available in 10.10. |
| + // It's also available via a private API since 10.9.2. For the remaining |
| + // cases in 10.9, rely on ::Gestalt(..). This can be removed once 10.9 is no |
|
Nico
2016/03/31 19:42:19
Maybe replace last sentence with "Since this code
tapted
2016/03/31 20:44:23
Done.
|
| + // longer supported. Gestalt was deprecated in 10.8, so suppress the |
| + // deprecation warning. |
| + DCHECK(base::mac::IsOSMavericks()); |
| +#pragma clang diagnostic push |
| +#pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| + Gestalt(gestaltSystemVersionMajor, |
| + reinterpret_cast<SInt32*>(major_version)); |
| + Gestalt(gestaltSystemVersionMinor, |
| + reinterpret_cast<SInt32*>(minor_version)); |
| + Gestalt(gestaltSystemVersionBugFix, |
| + reinterpret_cast<SInt32*>(bugfix_version)); |
| +#pragma clang diagnostic pop |
| + } |
| } |
| // static |