OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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_UTIL_H_ | 5 #ifndef BASE_MAC_UTIL_H_ |
6 #define BASE_MAC_UTIL_H_ | 6 #define BASE_MAC_UTIL_H_ |
7 | 7 |
8 struct FSRef; | 8 #include <Carbon/Carbon.h> |
| 9 #include <string> |
| 10 |
9 class FilePath; | 11 class FilePath; |
10 | 12 |
11 #ifdef __OBJC__ | 13 #ifdef __OBJC__ |
12 @class NSBundle; | 14 @class NSBundle; |
13 #else | 15 #else |
14 class NSBundle; | 16 class NSBundle; |
15 #endif | 17 #endif |
16 | 18 |
17 #include <string> | |
18 | |
19 namespace mac_util { | 19 namespace mac_util { |
20 | 20 |
21 std::string PathFromFSRef(const FSRef& ref); | 21 std::string PathFromFSRef(const FSRef& ref); |
22 bool FSRefFromPath(const std::string& path, FSRef* ref); | 22 bool FSRefFromPath(const std::string& path, FSRef* ref); |
23 | 23 |
24 // Returns true if the application is running from a bundle | 24 // Returns true if the application is running from a bundle |
25 bool AmIBundled(); | 25 bool AmIBundled(); |
26 | 26 |
27 // Returns the main bundle or the override, used for code that needs | 27 // Returns the main bundle or the override, used for code that needs |
28 // to fetch resources from bundles, but work within a unittest where we | 28 // to fetch resources from bundles, but work within a unittest where we |
29 // aren't a bundle. | 29 // aren't a bundle. |
30 NSBundle* MainAppBundle(); | 30 NSBundle* MainAppBundle(); |
31 | 31 |
32 // Returns the ~/Library directory. | |
33 FilePath GetUserLibraryPath(); | |
34 | |
35 // Set the bundle that MainAppBundle will return, overriding the default value | 32 // Set the bundle that MainAppBundle will return, overriding the default value |
36 // (Restore the default by calling SetOverrideAppBundle(nil)). | 33 // (Restore the default by calling SetOverrideAppBundle(nil)). |
37 void SetOverrideAppBundle(NSBundle* bundle); | 34 void SetOverrideAppBundle(NSBundle* bundle); |
38 void SetOverrideAppBundlePath(const FilePath& file_path); | 35 void SetOverrideAppBundlePath(const FilePath& file_path); |
39 | 36 |
| 37 // Returns the creator code associated with the CFBundleRef at bundle. |
| 38 OSType CreatorCodeForCFBundleRef(CFBundleRef bundle); |
| 39 |
| 40 // Returns the creator code associated with this application, by calling |
| 41 // CreatorCodeForCFBundleRef for the application's main bundle. If this |
| 42 // information cannot be determined, returns kUnknownType ('????'). This |
| 43 // does not respect the override app bundle because it's based on CFBundle |
| 44 // instead of NSBundle, and because callers probably don't want the override |
| 45 // app bundle's creator code anyway. |
| 46 OSType CreatorCodeForApplication(); |
| 47 |
| 48 // Returns the ~/Library directory. |
| 49 FilePath GetUserLibraryPath(); |
| 50 |
40 } // namespace mac_util | 51 } // namespace mac_util |
41 | 52 |
42 #endif // BASE_MAC_UTIL_H_ | 53 #endif // BASE_MAC_UTIL_H_ |
OLD | NEW |