diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-29 04:43:14 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-29 04:43:14 +0000 |
commit | 8ca87726c96e1b89fee43afa224b8d3da2d5d399 (patch) | |
tree | 9cdd55fcb4a038265602ccb00c36282345447e41 /base/mac/foundation_util.h | |
parent | 47f22ea3bc0e86842bc3c4a89183d20369e317d7 (diff) | |
download | chromium_src-8ca87726c96e1b89fee43afa224b8d3da2d5d399.zip chromium_src-8ca87726c96e1b89fee43afa224b8d3da2d5d399.tar.gz chromium_src-8ca87726c96e1b89fee43afa224b8d3da2d5d399.tar.bz2 |
mac: Components build for base, easy part
BUG=90078
TEST=none
Review URL: http://codereview.chromium.org/7474010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94636 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac/foundation_util.h')
-rw-r--r-- | base/mac/foundation_util.h | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/base/mac/foundation_util.h b/base/mac/foundation_util.h index dc7d4e7..37c2ff1 100644 --- a/base/mac/foundation_util.h +++ b/base/mac/foundation_util.h @@ -11,6 +11,7 @@ #include <string> #include <vector> +#include "base/base_api.h" #include "base/logging.h" #if defined(__OBJC__) @@ -35,25 +36,25 @@ namespace base { namespace mac { // Returns true if the application is running from a bundle -bool AmIBundled(); -void SetOverrideAmIBundled(bool value); +BASE_API bool AmIBundled(); +BASE_API void SetOverrideAmIBundled(bool value); // Returns true if this process is marked as a "Background only process". -bool IsBackgroundOnlyProcess(); +BASE_API 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(); -FilePath MainAppBundlePath(); +BASE_API NSBundle* MainAppBundle(); +BASE_API FilePath MainAppBundlePath(); // Returns the path to a resource within the MainAppBundle. FilePath PathForMainAppBundleResource(CFStringRef resourceName); // 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); +BASE_API void SetOverrideAppBundle(NSBundle* bundle); +BASE_API void SetOverrideAppBundlePath(const FilePath& file_path); // Returns the creator code associated with the CFBundleRef at bundle. OSType CreatorCodeForCFBundleRef(CFBundleRef bundle); @@ -64,7 +65,7 @@ OSType CreatorCodeForCFBundleRef(CFBundleRef bundle); // 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(); +BASE_API OSType CreatorCodeForApplication(); // Searches for directories for the given key in only the given |domain_mask|. // If found, fills result (which must always be non-NULL) with the @@ -76,32 +77,34 @@ bool GetSearchPathDirectory(NSSearchPathDirectory directory, // Searches for directories for the given key in only the local domain. // If found, fills result (which must always be non-NULL) with the // first found directory and returns true. Otherwise, returns false. -bool GetLocalDirectory(NSSearchPathDirectory directory, FilePath* result); +BASE_API bool GetLocalDirectory(NSSearchPathDirectory directory, + FilePath* result); // Searches for directories for the given key in only the user domain. // If found, fills result (which must always be non-NULL) with the // first found directory and returns true. Otherwise, returns false. -bool GetUserDirectory(NSSearchPathDirectory directory, FilePath* result); +BASE_API bool GetUserDirectory(NSSearchPathDirectory directory, + FilePath* result); // Returns the ~/Library directory. -FilePath GetUserLibraryPath(); +BASE_API FilePath GetUserLibraryPath(); // Takes a path to an (executable) binary and tries to provide the path to an // application bundle containing it. It takes the outermost bundle that it can // find (so for "/Foo/Bar.app/.../Baz.app/..." it produces "/Foo/Bar.app"). // |exec_name| - path to the binary // returns - path to the application bundle, or empty on error -FilePath GetAppBundlePath(const FilePath& exec_name); +BASE_API FilePath GetAppBundlePath(const FilePath& exec_name); // Utility function to pull out a value from a dictionary, check its type, and // return it. Returns NULL if the key is not present or of the wrong type. -CFTypeRef GetValueFromDictionary(CFDictionaryRef dict, - CFStringRef key, - CFTypeID expected_type); +BASE_API CFTypeRef GetValueFromDictionary(CFDictionaryRef dict, + CFStringRef key, + CFTypeID expected_type); // Retain/release calls for memory management in C++. -void NSObjectRetain(void* obj); -void NSObjectRelease(void* obj); +BASE_API void NSObjectRetain(void* obj); +BASE_API void NSObjectRelease(void* obj); // CFTypeRefToNSObjectAutorelease transfers ownership of a Core Foundation // object (one derived from CFTypeRef) to the Foundation memory management @@ -120,16 +123,16 @@ void NSObjectRelease(void* obj); // returned NSObject. // // Returns an id, typed here for C++'s sake as a void*. -void* CFTypeRefToNSObjectAutorelease(CFTypeRef cf_object); +BASE_API void* CFTypeRefToNSObjectAutorelease(CFTypeRef cf_object); // Returns the base bundle ID, which can be set by SetBaseBundleID but // defaults to a reasonable string. This never returns NULL. BaseBundleID // returns a pointer to static storage that must not be freed. -const char* BaseBundleID(); +BASE_API const char* BaseBundleID(); // Sets the base bundle ID to override the default. The implementation will // make its own copy of new_base_bundle_id. -void SetBaseBundleID(const char* new_base_bundle_id); +BASE_API void SetBaseBundleID(const char* new_base_bundle_id); } // namespace mac } // namespace base @@ -158,8 +161,8 @@ OBJC_CPP_CLASS_DECL(TypeNS) \ \ namespace base { \ namespace mac { \ -TypeNS* CFToNSCast(TypeCF##Ref cf_val); \ -TypeCF##Ref NSToCFCast(TypeNS* ns_val); \ +BASE_API TypeNS* CFToNSCast(TypeCF##Ref cf_val); \ +BASE_API TypeCF##Ref NSToCFCast(TypeNS* ns_val); \ } \ } \ @@ -169,8 +172,8 @@ OBJC_CPP_CLASS_DECL(NSMutable##name) \ \ namespace base { \ namespace mac { \ -NSMutable##name* CFToNSCast(CFMutable##name##Ref cf_val); \ -CFMutable##name##Ref NSToCFCast(NSMutable##name* ns_val); \ +BASE_API NSMutable##name* CFToNSCast(CFMutable##name##Ref cf_val); \ +BASE_API CFMutable##name##Ref NSToCFCast(NSMutable##name* ns_val); \ } \ } \ @@ -200,7 +203,8 @@ CF_TO_NS_CAST_DECL(CFURL, NSURL); // e.g. LOG(INFO) << base::mac::NSToCFCast(@"foo"); // Operator << can not be overloaded for ObjectiveC types as the compiler // can not distinguish between overloads for id with overloads for void*. -extern std::ostream& operator<<(std::ostream& o, const CFErrorRef err); -extern std::ostream& operator<<(std::ostream& o, const CFStringRef str); +BASE_API extern std::ostream& operator<<(std::ostream& o, const CFErrorRef err); +BASE_API extern std::ostream& operator<<(std::ostream& o, + const CFStringRef str); #endif // BASE_MAC_FOUNDATION_UTIL_H_ |