summaryrefslogtreecommitdiffstats
path: root/base/mac_util.mm
diff options
context:
space:
mode:
Diffstat (limited to 'base/mac_util.mm')
-rw-r--r--base/mac_util.mm25
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