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