Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(999)

Unified Diff: base/mac_util.mm

Issue 28214: Add a macutil for the main app bundle and override... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac_util.h ('k') | chrome/common/resource_bundle_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/mac_util.h ('k') | chrome/common/resource_bundle_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698