electron/brightray/browser/browser_main_parts_mac.mm

38 lines
1.3 KiB
Text
Raw Normal View History

#import "brightray/browser/browser_main_parts.h"
2013-03-13 19:12:05 +00:00
2018-04-20 18:47:04 +00:00
#import <AppKit/AppKit.h>
#import "base/logging.h"
2013-03-13 19:12:05 +00:00
#import "base/mac/bundle_locations.h"
namespace brightray {
void BrowserMainParts::OverrideAppLogsPath() {
base::FilePath path;
2018-04-20 18:47:04 +00:00
NSString* bundleName =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
NSString* logsPath =
[NSString stringWithFormat:@"Library/Logs/%@", bundleName];
NSString* libraryPath =
[NSHomeDirectory() stringByAppendingPathComponent:logsPath];
2018-09-15 00:09:42 +00:00
base::PathService::Override(DIR_APP_LOGS,
base::FilePath([libraryPath UTF8String]));
}
2013-03-13 19:12:05 +00:00
// Replicates NSApplicationMain, but doesn't start a run loop.
void BrowserMainParts::InitializeMainNib() {
2013-03-13 19:12:05 +00:00
auto infoDictionary = base::mac::OuterBundle().infoDictionary;
2018-04-20 18:47:04 +00:00
auto principalClass =
NSClassFromString([infoDictionary objectForKey:@"NSPrincipalClass"]);
2013-03-13 19:12:05 +00:00
auto application = [principalClass sharedApplication];
2018-04-20 18:47:04 +00:00
NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
auto mainNib = [[NSNib alloc] initWithNibNamed:mainNibName
bundle:base::mac::FrameworkBundle()];
[mainNib instantiateWithOwner:application topLevelObjects:nil];
2013-03-13 19:12:05 +00:00
[mainNib release];
}
} // namespace brightray