Chromium Code Reviews| 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. |
| 146 BASE_EXPORT bool IsOSLaterThanLion(); | 151 BASE_EXPORT |
| 152 bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement(); | |
|
Avi (use Gerrit)
2012/03/14 17:00:52
Alternatively, drop this and give me IsOSMountainL
| |
| 147 | 153 |
| 148 // When the deployment target is set, the code produced cannot run on earlier | 154 // 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 | 155 // 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 | 156 // constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro |
| 151 // contains the value of the deployment target. | 157 // contains the value of the deployment target. |
| 152 | 158 |
| 153 #if defined(MAC_OS_X_VERSION_10_6) && \ | 159 #if defined(MAC_OS_X_VERSION_10_6) && \ |
| 154 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 | 160 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 |
| 155 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6 | 161 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6 |
| 156 inline bool IsOSLeopard() { return false; } | 162 inline bool IsOSLeopard() { return false; } |
| 157 inline bool IsOSLeopardOrEarlier() { return false; } | 163 inline bool IsOSLeopardOrEarlier() { return false; } |
| 158 inline bool IsOSSnowLeopardOrLater() { return true; } | 164 inline bool IsOSSnowLeopardOrLater() { return true; } |
| 159 #endif | 165 #endif |
| 160 | 166 |
| 161 #if defined(MAC_OS_X_VERSION_10_7) && \ | 167 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 162 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 | 168 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 |
| 163 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 | 169 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 |
| 164 inline bool IsOSSnowLeopard() { return false; } | 170 inline bool IsOSSnowLeopard() { return false; } |
| 165 inline bool IsOSSnowLeopardOrEarlier() { return false; } | 171 inline bool IsOSSnowLeopardOrEarlier() { return false; } |
| 166 inline bool IsOSLionOrLater() { return true; } | 172 inline bool IsOSLionOrLater() { return true; } |
| 167 #endif | 173 #endif |
| 168 | 174 |
| 169 #if defined(MAC_OS_X_VERSION_10_7) && \ | 175 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 170 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 | 176 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 |
| 171 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 | 177 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 |
| 172 inline bool IsOSLion() { return false; } | 178 inline bool IsOSLion() { return false; } |
| 173 inline bool IsOSLaterThanLion() { return true; } | 179 inline bool IsOSLionOrEarlier() { return false; } |
| 180 #endif | |
| 181 | |
| 182 #if defined(MAC_OS_X_VERSION_10_8) && \ | |
| 183 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 | |
| 184 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8 | |
| 185 inline bool IsOSMountainLionOrLater() { return true; } | |
| 186 #endif | |
| 187 | |
| 188 #if defined(MAC_OS_X_VERSION_10_8) && \ | |
| 189 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8 | |
| 190 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8 | |
| 191 inline bool IsOSMountainLion() { return false; } | |
| 192 inline bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement() | |
| 193 { | |
| 194 return true; | |
| 195 } | |
| 174 #endif | 196 #endif |
| 175 | 197 |
| 176 // Retrieve the system's model identifier string from the IOKit registry: | 198 // Retrieve the system's model identifier string from the IOKit registry: |
| 177 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon | 199 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon |
| 178 // failure. | 200 // failure. |
| 179 BASE_EXPORT std::string GetModelIdentifier(); | 201 BASE_EXPORT std::string GetModelIdentifier(); |
| 180 | 202 |
| 181 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). | 203 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). |
| 182 // If any error occurs, none of the input pointers are touched. | 204 // If any error occurs, none of the input pointers are touched. |
| 183 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, | 205 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, |
| 184 std::string* type, | 206 std::string* type, |
| 185 int32* major, | 207 int32* major, |
| 186 int32* minor); | 208 int32* minor); |
| 187 | 209 |
| 188 } // namespace mac | 210 } // namespace mac |
| 189 } // namespace base | 211 } // namespace base |
| 190 | 212 |
| 191 #endif // BASE_MAC_MAC_UTIL_H_ | 213 #endif // BASE_MAC_MAC_UTIL_H_ |
| OLD | NEW |