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 <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <string> | 10 #include <string> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 inline bool IsAtMostOS10_##V() { \ | 132 inline bool IsAtMostOS10_##V() { \ |
133 TEST_DEPLOYMENT_TARGET(>, V, false) \ | 133 TEST_DEPLOYMENT_TARGET(>, V, false) \ |
134 return internal::MacOSXMinorVersion() <= V; \ | 134 return internal::MacOSXMinorVersion() <= V; \ |
135 } | 135 } |
136 | 136 |
137 #define TEST_DEPLOYMENT_TARGET(OP, V, RET) \ | 137 #define TEST_DEPLOYMENT_TARGET(OP, V, RET) \ |
138 if (MAC_OS_X_VERSION_MIN_REQUIRED OP MAC_OS_X_VERSION_10_##V) \ | 138 if (MAC_OS_X_VERSION_MIN_REQUIRED OP MAC_OS_X_VERSION_10_##V) \ |
139 return RET; | 139 return RET; |
140 #define IGNORE_DEPLOYMENT_TARGET(OP, V, RET) | 140 #define IGNORE_DEPLOYMENT_TARGET(OP, V, RET) |
141 | 141 |
142 DEFINE_IS_OS_FUNCS(9, TEST_DEPLOYMENT_TARGET) | |
143 DEFINE_IS_OS_FUNCS(10, TEST_DEPLOYMENT_TARGET) | 142 DEFINE_IS_OS_FUNCS(10, TEST_DEPLOYMENT_TARGET) |
144 | 143 |
145 #ifdef MAC_OS_X_VERSION_10_11 | 144 #ifdef MAC_OS_X_VERSION_10_11 |
146 DEFINE_IS_OS_FUNCS(11, TEST_DEPLOYMENT_TARGET) | 145 DEFINE_IS_OS_FUNCS(11, TEST_DEPLOYMENT_TARGET) |
147 #else | 146 #else |
148 DEFINE_IS_OS_FUNCS(11, IGNORE_DEPLOYMENT_TARGET) | 147 DEFINE_IS_OS_FUNCS(11, IGNORE_DEPLOYMENT_TARGET) |
149 #endif | 148 #endif |
150 | 149 |
151 #ifdef MAC_OS_X_VERSION_10_12 | 150 #ifdef MAC_OS_X_VERSION_10_12 |
152 DEFINE_IS_OS_FUNCS(12, TEST_DEPLOYMENT_TARGET) | 151 DEFINE_IS_OS_FUNCS(12, TEST_DEPLOYMENT_TARGET) |
153 #else | 152 #else |
154 DEFINE_IS_OS_FUNCS(12, IGNORE_DEPLOYMENT_TARGET) | 153 DEFINE_IS_OS_FUNCS(12, IGNORE_DEPLOYMENT_TARGET) |
155 #endif | 154 #endif |
156 | 155 |
| 156 // Straggler for the oldest OS version we support. |
| 157 inline bool IsOS10_9() { |
| 158 TEST_DEPLOYMENT_TARGET(>, 9, false) |
| 159 return internal::MacOSXMinorVersion() == 9; |
| 160 } |
| 161 |
157 #undef IGNORE_DEPLOYMENT_TARGET | 162 #undef IGNORE_DEPLOYMENT_TARGET |
158 #undef TEST_DEPLOYMENT_TARGET | 163 #undef TEST_DEPLOYMENT_TARGET |
159 #undef DEFINE_IS_OS_FUNCS | 164 #undef DEFINE_IS_OS_FUNCS |
160 | 165 |
161 // This should be infrequently used. It only makes sense to use this to avoid | 166 // This should be infrequently used. It only makes sense to use this to avoid |
162 // codepaths that are very likely to break on future (unreleased, untested, | 167 // codepaths that are very likely to break on future (unreleased, untested, |
163 // unborn) OS releases, or to log when the OS is newer than any known version. | 168 // unborn) OS releases, or to log when the OS is newer than any known version. |
164 inline bool IsOSLaterThan10_12_DontCallThis() { | 169 inline bool IsOSLaterThan10_12_DontCallThis() { |
165 return !IsAtMostOS10_12(); | 170 return !IsAtMostOS10_12(); |
166 } | 171 } |
167 | 172 |
168 // Retrieve the system's model identifier string from the IOKit registry: | 173 // Retrieve the system's model identifier string from the IOKit registry: |
169 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon | 174 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon |
170 // failure. | 175 // failure. |
171 BASE_EXPORT std::string GetModelIdentifier(); | 176 BASE_EXPORT std::string GetModelIdentifier(); |
172 | 177 |
173 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). | 178 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). |
174 // If any error occurs, none of the input pointers are touched. | 179 // If any error occurs, none of the input pointers are touched. |
175 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, | 180 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, |
176 std::string* type, | 181 std::string* type, |
177 int32_t* major, | 182 int32_t* major, |
178 int32_t* minor); | 183 int32_t* minor); |
179 | 184 |
180 } // namespace mac | 185 } // namespace mac |
181 } // namespace base | 186 } // namespace base |
182 | 187 |
183 #endif // BASE_MAC_MAC_UTIL_H_ | 188 #endif // BASE_MAC_MAC_UTIL_H_ |
OLD | NEW |