| 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 #ifndef BASE_MAC_MAC_UTIL_H_ | 5 #ifndef BASE_MAC_MAC_UTIL_H_ |
| 6 #define BASE_MAC_MAC_UTIL_H_ | 6 #define BASE_MAC_MAC_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <AvailabilityMacros.h> | 9 #include <AvailabilityMacros.h> |
| 10 #include <Carbon/Carbon.h> | 10 #include <Carbon/Carbon.h> |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 BASE_EXPORT bool IsOSLeopard(); | 131 BASE_EXPORT bool IsOSLeopard(); |
| 132 BASE_EXPORT bool IsOSLeopardOrEarlier(); | 132 BASE_EXPORT bool IsOSLeopardOrEarlier(); |
| 133 | 133 |
| 134 // Snow Leopard is Mac OS X 10.6, Darwin 10. | 134 // Snow Leopard is Mac OS X 10.6, Darwin 10. |
| 135 BASE_EXPORT bool IsOSSnowLeopard(); | 135 BASE_EXPORT bool IsOSSnowLeopard(); |
| 136 BASE_EXPORT bool IsOSSnowLeopardOrEarlier(); | 136 BASE_EXPORT bool IsOSSnowLeopardOrEarlier(); |
| 137 BASE_EXPORT bool IsOSSnowLeopardOrLater(); | 137 BASE_EXPORT bool IsOSSnowLeopardOrLater(); |
| 138 | 138 |
| 139 // Lion is Mac OS X 10.7, Darwin 11. | 139 // Lion is Mac OS X 10.7, Darwin 11. |
| 140 BASE_EXPORT bool IsOSLion(); | 140 BASE_EXPORT bool IsOSLion(); |
| 141 BASE_EXPORT bool IsOSLionOrEarlier(); |
| 141 BASE_EXPORT bool IsOSLionOrLater(); | 142 BASE_EXPORT bool IsOSLionOrLater(); |
| 142 | 143 |
| 144 // Mountain Lion is Mac OS X 10.8, Darwin 12. |
| 145 BASE_EXPORT bool IsOSMountainLion(); |
| 146 BASE_EXPORT bool IsOSMountainLionOrLater(); |
| 147 |
| 143 // This should be infrequently used. It only makes sense to use this to avoid | 148 // This should be infrequently used. It only makes sense to use this to avoid |
| 144 // codepaths that are very likely to break on future (unreleased, untested, | 149 // codepaths that are very likely to break on future (unreleased, untested, |
| 145 // unborn) OS releases. | 150 // unborn) OS releases. |
| 151 BASE_EXPORT |
| 152 bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement(); |
| 153 // TODO(rsesek|avi): Remove when allocators gonna allocate. |
| 146 BASE_EXPORT bool IsOSLaterThanLion(); | 154 BASE_EXPORT bool IsOSLaterThanLion(); |
| 147 | 155 |
| 148 // When the deployment target is set, the code produced cannot run on earlier | 156 // When the deployment target is set, the code produced cannot run on earlier |
| 149 // OS releases. That enables some of the IsOS* family to be implemented as | 157 // OS releases. That enables some of the IsOS* family to be implemented as |
| 150 // constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro | 158 // constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro |
| 151 // contains the value of the deployment target. | 159 // contains the value of the deployment target. |
| 152 | 160 |
| 153 #if defined(MAC_OS_X_VERSION_10_6) && \ | 161 #if defined(MAC_OS_X_VERSION_10_6) && \ |
| 154 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 | 162 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 |
| 155 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6 | 163 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6 |
| 156 inline bool IsOSLeopard() { return false; } | 164 inline bool IsOSLeopard() { return false; } |
| 157 inline bool IsOSLeopardOrEarlier() { return false; } | 165 inline bool IsOSLeopardOrEarlier() { return false; } |
| 158 inline bool IsOSSnowLeopardOrLater() { return true; } | 166 inline bool IsOSSnowLeopardOrLater() { return true; } |
| 159 #endif | 167 #endif |
| 160 | 168 |
| 161 #if defined(MAC_OS_X_VERSION_10_7) && \ | 169 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 162 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 | 170 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 |
| 163 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 | 171 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 |
| 164 inline bool IsOSSnowLeopard() { return false; } | 172 inline bool IsOSSnowLeopard() { return false; } |
| 165 inline bool IsOSSnowLeopardOrEarlier() { return false; } | 173 inline bool IsOSSnowLeopardOrEarlier() { return false; } |
| 166 inline bool IsOSLionOrLater() { return true; } | 174 inline bool IsOSLionOrLater() { return true; } |
| 167 #endif | 175 #endif |
| 168 | 176 |
| 169 #if defined(MAC_OS_X_VERSION_10_7) && \ | 177 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 170 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 | 178 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 |
| 171 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 | 179 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 |
| 172 inline bool IsOSLion() { return false; } | 180 inline bool IsOSLion() { return false; } |
| 181 inline bool IsOSLionOrEarlier() { return false; } |
| 173 inline bool IsOSLaterThanLion() { return true; } | 182 inline bool IsOSLaterThanLion() { return true; } |
| 174 #endif | 183 #endif |
| 175 | 184 |
| 185 #if defined(MAC_OS_X_VERSION_10_8) && \ |
| 186 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 |
| 187 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8 |
| 188 inline bool IsOSMountainLionOrLater() { return true; } |
| 189 #endif |
| 190 |
| 191 #if defined(MAC_OS_X_VERSION_10_8) && \ |
| 192 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8 |
| 193 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8 |
| 194 inline bool IsOSMountainLion() { return false; } |
| 195 inline bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement() |
| 196 { |
| 197 return true; |
| 198 } |
| 199 #endif |
| 200 |
| 176 // Retrieve the system's model identifier string from the IOKit registry: | 201 // Retrieve the system's model identifier string from the IOKit registry: |
| 177 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon | 202 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon |
| 178 // failure. | 203 // failure. |
| 179 BASE_EXPORT std::string GetModelIdentifier(); | 204 BASE_EXPORT std::string GetModelIdentifier(); |
| 180 | 205 |
| 181 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). | 206 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). |
| 182 // If any error occurs, none of the input pointers are touched. | 207 // If any error occurs, none of the input pointers are touched. |
| 183 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, | 208 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, |
| 184 std::string* type, | 209 std::string* type, |
| 185 int32* major, | 210 int32* major, |
| 186 int32* minor); | 211 int32* minor); |
| 187 | 212 |
| 188 } // namespace mac | 213 } // namespace mac |
| 189 } // namespace base | 214 } // namespace base |
| 190 | 215 |
| 191 #endif // BASE_MAC_MAC_UTIL_H_ | 216 #endif // BASE_MAC_MAC_UTIL_H_ |
| OLD | NEW |