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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 BASE_EXPORT bool IsOSLionOrEarlier(); | 133 BASE_EXPORT bool IsOSLionOrEarlier(); |
134 BASE_EXPORT bool IsOSLionOrLater(); | 134 BASE_EXPORT bool IsOSLionOrLater(); |
135 | 135 |
136 // Mountain Lion is Mac OS X 10.8, Darwin 12. | 136 // Mountain Lion is Mac OS X 10.8, Darwin 12. |
137 BASE_EXPORT bool IsOSMountainLion(); | 137 BASE_EXPORT bool IsOSMountainLion(); |
138 BASE_EXPORT bool IsOSMountainLionOrEarlier(); | 138 BASE_EXPORT bool IsOSMountainLionOrEarlier(); |
139 BASE_EXPORT bool IsOSMountainLionOrLater(); | 139 BASE_EXPORT bool IsOSMountainLionOrLater(); |
140 | 140 |
141 // Mavericks is Mac OS X 10.9, Darwin 13. | 141 // Mavericks is Mac OS X 10.9, Darwin 13. |
142 BASE_EXPORT bool IsOSMavericks(); | 142 BASE_EXPORT bool IsOSMavericks(); |
| 143 BASE_EXPORT bool IsOSMavericksOrEarlier(); |
143 BASE_EXPORT bool IsOSMavericksOrLater(); | 144 BASE_EXPORT bool IsOSMavericksOrLater(); |
144 | 145 |
| 146 // Yosemite is Mac OS X 10.10, Darwin 14. |
| 147 BASE_EXPORT bool IsOSYosemite(); |
| 148 BASE_EXPORT bool IsOSYosemiteOrLater(); |
| 149 |
145 // This should be infrequently used. It only makes sense to use this to avoid | 150 // This should be infrequently used. It only makes sense to use this to avoid |
146 // codepaths that are very likely to break on future (unreleased, untested, | 151 // codepaths that are very likely to break on future (unreleased, untested, |
147 // unborn) OS releases, or to log when the OS is newer than any known version. | 152 // unborn) OS releases, or to log when the OS is newer than any known version. |
148 BASE_EXPORT bool IsOSLaterThanMavericks_DontCallThis(); | 153 BASE_EXPORT bool IsOSLaterThanYosemite_DontCallThis(); |
149 | 154 |
150 // Inline functions that are redundant due to version ranges being mutually- | 155 // Inline functions that are redundant due to version ranges being mutually- |
151 // exclusive. | 156 // exclusive. |
152 inline bool IsOSLionOrEarlier() { return !IsOSMountainLionOrLater(); } | 157 inline bool IsOSLionOrEarlier() { return !IsOSMountainLionOrLater(); } |
153 inline bool IsOSMountainLionOrEarlier() { return !IsOSMavericksOrLater(); } | 158 inline bool IsOSMountainLionOrEarlier() { return !IsOSMavericksOrLater(); } |
| 159 inline bool IsOSMavericksOrEarlier() { return !IsOSYosemiteOrLater(); } |
154 | 160 |
155 // When the deployment target is set, the code produced cannot run on earlier | 161 // 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 | 162 // 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 | 163 // constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro |
158 // contains the value of the deployment target. | 164 // contains the value of the deployment target. |
159 | 165 |
160 #if defined(MAC_OS_X_VERSION_10_7) && \ | 166 #if defined(MAC_OS_X_VERSION_10_7) && \ |
161 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 | 167 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 |
162 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 | 168 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 |
163 inline bool IsOSSnowLeopard() { return false; } | 169 inline bool IsOSSnowLeopard() { return false; } |
(...skipping 21 matching lines...) Expand all Loading... |
185 #if defined(MAC_OS_X_VERSION_10_9) && \ | 191 #if defined(MAC_OS_X_VERSION_10_9) && \ |
186 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 | 192 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 |
187 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9 | 193 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9 |
188 inline bool IsOSMavericksOrLater() { return true; } | 194 inline bool IsOSMavericksOrLater() { return true; } |
189 #endif | 195 #endif |
190 | 196 |
191 #if defined(MAC_OS_X_VERSION_10_9) && \ | 197 #if defined(MAC_OS_X_VERSION_10_9) && \ |
192 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9 | 198 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9 |
193 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9 | 199 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9 |
194 inline bool IsOSMavericks() { return false; } | 200 inline bool IsOSMavericks() { return false; } |
195 inline bool IsOSLaterThanMavericks_DontCallThis() { return true; } | 201 #endif |
| 202 |
| 203 #if defined(MAC_OS_X_VERSION_10_10) && \ |
| 204 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 |
| 205 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_10 |
| 206 inline bool IsOSYosemiteOrLater() { return true; } |
| 207 #endif |
| 208 |
| 209 #if defined(MAC_OS_X_VERSION_10_10) && \ |
| 210 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_10 |
| 211 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_10 |
| 212 inline bool IsOSYosemite() { return false; } |
| 213 inline bool IsOSLaterThanYosemite_DontCallThis() { return true; } |
196 #endif | 214 #endif |
197 | 215 |
198 // Retrieve the system's model identifier string from the IOKit registry: | 216 // Retrieve the system's model identifier string from the IOKit registry: |
199 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon | 217 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon |
200 // failure. | 218 // failure. |
201 BASE_EXPORT std::string GetModelIdentifier(); | 219 BASE_EXPORT std::string GetModelIdentifier(); |
202 | 220 |
203 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). | 221 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). |
204 // If any error occurs, none of the input pointers are touched. | 222 // If any error occurs, none of the input pointers are touched. |
205 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, | 223 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, |
206 std::string* type, | 224 std::string* type, |
207 int32* major, | 225 int32* major, |
208 int32* minor); | 226 int32* minor); |
209 | 227 |
210 } // namespace mac | 228 } // namespace mac |
211 } // namespace base | 229 } // namespace base |
212 | 230 |
213 #endif // BASE_MAC_MAC_UTIL_H_ | 231 #endif // BASE_MAC_MAC_UTIL_H_ |
OLD | NEW |