electron/atom/app/atom_main_delegate.cc

96 lines
2.8 KiB
C++
Raw Normal View History

2013-04-12 01:46:58 +00:00
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
2014-04-25 09:49:37 +00:00
// Use of this source code is governed by the MIT license that can be
2013-04-12 01:46:58 +00:00
// found in the LICENSE file.
2014-03-16 00:30:26 +00:00
#include "atom/app/atom_main_delegate.h"
2013-04-12 01:46:58 +00:00
#include <string>
#include "atom/browser/atom_browser_client.h"
#include "atom/renderer/atom_renderer_client.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"
#include "base/logging.h"
2013-04-20 03:19:25 +00:00
#include "content/public/common/content_switches.h"
2014-07-16 07:05:02 +00:00
#include "ui/base/resource/resource_bundle.h"
2013-04-12 01:46:58 +00:00
namespace atom {
AtomMainDelegate::AtomMainDelegate() {
}
AtomMainDelegate::~AtomMainDelegate() {
}
2014-07-16 07:05:02 +00:00
void AtomMainDelegate::AddDataPackFromPath(
ui::ResourceBundle* bundle, const base::FilePath& pak_dir) {
2014-07-16 07:49:40 +00:00
#if defined(OS_WIN)
2014-07-16 07:05:02 +00:00
bundle->AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("ui_resources_200_percent.pak")),
ui::SCALE_FACTOR_200P);
bundle->AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("webkit_resources_200_percent.pak")),
ui::SCALE_FACTOR_200P);
2014-07-16 07:49:40 +00:00
#endif
2014-07-16 07:05:02 +00:00
}
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
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);
2014-02-19 11:07:52 +00:00
// Enable convient stack printing.
#if defined(DEBUG) && defined(OS_LINUX)
2014-02-19 11:07:52 +00:00
base::debug::EnableInProcessStackDumping();
#endif
2014-07-09 09:15:28 +00:00
return brightray::MainDelegate::BasicStartupComplete(exit_code);
}
2013-04-20 03:19:25 +00:00
void AtomMainDelegate::PreSandboxStartup() {
2014-07-09 09:15:28 +00:00
brightray::MainDelegate::PreSandboxStartup();
2013-04-20 03:19:25 +00:00
CommandLine* command_line = CommandLine::ForCurrentProcess();
std::string process_type = command_line->GetSwitchValueASCII(
switches::kProcessType);
// Only append arguments for browser process.
if (!process_type.empty())
return;
// Add a flag to mark the start of switches added by atom-shell.
command_line->AppendSwitch("atom-shell-switches-start");
// Disable renderer sandbox for most of node's functions.
2013-04-20 03:19:25 +00:00
command_line->AppendSwitch(switches::kNoSandbox);
// Add a flag to mark the end of switches added by atom-shell.
command_line->AppendSwitch("atom-shell-switches-end");
2013-04-20 03:19:25 +00:00
}
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