| // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef BASE_MAC_UTIL_H_ |
| #define BASE_MAC_UTIL_H_ |
| |
| #include <Carbon/Carbon.h> |
| #include <string> |
| |
| class FilePath; |
| |
| #ifdef __OBJC__ |
| @class NSBundle; |
| #else |
| class NSBundle; |
| #endif |
| |
| namespace mac_util { |
| |
| std::string PathFromFSRef(const FSRef& ref); |
| bool FSRefFromPath(const std::string& path, FSRef* ref); |
| |
| // Returns true if the application is running from a bundle |
| bool AmIBundled(); |
| |
| // Returns true if this process is marked as a "Background only process". |
| bool IsBackgroundOnlyProcess(); |
| |
| // Returns the main bundle or the override, used for code that needs |
| // to fetch resources from bundles, but work within a unittest where we |
| // aren't a bundle. |
| NSBundle* MainAppBundle(); |
| |
| // Set the bundle that MainAppBundle will return, overriding the default value |
| // (Restore the default by calling SetOverrideAppBundle(nil)). |
| void SetOverrideAppBundle(NSBundle* bundle); |
| void SetOverrideAppBundlePath(const FilePath& file_path); |
| |
| // Returns the creator code associated with the CFBundleRef at bundle. |
| OSType CreatorCodeForCFBundleRef(CFBundleRef bundle); |
| |
| // Returns the creator code associated with this application, by calling |
| // CreatorCodeForCFBundleRef for the application's main bundle. If this |
| // information cannot be determined, returns kUnknownType ('????'). This |
| // does not respect the override app bundle because it's based on CFBundle |
| // instead of NSBundle, and because callers probably don't want the override |
| // app bundle's creator code anyway. |
| OSType CreatorCodeForApplication(); |
| |
| // Returns the ~/Library directory. |
| FilePath GetUserLibraryPath(); |
| |
| // Returns an sRGB color space. The return value is a static value; do not |
| // release it! |
| CGColorSpaceRef GetSRGBColorSpace(); |
| |
| // Returns the color space being used by the main display. The return value |
| // is a static value; do not release it! |
| CGColorSpaceRef GetSystemColorSpace(); |
| |
| } // namespace mac_util |
| |
| #endif // BASE_MAC_UTIL_H_ |