Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: base/mac/mac_util.h

Issue 25286002: Update OS version functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uma Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/mac/mac_util.mm » ('j') | chrome/browser/chrome_browser_main_mac.mm » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
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();
159
160 // Inline functions that are redundant due to version ranges being mutually-
161 // exclusive.
162 inline bool IsOSLionOrEarlier() { return !IsOSMountainLionOrLater(); }
163 inline bool IsOSMountainLionOrEarlier() { return !IsOSMavericksOrLater(); }
154 164
155 // When the deployment target is set, the code produced cannot run on earlier 165 // 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 166 // 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 167 // constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro
158 // contains the value of the deployment target. 168 // contains the value of the deployment target.
159 169
160 #if defined(MAC_OS_X_VERSION_10_7) && \ 170 #if defined(MAC_OS_X_VERSION_10_7) && \
161 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 171 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
162 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 172 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7
163 inline bool IsOSSnowLeopard() { return false; } 173 inline bool IsOSSnowLeopard() { return false; }
164 inline bool IsOSLionOrLater() { return true; } 174 inline bool IsOSLionOrLater() { return true; }
165 #endif 175 #endif
166 176
167 #if defined(MAC_OS_X_VERSION_10_7) && \ 177 #if defined(MAC_OS_X_VERSION_10_7) && \
168 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
169 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 179 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7
170 inline bool IsOSLion() { return false; } 180 inline bool IsOSLion() { return false; }
171 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_GE_10_8
177 inline bool IsOSMountainLionOrLater() { return true; } 186 inline bool IsOSMountainLionOrLater() { return true; }
178 #endif 187 #endif
179 188
180 #if defined(MAC_OS_X_VERSION_10_8) && \ 189 #if defined(MAC_OS_X_VERSION_10_8) && \
181 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8 190 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8
182 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8 191 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8
183 inline bool IsOSMountainLion() { return false; } 192 inline bool IsOSMountainLion() { return false; }
184 inline bool IsOSLaterThanMountainLion_DontCallThis() { 193 #endif
185 return true; 194
186 } 195 #if defined(MAC_OS_X_VERSION_10_9) && \
196 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
197 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9
198 inline bool IsOSMavericksOrLater() { return true; }
199 #endif
200
201 #if defined(MAC_OS_X_VERSION_10_9) && \
202 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
203 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9
204 inline bool IsOSMavericks() { return false; }
205 inline bool IsOSLaterThanMavericks_DontCallThis() { return true; }
187 #endif 206 #endif
188 207
189 // Retrieve the system's model identifier string from the IOKit registry: 208 // Retrieve the system's model identifier string from the IOKit registry:
190 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon 209 // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon
191 // failure. 210 // failure.
192 BASE_EXPORT std::string GetModelIdentifier(); 211 BASE_EXPORT std::string GetModelIdentifier();
193 212
194 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1). 213 // Parse a model identifier string; for example, into ("MacBookPro", 6, 1).
195 // If any error occurs, none of the input pointers are touched. 214 // If any error occurs, none of the input pointers are touched.
196 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident, 215 BASE_EXPORT bool ParseModelIdentifier(const std::string& ident,
197 std::string* type, 216 std::string* type,
198 int32* major, 217 int32* major,
199 int32* minor); 218 int32* minor);
200 219
201 } // namespace mac 220 } // namespace mac
202 } // namespace base 221 } // namespace base
203 222
204 #endif // BASE_MAC_MAC_UTIL_H_ 223 #endif // BASE_MAC_MAC_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/mac/mac_util.mm » ('j') | chrome/browser/chrome_browser_main_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698