OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Carbon/Carbon.h> | 10 #include <Carbon/Carbon.h> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 | 14 |
14 // TODO(rohitrao): Clean up sites that include mac_util.h and remove this line. | 15 // TODO(rohitrao): Clean up sites that include mac_util.h and remove this line. |
15 #include "base/mac/foundation_util.h" | 16 #include "base/mac/foundation_util.h" |
16 | 17 |
17 #if defined(__OBJC__) | 18 #if defined(__OBJC__) |
18 #import <Foundation/Foundation.h> | 19 #import <Foundation/Foundation.h> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // specified hide flag. | 104 // specified hide flag. |
104 void AddToLoginItems(bool hide_on_startup); | 105 void AddToLoginItems(bool hide_on_startup); |
105 | 106 |
106 // Removes the current application from the list Of Login Items. | 107 // Removes the current application from the list Of Login Items. |
107 void RemoveFromLoginItems(); | 108 void RemoveFromLoginItems(); |
108 | 109 |
109 // Returns true if the current process was automatically launched as a | 110 // Returns true if the current process was automatically launched as a |
110 // 'Login Item' with 'hide on startup' flag. Used to suppress opening windows. | 111 // 'Login Item' with 'hide on startup' flag. Used to suppress opening windows. |
111 bool WasLaunchedAsHiddenLoginItem(); | 112 bool WasLaunchedAsHiddenLoginItem(); |
112 | 113 |
| 114 // Run-time OS version checks. Use these instead of |
| 115 // base::SysInfo::OperatingSystemVersionNumbers. Prefer the "OrEarlier" and |
| 116 // "OrLater" variants to those that check for a specific version, unless you |
| 117 // know for sure that you need to check for a specific version. |
| 118 |
| 119 // Leopard is Mac OS X 10.5, Darwin 9. |
| 120 bool IsOSLeopard(); |
| 121 bool IsOSLeopardOrEarlier(); |
| 122 |
| 123 // Snow Leopard is Mac OS X 10.6, Darwin 10. |
| 124 bool IsOSSnowLeopard(); |
| 125 bool IsOSSnowLeopardOrEarlier(); |
| 126 bool IsOSSnowLeopardOrLater(); |
| 127 |
| 128 // Lion is Mac OS X 10.7, Darwin 11. |
| 129 bool IsOSLion(); |
| 130 bool IsOSLionOrLater(); |
| 131 |
| 132 // This should be infrequently used. It only makes sense to use this to avoid |
| 133 // codepaths that are very likely to break on future (unreleased, untested, |
| 134 // unborn) OS releases. |
| 135 bool IsOSLaterThanLion(); |
| 136 |
| 137 // When the deployment target is set, the code produced cannot run on earlier |
| 138 // OS releases. That enables some of the IsOS* family to be implemented as |
| 139 // constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro |
| 140 // contains the value of the deployment target. |
| 141 |
| 142 #if defined(MAC_OS_X_VERSION_10_6) && \ |
| 143 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 |
| 144 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_6 |
| 145 inline bool IsOSLeopardOrEarlier() { return false; } |
| 146 inline bool IsOSSnowLeopardOrLater() { return true; } |
| 147 #endif |
| 148 |
| 149 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 150 MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 |
| 151 #define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7 |
| 152 inline bool IsOSSnowLeopardOrEarlier() { return false; } |
| 153 inline bool IsOSLionOrLater() { return true; } |
| 154 #endif |
| 155 |
| 156 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 157 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 |
| 158 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 |
| 159 inline bool IsOSLaterThanLion() { return true; } |
| 160 #endif |
| 161 |
113 } // namespace mac | 162 } // namespace mac |
114 } // namespace base | 163 } // namespace base |
115 | 164 |
116 #endif // BASE_MAC_MAC_UTIL_H_ | 165 #endif // BASE_MAC_MAC_UTIL_H_ |
OLD | NEW |