Implement app.relaunch on OS X

This commit is contained in:
Cheng Zhao 2016-06-01 18:22:14 +09:00
parent 7b3ba739bf
commit abdcb9d481
6 changed files with 54 additions and 17 deletions

View file

@ -21,10 +21,18 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#if defined(OS_MACOSX)
#include "chrome/browser/mac/relauncher.h"
#endif
namespace atom {
namespace {
#if defined(OS_MACOSX)
const char* kRelauncherProcess = "relauncher";
#endif
bool IsBrowserProcess(base::CommandLine* cmd) {
std::string process_type = cmd->GetSwitchValueASCII(switches::kProcessType);
return process_type.empty();
@ -146,6 +154,26 @@ content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() {
return utility_client_.get();
}
#if defined(OS_MACOSX)
int AtomMainDelegate::RunProcess(
const std::string& process_type,
const content::MainFunctionParams& main_function_params) {
if (process_type == kRelauncherProcess)
return mac_relauncher::internal::RelauncherMain(main_function_params);
else
return -1;
}
bool AtomMainDelegate::ShouldSendMachPort(const std::string& process_type) {
return process_type != kRelauncherProcess;
}
bool AtomMainDelegate::DelaySandboxInitialization(
const std::string& process_type) {
return process_type == kRelauncherProcess;
}
#endif
std::unique_ptr<brightray::ContentClient>
AtomMainDelegate::CreateContentClient() {
return std::unique_ptr<brightray::ContentClient>(new AtomContentClient);

View file

@ -5,6 +5,8 @@
#ifndef ATOM_APP_ATOM_MAIN_DELEGATE_H_
#define ATOM_APP_ATOM_MAIN_DELEGATE_H_
#include <string>
#include "brightray/common/main_delegate.h"
#include "brightray/common/content_client.h"
@ -22,6 +24,13 @@ class AtomMainDelegate : public brightray::MainDelegate {
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override;
#if defined(OS_MACOSX)
int RunProcess(
const std::string& process_type,
const content::MainFunctionParams& main_function_params) override;
bool ShouldSendMachPort(const std::string& process_type) override;
bool DelaySandboxInitialization(const std::string& process_type) override;
#endif
// brightray::MainDelegate:
std::unique_ptr<brightray::ContentClient> CreateContentClient() override;