2014-12-29 17:35:08 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "atom/app/atom_main_delegate.h"
|
|
|
|
|
|
|
|
#include "base/mac/bundle_locations.h"
|
|
|
|
#include "base/files/file_path.h"
|
2015-04-14 05:51:08 +00:00
|
|
|
#include "base/files/file_util.h"
|
2016-05-18 07:42:26 +00:00
|
|
|
#include "base/mac/foundation_util.h"
|
|
|
|
#include "base/mac/scoped_nsautorelease_pool.h"
|
2014-12-29 17:35:08 +00:00
|
|
|
#include "base/path_service.h"
|
2016-05-19 01:57:57 +00:00
|
|
|
#include "base/strings/sys_string_conversions.h"
|
2015-04-14 05:51:08 +00:00
|
|
|
#include "brightray/common/application_info.h"
|
2014-12-29 17:35:08 +00:00
|
|
|
#include "brightray/common/mac/main_application_bundle.h"
|
|
|
|
#include "content/public/common/content_paths.h"
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
base::FilePath GetFrameworksPath() {
|
|
|
|
return brightray::MainApplicationBundlePath().Append("Contents")
|
|
|
|
.Append("Frameworks");
|
|
|
|
}
|
|
|
|
|
2015-04-17 07:10:48 +00:00
|
|
|
base::FilePath GetHelperAppPath(const base::FilePath& frameworks_path,
|
2015-04-14 05:51:08 +00:00
|
|
|
const std::string& name) {
|
|
|
|
return frameworks_path.Append(name + " Helper.app")
|
|
|
|
.Append("Contents")
|
|
|
|
.Append("MacOS")
|
|
|
|
.Append(name + " Helper");
|
|
|
|
}
|
|
|
|
|
2014-12-29 17:35:08 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void AtomMainDelegate::OverrideFrameworkBundlePath() {
|
|
|
|
base::mac::SetOverrideFrameworkBundlePath(
|
2015-04-14 06:13:03 +00:00
|
|
|
GetFrameworksPath().Append(ATOM_PRODUCT_NAME " Framework.framework"));
|
2014-12-29 17:35:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AtomMainDelegate::OverrideChildProcessPath() {
|
2015-04-14 05:51:08 +00:00
|
|
|
base::FilePath frameworks_path = GetFrameworksPath();
|
2015-04-17 07:10:48 +00:00
|
|
|
base::FilePath helper_path = GetHelperAppPath(frameworks_path,
|
2015-04-14 06:13:03 +00:00
|
|
|
ATOM_PRODUCT_NAME);
|
2015-04-14 05:51:08 +00:00
|
|
|
if (!base::PathExists(helper_path))
|
2015-04-17 07:10:48 +00:00
|
|
|
helper_path = GetHelperAppPath(frameworks_path,
|
2015-04-14 05:51:08 +00:00
|
|
|
brightray::GetApplicationName());
|
|
|
|
if (!base::PathExists(helper_path))
|
|
|
|
LOG(FATAL) << "Unable to find helper app";
|
2014-12-29 17:35:08 +00:00
|
|
|
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
|
|
|
}
|
|
|
|
|
2016-05-18 07:42:26 +00:00
|
|
|
void AtomMainDelegate::SetUpBundleOverrides() {
|
|
|
|
base::mac::ScopedNSAutoreleasePool pool;
|
2016-05-19 01:57:57 +00:00
|
|
|
NSBundle* bundle = brightray::MainApplicationBundle();
|
|
|
|
std::string base_bundle_id =
|
|
|
|
base::SysNSStringToUTF8([bundle bundleIdentifier]);
|
|
|
|
NSString* team_id = [bundle objectForInfoDictionaryKey:@"ElectronTeamID"];
|
|
|
|
if (team_id)
|
|
|
|
base_bundle_id = base::SysNSStringToUTF8(team_id) + "." + base_bundle_id;
|
|
|
|
base::mac::SetBaseBundleID(base_bundle_id.c_str());
|
2016-05-18 07:42:26 +00:00
|
|
|
}
|
|
|
|
|
2014-12-29 17:35:08 +00:00
|
|
|
} // namespace atom
|