diff options
author | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 16:26:03 +0000 |
---|---|---|
committer | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 16:26:03 +0000 |
commit | 6f33add36219e1faadea9d295b35d43841ebd508 (patch) | |
tree | bc5561b8d3cedeb13e504c971a7992a34e6d2353 /base/mac_util.mm | |
parent | abf6c7a76bc68d0a01c1665e97972b0056654a26 (diff) | |
download | chromium_src-6f33add36219e1faadea9d295b35d43841ebd508.zip chromium_src-6f33add36219e1faadea9d295b35d43841ebd508.tar.gz chromium_src-6f33add36219e1faadea9d295b35d43841ebd508.tar.bz2 |
Add a macutil for the main app bundle and override
- provide apis to get and override the app bundle
- w/in the core code, use this api for fetching the bundle
- render sandbox config
- resource bundles
- test shell font
- w/in the unittest boot straps, use the mac util to override the bundle so resources can be found.
Review URL: http://codereview.chromium.org/28214
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac_util.mm')
-rw-r--r-- | base/mac_util.mm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/base/mac_util.mm b/base/mac_util.mm index 462d165..156cb1c 100644 --- a/base/mac_util.mm +++ b/base/mac_util.mm @@ -7,7 +7,10 @@ #include <Carbon/Carbon.h> #import <Cocoa/Cocoa.h> +#include "base/file_path.h" +#include "base/logging.h" #include "base/scoped_cftyperef.h" +#include "base/sys_string_conversions.h" namespace mac_util { @@ -41,4 +44,26 @@ bool AmIBundled() { 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 |