Chromium Code Reviews| Index: base/mac_util.mm |
| =================================================================== |
| --- base/mac_util.mm (revision 10790) |
| +++ base/mac_util.mm (working copy) |
| @@ -6,8 +6,10 @@ |
| #include <Carbon/Carbon.h> |
| #import <Cocoa/Cocoa.h> |
| - |
| +#include "base/file_path.h" |
|
Mark Mentovai
2009/03/03 16:21:45
Leave the blank line between system and chrome hea
|
| +#include "base/logging.h" |
| #include "base/scoped_cftyperef.h" |
| +#include "base/sys_string_conversions.h" |
| namespace mac_util { |
| @@ -41,4 +43,26 @@ |
| return info.nodeFlags & kFSNodeIsDirectoryMask; |
| } |
| +// No threading worries since NSBundle isn't thread safe. |
| +static NSBundle* g_override_app_bundle = nil; |
| + |
| +NSBundle* MainAppBundle() { |
| + if (g_override_app_bundle) |
| + return g_override_app_bundle; |
| + return [NSBundle mainBundle]; |
| +} |
| + |
| +void SetOverrideAppBundle(NSBundle* bundle) { |
| + [g_override_app_bundle release]; |
| + g_override_app_bundle = [bundle retain]; |
| +} |
| + |
| +void SetOverrideAppBundlePath(const FilePath& file_path) { |
| + NSString* path = base::SysUTF8ToNSString(file_path.value()); |
| + NSBundle* bundle = [NSBundle bundleWithPath:path]; |
| + DCHECK(bundle) << "failed to load the bundle: " << file_path.value(); |
| + |
| + SetOverrideAppBundle(bundle); |
| +} |
| + |
| } // namespace mac_util |