electron/app/atom_main_delegate.cc

97 lines
2.9 KiB
C++
Raw Normal View History

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"
#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"
#include "ui/base/resource/resource_bundle.h"
#include "base/path_service.h"
2013-04-12 01:46:58 +00:00
namespace atom {
AtomMainDelegate::AtomMainDelegate() {
}
AtomMainDelegate::~AtomMainDelegate() {
}
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
// Disable logging out to debug.log on Windows
#if defined(OS_WIN)
logging::LoggingSettings settings;
#if defined(DEBUG)
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;
#else
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
#endif
settings.dcheck_state =
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
logging::InitLogging(settings);
#endif // defined(OS_WIN)
2013-12-23 14:04:49 +00:00
// Logging with pid and timestamp.
logging::SetLogItems(true, false, true, false);
return brightray::MainDelegate::BasicStartupComplete(exit_code);
}
2013-04-20 03:19:25 +00:00
void AtomMainDelegate::PreSandboxStartup() {
#if defined(OS_MACOSX)
OverrideChildProcessPath();
OverrideFrameworkBundlePath();
#endif
InitializeResourceBundle();
2013-04-20 03:19:25 +00:00
CommandLine* command_line = CommandLine::ForCurrentProcess();
std::string process_type = command_line->GetSwitchValueASCII(
switches::kProcessType);
// Don't append arguments for renderer process.
if (process_type == switches::kRendererProcess)
return;
// Disable renderer sandbox for most of node's functions.
2013-04-20 03:19:25 +00:00
command_line->AppendSwitch(switches::kNoSandbox);
// Disable accelerated compositing since it caused a lot of troubles (black
// devtools, screen flashes) and needed lots of effort to make it right.
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
// Add a flag to mark the end of switches added by atom-shell.
command_line->AppendSwitch("no-more-atom-shell-switches");
2013-04-20 03:19:25 +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