
* Update to Chromium 68.0.3440.128 and Node 10.10.0 * update v8, ffmpeg, chromium, crashpad, boringssl, and webrtc patches * fix SSL_get_tlsext_status_type patch * pass encryption_modes_supported to CdmInfo * kNoSandbox moved into service_manager * bump CHROME_VERSION_STRING TODO: automatically pull in the real chrome version * PathService -> base::PathService * net::X509Certificate::Equals -> net::X509Certificate::EqualsExcludingChain * use content::ChildProcessTerminationInfo * GetHandle() -> GetProcess().Handle() * ScopedNestableTaskAllower doesn't take an argument * net::HttpAuthCache::ClearEntriesAddedWithin -> ClearAllEntries * std::unique_ptr<WebContents> * blink::WebFullscreenOptions * OnAudioStateChanged doesn't take a WebContents * content::RESULT_CODE_NORMAL_EXIT -> service_manager::RESULT_CODE_NORMAL_EXIT * MessageLoopCurrent * WasResized -> SynchronizeVisualProperties * SetTimeStamp takes a base::TimeTicks * ExecuteScriptInIsolatedWorld is single-script only * DispatchNonPersistentCloseEvent takes a callback now * expose URLRequestContextGetter::{Add,Remove}Observer * test: remove no longer existing Chromium test deps cc_blink_unittests has been removed in https://chromium-review.googlesource.com/1053765 mojo_common_unittests has been removed in https://chromium-review.googlesource.com/1028000 * SetFdLimit -> IncreaseFdLimitTo NOTE: the behaviour of this API has changed slightly, and we should mention that in the notes. * MessageLoop::QuitWhenIdleClosure -> RunLoop::QuitCurrentWhenIdleClosureDeprecated * certificate_transparency moved out of net/ pending a clearer decision about what to do with CT in the mean time, copy CreateLogVerifiersForKnownLogs from deleted chromium source * add secure_origin_whitelist to chrome source list NOTE: is this something we actually want? cc @deepak1556 * DrainBackgroundTasks -> DrainTasks * use new node options parser * fix disable_scroll_begin_dcheck.patch * ViewsDelegate::CreateWebContents went away see https://chromium-review.googlesource.com/c/chromium/src/+/1031314 * kZygoteProcess moved into service_manager * test: minor improvements to the Node spec - reformat some parts - better failures reporting with `expect` - skip some tests instead of marking them as passed * chromium removed *_posix.cc from the source filters * test: fix :electron_tests compilation * better crash diagnostics in ffmpeg test * fix: enable back a DCHECK in viz::ServerSharedBitmapManager Fixes #14327. Backports https://chromium-review.googlesource.com/802574. * chore: update linux sysroots * chore: remove obsolete "install-sysroot.py" script * test: fix frame-subscriber test on Mac * disable OSR for now * test: make before-input-event test more robust * test: make run-as-node --inspect test more robust on windows * roll node to v10.11.0 * avoid duplicate files when building a zip * disable failing assert in beginFrameSubscription dirty-rectangle test * experiment with is_cfi = false * fix: build torque with x64 toolchain Co-Authored-By: Alexey Kuzmin <github@alexeykuzmin.com> * test: disable the "app.relaunch" test on Linux * chore: bump node to get header tar file * chore: bump node to fix tar.py line endings
210 lines
6.5 KiB
C++
210 lines
6.5 KiB
C++
// Copyright (c) 2013 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 <iostream>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "atom/app/atom_content_client.h"
|
|
#include "atom/browser/atom_browser_client.h"
|
|
#include "atom/browser/relauncher.h"
|
|
#include "atom/common/google_api_key.h"
|
|
#include "atom/common/options_switches.h"
|
|
#include "atom/renderer/atom_renderer_client.h"
|
|
#include "atom/renderer/atom_sandboxed_renderer_client.h"
|
|
#include "atom/utility/atom_content_utility_client.h"
|
|
#include "base/command_line.h"
|
|
#include "base/debug/stack_trace.h"
|
|
#include "base/environment.h"
|
|
#include "base/logging.h"
|
|
#include "chrome/common/chrome_paths.h"
|
|
#include "content/public/common/content_switches.h"
|
|
#include "ipc/ipc_buildflags.h"
|
|
#include "services/service_manager/sandbox/switches.h"
|
|
#include "ui/base/l10n/l10n_util.h"
|
|
#include "ui/base/resource/resource_bundle.h"
|
|
|
|
#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
|
|
#define IPC_MESSAGE_MACROS_LOG_ENABLED
|
|
#include "content/public/common/content_ipc_logging.h"
|
|
#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
|
|
content::RegisterIPCLogger(msg_id, logger)
|
|
#include "atom/common/common_message_generator.h"
|
|
#endif
|
|
|
|
namespace atom {
|
|
|
|
namespace {
|
|
|
|
const char* kRelauncherProcess = "relauncher";
|
|
|
|
bool IsBrowserProcess(base::CommandLine* cmd) {
|
|
std::string process_type = cmd->GetSwitchValueASCII(::switches::kProcessType);
|
|
return process_type.empty();
|
|
}
|
|
|
|
#if defined(OS_WIN)
|
|
void InvalidParameterHandler(const wchar_t*,
|
|
const wchar_t*,
|
|
const wchar_t*,
|
|
unsigned int,
|
|
uintptr_t) {
|
|
// noop.
|
|
}
|
|
#endif
|
|
|
|
} // namespace
|
|
|
|
AtomMainDelegate::AtomMainDelegate() {}
|
|
|
|
AtomMainDelegate::~AtomMainDelegate() {}
|
|
|
|
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
|
auto* command_line = base::CommandLine::ForCurrentProcess();
|
|
|
|
logging::LoggingSettings settings;
|
|
#if defined(OS_WIN)
|
|
// On Windows the terminal returns immediately, so we add a new line to
|
|
// prevent output in the same line as the prompt.
|
|
if (IsBrowserProcess(command_line))
|
|
std::wcout << std::endl;
|
|
#if defined(DEBUG)
|
|
// Print logging to debug.log on Windows
|
|
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 // defined(DEBUG)
|
|
#else // defined(OS_WIN)
|
|
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
|
#endif // !defined(OS_WIN)
|
|
|
|
// Only enable logging when --enable-logging is specified.
|
|
auto env = base::Environment::Create();
|
|
if (!command_line->HasSwitch(::switches::kEnableLogging) &&
|
|
!env->HasVar("ELECTRON_ENABLE_LOGGING")) {
|
|
settings.logging_dest = logging::LOG_NONE;
|
|
logging::SetMinLogLevel(logging::LOG_NUM_SEVERITIES);
|
|
}
|
|
|
|
logging::InitLogging(settings);
|
|
|
|
// Logging with pid and timestamp.
|
|
logging::SetLogItems(true, false, true, false);
|
|
|
|
// Enable convient stack printing.
|
|
#if defined(DEBUG) && defined(OS_LINUX)
|
|
bool enable_stack_dumping = true;
|
|
#else
|
|
bool enable_stack_dumping = env->HasVar("ELECTRON_ENABLE_STACK_DUMPING");
|
|
#endif
|
|
#if defined(ARCH_CPU_ARM_FAMILY) && defined(ARCH_CPU_32_BITS)
|
|
// For 32bit ARM enabling stack printing would end up crashing.
|
|
// https://github.com/electron/electron/pull/11230#issuecomment-363232482
|
|
enable_stack_dumping = false;
|
|
#endif
|
|
if (enable_stack_dumping)
|
|
base::debug::EnableInProcessStackDumping();
|
|
|
|
chrome::RegisterPathProvider();
|
|
|
|
#if defined(OS_MACOSX)
|
|
SetUpBundleOverrides();
|
|
#endif
|
|
|
|
#if defined(OS_WIN)
|
|
// Ignore invalid parameter errors.
|
|
_set_invalid_parameter_handler(InvalidParameterHandler);
|
|
// Disable the ActiveVerifier, which is used by Chrome to track possible
|
|
// bugs, but no use in Electron.
|
|
base::win::DisableHandleVerifier();
|
|
#endif
|
|
|
|
return brightray::MainDelegate::BasicStartupComplete(exit_code);
|
|
}
|
|
|
|
void AtomMainDelegate::PreSandboxStartup() {
|
|
brightray::MainDelegate::PreSandboxStartup();
|
|
|
|
auto* command_line = base::CommandLine::ForCurrentProcess();
|
|
|
|
// Only append arguments for browser process.
|
|
if (!IsBrowserProcess(command_line))
|
|
return;
|
|
|
|
if (!command_line->HasSwitch(switches::kEnableMixedSandbox)) {
|
|
if (command_line->HasSwitch(switches::kEnableSandbox)) {
|
|
// Disable setuid sandbox since it is not longer required on
|
|
// linux(namespace sandbox is available on most distros).
|
|
command_line->AppendSwitch(
|
|
service_manager::switches::kDisableSetuidSandbox);
|
|
} else {
|
|
// Disable renderer sandbox for most of node's functions.
|
|
command_line->AppendSwitch(service_manager::switches::kNoSandbox);
|
|
}
|
|
}
|
|
|
|
// Allow file:// URIs to read other file:// URIs by default.
|
|
command_line->AppendSwitch(::switches::kAllowFileAccessFromFiles);
|
|
|
|
#if defined(OS_MACOSX)
|
|
// Enable AVFoundation.
|
|
command_line->AppendSwitch("enable-avfoundation");
|
|
#endif
|
|
}
|
|
|
|
content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
|
|
browser_client_.reset(new AtomBrowserClient);
|
|
return browser_client_.get();
|
|
}
|
|
|
|
content::ContentRendererClient*
|
|
AtomMainDelegate::CreateContentRendererClient() {
|
|
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
|
switches::kEnableSandbox) ||
|
|
!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
|
service_manager::switches::kNoSandbox)) {
|
|
renderer_client_.reset(new AtomSandboxedRendererClient);
|
|
} else {
|
|
renderer_client_.reset(new AtomRendererClient);
|
|
}
|
|
|
|
return renderer_client_.get();
|
|
}
|
|
|
|
content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() {
|
|
utility_client_.reset(new AtomContentUtilityClient);
|
|
return utility_client_.get();
|
|
}
|
|
|
|
int AtomMainDelegate::RunProcess(
|
|
const std::string& process_type,
|
|
const content::MainFunctionParams& main_function_params) {
|
|
if (process_type == kRelauncherProcess)
|
|
return relauncher::RelauncherMain(main_function_params);
|
|
else
|
|
return -1;
|
|
}
|
|
|
|
#if defined(OS_MACOSX)
|
|
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::make_unique<AtomContentClient>();
|
|
}
|
|
|
|
} // namespace atom
|