mac: Makes sure MainMenu.nib is alwasys loaded from Atom.framework.

This commit is contained in:
Cheng Zhao 2013-09-12 17:16:33 +08:00
parent 8cb624d828
commit ef92cd8b45

View file

@ -4,9 +4,11 @@
#include "browser/atom_browser_main_parts.h"
#import "base/mac/bundle_locations.h"
#include "base/files/file_path.h"
#import "base/mac/foundation_util.h"
#import "browser/atom_application_mac.h"
#import "browser/atom_application_delegate_mac.h"
#import "vendor/brightray/common/mac/main_application_bundle.h"
namespace atom {
@ -17,10 +19,12 @@ void AtomBrowserMainParts::PreMainMessageLoopStart() {
AtomApplicationDelegate* delegate = [AtomApplicationDelegate alloc];
[NSApp setDelegate:delegate];
auto infoDictionary = base::mac::OuterBundle().infoDictionary;
NSString *mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
auto mainNib = [[NSNib alloc] initWithNibNamed:mainNibName bundle:base::mac::FrameworkBundle()];
base::FilePath frameworkPath = brightray::MainApplicationBundlePath()
.Append("Contents").Append("Frameworks").Append("Atom.framework");
NSBundle* frameworkBundle = [NSBundle
bundleWithPath:base::mac::FilePathToNSString(frameworkPath)];
NSNib* mainNib = [[NSNib alloc] initWithNibNamed:@"MainMenu"
bundle:frameworkBundle];
[mainNib instantiateWithOwner:application topLevelObjects:nil];
[mainNib release];