Check ElectronMainProcess key in Info.plist
This commit is contained in:
parent
77f7cfc938
commit
b81876775e
1 changed files with 13 additions and 2 deletions
|
@ -6,19 +6,30 @@
|
||||||
#import "common/mac/main_application_bundle.h"
|
#import "common/mac/main_application_bundle.h"
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
|
#include "base/mac/bundle_locations.h"
|
||||||
#include "base/mac/foundation_util.h"
|
#include "base/mac/foundation_util.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool HasMainProcessKey() {
|
||||||
|
NSDictionary* info_dictionary = [base::mac::MainBundle() infoDictionary];
|
||||||
|
return [[info_dictionary objectForKey:@"ElectronMainProcess"] boolValue] != NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
base::FilePath MainApplicationBundlePath() {
|
base::FilePath MainApplicationBundlePath() {
|
||||||
// Start out with the path to the running executable.
|
// Start out with the path to the running executable.
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
PathService::Get(base::FILE_EXE, &path);
|
PathService::Get(base::FILE_EXE, &path);
|
||||||
|
|
||||||
// Up to Contents.
|
// Up to Contents.
|
||||||
if (base::EndsWith(path.value(), " Helper", base::CompareCase::SENSITIVE)) {
|
if (!HasMainProcessKey() &&
|
||||||
|
base::EndsWith(path.value(), " Helper", base::CompareCase::SENSITIVE)) {
|
||||||
// The running executable is the helper. Go up five steps:
|
// The running executable is the helper. Go up five steps:
|
||||||
// Contents/Frameworks/Helper.app/Contents/MacOS/Helper
|
// Contents/Frameworks/Helper.app/Contents/MacOS/Helper
|
||||||
// ^ to here ^ from here
|
// ^ to here ^ from here
|
||||||
|
@ -40,4 +51,4 @@ NSBundle* MainApplicationBundle() {
|
||||||
return [NSBundle bundleWithPath:base::mac::FilePathToNSString(MainApplicationBundlePath())];
|
return [NSBundle bundleWithPath:base::mac::FilePathToNSString(MainApplicationBundlePath())];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
Loading…
Reference in a new issue