2013-04-12 01:46:58 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "app/atom_main_delegate.h"
|
|
|
|
|
2013-04-20 03:19:25 +00:00
|
|
|
#include "base/command_line.h"
|
2014-02-19 11:07:52 +00:00
|
|
|
#include "base/debug/stack_trace.h"
|
2013-07-08 03:09:53 +00:00
|
|
|
#include "base/logging.h"
|
2013-04-12 01:46:58 +00:00
|
|
|
#include "browser/atom_browser_client.h"
|
2013-04-20 03:19:25 +00:00
|
|
|
#include "content/public/common/content_switches.h"
|
2013-04-12 01:46:58 +00:00
|
|
|
#include "renderer/atom_renderer_client.h"
|
2013-09-12 09:51:45 +00:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
2013-09-17 18:53:31 +00:00
|
|
|
#include "base/path_service.h"
|
2013-09-12 07:42:36 +00:00
|
|
|
|
2013-04-12 01:46:58 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
AtomMainDelegate::AtomMainDelegate() {
|
|
|
|
}
|
|
|
|
|
|
|
|
AtomMainDelegate::~AtomMainDelegate() {
|
|
|
|
}
|
|
|
|
|
2013-07-08 03:09:53 +00:00
|
|
|
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
|
|
|
// Disable logging out to debug.log on Windows
|
|
|
|
#if defined(OS_WIN)
|
2013-12-17 06:01:40 +00:00
|
|
|
logging::LoggingSettings settings;
|
2013-07-23 08:37:00 +00:00
|
|
|
#if defined(DEBUG)
|
2013-12-17 06:01:40 +00:00
|
|
|
settings.logging_dest = logging::LOG_TO_ALL;
|
|
|
|
settings.log_file = L"debug.log";
|
|
|
|
settings.lock_log = logging::LOCK_LOG_FILE;
|
|
|
|
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
|
2013-07-23 08:37:00 +00:00
|
|
|
#else
|
2013-12-17 06:01:40 +00:00
|
|
|
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
|
|
|
#endif
|
|
|
|
settings.dcheck_state =
|
|
|
|
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
|
|
|
|
logging::InitLogging(settings);
|
2013-07-23 08:37:00 +00:00
|
|
|
#endif // defined(OS_WIN)
|
2013-07-08 03:09:53 +00:00
|
|
|
|
2013-12-23 14:04:49 +00:00
|
|
|
// Logging with pid and timestamp.
|
|
|
|
logging::SetLogItems(true, false, true, false);
|
|
|
|
|
2014-02-19 11:07:52 +00:00
|
|
|
// Enable convient stack printing.
|
2014-02-25 10:47:11 +00:00
|
|
|
#if defined(DEBUG) && defined(OS_LINUX)
|
2014-02-19 11:07:52 +00:00
|
|
|
base::debug::EnableInProcessStackDumping();
|
|
|
|
#endif
|
|
|
|
|
2013-07-08 03:09:53 +00:00
|
|
|
return brightray::MainDelegate::BasicStartupComplete(exit_code);
|
|
|
|
}
|
|
|
|
|
2013-04-20 03:19:25 +00:00
|
|
|
void AtomMainDelegate::PreSandboxStartup() {
|
2013-09-12 07:42:36 +00:00
|
|
|
#if defined(OS_MACOSX)
|
2013-09-12 09:51:45 +00:00
|
|
|
OverrideChildProcessPath();
|
|
|
|
OverrideFrameworkBundlePath();
|
|
|
|
#endif
|
|
|
|
InitializeResourceBundle();
|
2013-09-12 07:42:36 +00:00
|
|
|
|
2013-04-20 03:19:25 +00:00
|
|
|
CommandLine* command_line = CommandLine::ForCurrentProcess();
|
2014-01-30 13:06:56 +00:00
|
|
|
std::string process_type = command_line->GetSwitchValueASCII(
|
|
|
|
switches::kProcessType);
|
|
|
|
|
2014-02-20 17:04:27 +00:00
|
|
|
// Only append arguments for browser process.
|
|
|
|
if (!process_type.empty())
|
2014-01-30 13:06:56 +00:00
|
|
|
return;
|
2013-12-12 16:57:08 +00:00
|
|
|
|
2014-01-31 08:40:20 +00:00
|
|
|
// Add a flag to mark the start of switches added by atom-shell.
|
|
|
|
command_line->AppendSwitch("atom-shell-switches-start");
|
|
|
|
|
2013-12-12 16:57:08 +00:00
|
|
|
// Disable renderer sandbox for most of node's functions.
|
2013-04-20 03:19:25 +00:00
|
|
|
command_line->AppendSwitch(switches::kNoSandbox);
|
2013-12-12 16:57:08 +00:00
|
|
|
|
2013-12-15 06:20:28 +00:00
|
|
|
// Add a flag to mark the end of switches added by atom-shell.
|
2014-01-31 08:40:20 +00:00
|
|
|
command_line->AppendSwitch("atom-shell-switches-end");
|
2013-04-20 03:19:25 +00:00
|
|
|
}
|
|
|
|
|
2013-09-12 09:51:45 +00:00
|
|
|
void AtomMainDelegate::InitializeResourceBundle() {
|
|
|
|
base::FilePath path;
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
path = GetResourcesPakFilePath();
|
|
|
|
#else
|
|
|
|
base::FilePath pak_dir;
|
|
|
|
PathService::Get(base::DIR_MODULE, &pak_dir);
|
|
|
|
path = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ui::ResourceBundle::InitSharedInstanceWithPakPath(path);
|
|
|
|
}
|
|
|
|
|
2013-04-12 01:46:58 +00:00
|
|
|
content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
|
|
|
|
browser_client_.reset(new AtomBrowserClient);
|
|
|
|
return browser_client_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
content::ContentRendererClient*
|
|
|
|
AtomMainDelegate::CreateContentRendererClient() {
|
|
|
|
renderer_client_.reset(new AtomRendererClient);
|
|
|
|
return renderer_client_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace atom
|