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 | 7 |
| 8 #include <AvailabilityMacros.h> | 8 #include <AvailabilityMacros.h> |
| 9 #include <Carbon/Carbon.h> | 9 #include <Carbon/Carbon.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 // Snow Leopard is Mac OS X 10.6, Darwin 10. | 138 // Snow Leopard is Mac OS X 10.6, Darwin 10. |
| 139 BASE_EXPORT bool IsOSSnowLeopard(); | 139 BASE_EXPORT bool IsOSSnowLeopard(); |
| 140 | 140 |
| 141 // Lion is Mac OS X 10.7, Darwin 11. | 141 // Lion is Mac OS X 10.7, Darwin 11. |
| 142 BASE_EXPORT bool IsOSLion(); | 142 BASE_EXPORT bool IsOSLion(); |
| 143 BASE_EXPORT bool IsOSLionOrEarlier(); | 143 BASE_EXPORT bool IsOSLionOrEarlier(); |
| 144 BASE_EXPORT bool IsOSLionOrLater(); | 144 BASE_EXPORT bool IsOSLionOrLater(); |
| 145 | 145 |
| 146 // Mountain Lion is Mac OS X 10.8, Darwin 12. | 146 // Mountain Lion is Mac OS X 10.8, Darwin 12. |
| 147 BASE_EXPORT bool IsOSMountainLion(); | 147 BASE_EXPORT bool IsOSMountainLion(); |
| 148 BASE_EXPORT bool IsOSMountainLionOrEarlier(); | |
| 148 BASE_EXPORT bool IsOSMountainLionOrLater(); | 149 BASE_EXPORT bool IsOSMountainLionOrLater(); |
| 149 | 150 |
| 151 // Mavericks is Mac OS X 10.9, Darwin 13. | |
|
Mark Mentovai
2013/10/01 16:15:45
As a form of civil disobedience, can we do this wi
Avi (use Gerrit)
2013/10/01 17:07:27
As idiotic as it is, that's its name.
| |
| 152 BASE_EXPORT bool IsOSMavericks(); | |
| 153 BASE_EXPORT bool IsOSMavericksOrLater(); | |
| 154 | |
| 150 // This should be infrequently used. It only makes sense to use this to avoid | 155 // This should be infrequently used. It only makes sense to use this to avoid |
| 151 // codepaths that are very likely to break on future (unreleased, untested, | 156 // codepaths that are very likely to break on future (unreleased, untested, |
| 152 // unborn) OS releases, or to log when the OS is newer than any known version. | 157 // unborn) OS releases, or to log when the OS is newer than any known version. |
| 153 BASE_EXPORT bool IsOSLaterThanMountainLion_DontCallThis(); | 158 BASE_EXPORT bool IsOSLaterThanMavericks_DontCallThis(); |
| 154 | 159 |
| 155 // When the deployment target is set, the code produced cannot run on earlier | 160 // When the deployment target is set, the code produced cannot run on earlier |
| 156 // OS releases. That enables some of the IsOS* family to be implemented as | 161 // OS releases. That enables some of the IsOS* family to be implemented as |
| 157 // constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro | 162 // constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro |
| 158 // contains the value of the deployment target. | 163 // contains the value of the deployment target. |
| 159 | 164 |
| 160 #if defined(MAC_OS_X_VERSION_10_7) && \ | 165 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 161 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 | 166 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 |
| 162 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 | 167 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSSNOWLEOPARD |
| 163 inline bool IsOSSnowLeopard() { return false; } | 168 inline bool IsOSSnowLeopard() { return false; } |
| 169 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLIONORLATER | |
| 164 inline bool IsOSLionOrLater() { return true; } | 170 inline bool IsOSLionOrLater() { return true; } |
| 165 #endif | 171 #endif |
| 166 | 172 |
| 167 #if defined(MAC_OS_X_VERSION_10_7) && \ | 173 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 168 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 | 174 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 |
| 169 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 | 175 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSSNOWLEOPARD |
| 176 inline bool IsOSSnowLeopard() { return false; } | |
|
Mark Mentovai
2013/10/01 16:15:45
This will already have been defined on line 168. I
Avi (use Gerrit)
2013/10/01 17:07:27
Oh. Right.
| |
| 177 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLION | |
| 170 inline bool IsOSLion() { return false; } | 178 inline bool IsOSLion() { return false; } |
| 179 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLIONOREARLIER | |
| 171 inline bool IsOSLionOrEarlier() { return false; } | 180 inline bool IsOSLionOrEarlier() { return false; } |
| 172 #endif | 181 #endif |
| 173 | 182 |
| 174 #if defined(MAC_OS_X_VERSION_10_8) && \ | 183 #if defined(MAC_OS_X_VERSION_10_8) && \ |
| 175 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 | 184 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 |
| 176 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8 | 185 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSSNOWLEOPARD |
| 186 inline bool IsOSSnowLeopard() { return false; } | |
| 187 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLION | |
| 188 inline bool IsOSLion() { return false; } | |
| 189 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLIONOREARLIER | |
| 190 inline bool IsOSLionOrEarlier() { return false; } | |
| 191 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLIONORLATER | |
| 177 inline bool IsOSMountainLionOrLater() { return true; } | 192 inline bool IsOSMountainLionOrLater() { return true; } |
| 178 #endif | 193 #endif |
| 179 | 194 |
| 180 #if defined(MAC_OS_X_VERSION_10_8) && \ | 195 #if defined(MAC_OS_X_VERSION_10_8) && \ |
| 181 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8 | 196 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8 |
| 182 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8 | 197 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSSNOWLEOPARD |
| 198 inline bool IsOSSnowLeopard() { return false; } | |
| 199 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLION | |
| 200 inline bool IsOSLion() { return false; } | |
| 201 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLION | |
| 183 inline bool IsOSMountainLion() { return false; } | 202 inline bool IsOSMountainLion() { return false; } |
| 184 inline bool IsOSLaterThanMountainLion_DontCallThis() { | 203 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLIONOREARLIER |
| 185 return true; | 204 inline bool IsOSLionOrEarlier() { return false; } |
| 186 } | 205 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLIONOREARLIER |
| 206 inline bool IsOSMountainLionOrEarlier() { return false; } | |
| 207 #endif | |
| 208 | |
| 209 #if defined(MAC_OS_X_VERSION_10_9) && \ | |
| 210 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 | |
| 211 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSSNOWLEOPARD | |
| 212 inline bool IsOSSnowLeopard() { return false; } | |
| 213 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLION | |
| 214 inline bool IsOSLion() { return false; } | |
| 215 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLION | |
| 216 inline bool IsOSMountainLion() { return false; } | |
| 217 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLIONOREARLIER | |
| 218 inline bool IsOSLionOrEarlier() { return false; } | |
| 219 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLIONOREARLIER | |
| 220 inline bool IsOSMountainLionOrEarlier() { return false; } | |
| 221 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMAVERICKSORLATER | |
| 222 inline bool IsOSMavericksOrLater() { return true; } | |
| 223 #endif | |
| 224 | |
| 225 #if defined(MAC_OS_X_VERSION_10_9) && \ | |
| 226 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9 | |
| 227 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSSNOWLEOPARD | |
| 228 inline bool IsOSSnowLeopard() { return false; } | |
| 229 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLION | |
| 230 inline bool IsOSLion() { return false; } | |
| 231 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLION | |
| 232 inline bool IsOSMountainLion() { return false; } | |
| 233 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMAVERICKS | |
| 234 inline bool IsOSMavericks() { return false; } | |
| 235 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSLIONOREARLIER | |
| 236 inline bool IsOSLionOrEarlier() { return false; } | |
| 237 #define BASE_MAC_MAC_UTIL_H_INLINED_ISOSMOUNTAINLIONOREARLIER | |
| 238 inline bool IsOSMountainLionOrEarlier() { return false; } | |
| 239 #define BASE_MAC_MAC_UTIL_H_INLINED_ISLATERTHANOSMAVERICKS | |
| 240 inline bool IsOSLaterThanMavericks_DontCallThis() { return true; } | |
| 187 #endif | 241 #endif |
| 188 | 242 |
| 189 // Retrieve the system's model identifier string from the IOKit registry: | 243 // Retrieve the system's model identifier string from the IOKit registry: |
| 190 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon | 244 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon |
| 191 // failure. | 245 // failure. |
| 192 BASE_EXPORT std::string GetModelIdentifier(); | 246 BASE_EXPORT std::string GetModelIdentifier(); |
| 193 | 247 |
| 194 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). | 248 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). |
| 195 // If any error occurs, none of the input pointers are touched. | 249 // If any error occurs, none of the input pointers are touched. |
| 196 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, | 250 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, |
| 197 std::string* type, | 251 std::string* type, |
| 198 int32* major, | 252 int32* major, |
| 199 int32* minor); | 253 int32* minor); |
| 200 | 254 |
| 201 } // namespace mac | 255 } // namespace mac |
| 202 } // namespace base | 256 } // namespace base |
| 203 | 257 |
| 204 #endif // BASE_MAC_MAC_UTIL_H_ | 258 #endif // BASE_MAC_MAC_UTIL_H_ |
| OLD | NEW |