fixes linendings

This commit is contained in:
gellert 2016-08-02 19:31:30 +02:00
parent 362f3deb93
commit 1663a9cd13
2 changed files with 234 additions and 234 deletions

View file

@ -1,177 +1,177 @@
// Copyright (c) 2013 GitHub, Inc. // Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "atom/app/atom_main_delegate.h" #include "atom/app/atom_main_delegate.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "atom/app/atom_content_client.h" #include "atom/app/atom_content_client.h"
#include "atom/browser/atom_browser_client.h" #include "atom/browser/atom_browser_client.h"
#include "atom/browser/relauncher.h" #include "atom/browser/relauncher.h"
#include "atom/common/google_api_key.h" #include "atom/common/google_api_key.h"
#include "atom/renderer/atom_renderer_client.h" #include "atom/renderer/atom_renderer_client.h"
#include "atom/utility/atom_content_utility_client.h" #include "atom/utility/atom_content_utility_client.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/stack_trace.h" #include "base/debug/stack_trace.h"
#include "base/environment.h" #include "base/environment.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
namespace atom { namespace atom {
namespace { namespace {
const char* kRelauncherProcess = "relauncher"; const char* kRelauncherProcess = "relauncher";
bool IsBrowserProcess(base::CommandLine* cmd) { bool IsBrowserProcess(base::CommandLine* cmd) {
std::string process_type = cmd->GetSwitchValueASCII(switches::kProcessType); std::string process_type = cmd->GetSwitchValueASCII(switches::kProcessType);
return process_type.empty(); return process_type.empty();
} }
#if defined(OS_WIN) #if defined(OS_WIN)
void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*, void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*,
unsigned int, uintptr_t) { unsigned int, uintptr_t) {
// noop. // noop.
} }
#endif #endif
} // namespace } // namespace
AtomMainDelegate::AtomMainDelegate() { AtomMainDelegate::AtomMainDelegate() {
} }
AtomMainDelegate::~AtomMainDelegate() { AtomMainDelegate::~AtomMainDelegate() {
} }
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
auto command_line = base::CommandLine::ForCurrentProcess(); auto command_line = base::CommandLine::ForCurrentProcess();
logging::LoggingSettings settings; logging::LoggingSettings settings;
#if defined(OS_WIN) #if defined(OS_WIN)
// On Windows the terminal returns immediately, so we add a new line to // On Windows the terminal returns immediately, so we add a new line to
// prevent output in the same line as the prompt. // prevent output in the same line as the prompt.
if (IsBrowserProcess(command_line)) if (IsBrowserProcess(command_line))
std::wcout << std::endl; std::wcout << std::endl;
#if defined(DEBUG) #if defined(DEBUG)
// Print logging to debug.log on Windows // Print logging to debug.log on Windows
settings.logging_dest = logging::LOG_TO_ALL; settings.logging_dest = logging::LOG_TO_ALL;
settings.log_file = L"debug.log"; settings.log_file = L"debug.log";
settings.lock_log = logging::LOCK_LOG_FILE; settings.lock_log = logging::LOCK_LOG_FILE;
settings.delete_old = logging::DELETE_OLD_LOG_FILE; settings.delete_old = logging::DELETE_OLD_LOG_FILE;
#else #else
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
#endif // defined(DEBUG) #endif // defined(DEBUG)
#else // defined(OS_WIN) #else // defined(OS_WIN)
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
#endif // !defined(OS_WIN) #endif // !defined(OS_WIN)
// Only enable logging when --enable-logging is specified. // Only enable logging when --enable-logging is specified.
std::unique_ptr<base::Environment> env(base::Environment::Create()); std::unique_ptr<base::Environment> env(base::Environment::Create());
if (!command_line->HasSwitch(switches::kEnableLogging) && if (!command_line->HasSwitch(switches::kEnableLogging) &&
!env->HasVar("ELECTRON_ENABLE_LOGGING")) { !env->HasVar("ELECTRON_ENABLE_LOGGING")) {
settings.logging_dest = logging::LOG_NONE; settings.logging_dest = logging::LOG_NONE;
logging::SetMinLogLevel(logging::LOG_NUM_SEVERITIES); logging::SetMinLogLevel(logging::LOG_NUM_SEVERITIES);
} }
logging::InitLogging(settings); logging::InitLogging(settings);
// Logging with pid and timestamp. // Logging with pid and timestamp.
logging::SetLogItems(true, false, true, false); logging::SetLogItems(true, false, true, false);
// Enable convient stack printing. // Enable convient stack printing.
bool enable_stack_dumping = env->HasVar("ELECTRON_ENABLE_STACK_DUMPING"); bool enable_stack_dumping = env->HasVar("ELECTRON_ENABLE_STACK_DUMPING");
#if defined(DEBUG) && defined(OS_LINUX) #if defined(DEBUG) && defined(OS_LINUX)
enable_stack_dumping = true; enable_stack_dumping = true;
#endif #endif
if (enable_stack_dumping) if (enable_stack_dumping)
base::debug::EnableInProcessStackDumping(); base::debug::EnableInProcessStackDumping();
chrome::RegisterPathProvider(); chrome::RegisterPathProvider();
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
SetUpBundleOverrides(); SetUpBundleOverrides();
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
// Ignore invalid parameter errors. // Ignore invalid parameter errors.
_set_invalid_parameter_handler(InvalidParameterHandler); _set_invalid_parameter_handler(InvalidParameterHandler);
#endif #endif
return brightray::MainDelegate::BasicStartupComplete(exit_code); return brightray::MainDelegate::BasicStartupComplete(exit_code);
} }
void AtomMainDelegate::PreSandboxStartup() { void AtomMainDelegate::PreSandboxStartup() {
brightray::MainDelegate::PreSandboxStartup(); brightray::MainDelegate::PreSandboxStartup();
// Set google API key. // Set google API key.
std::unique_ptr<base::Environment> env(base::Environment::Create()); std::unique_ptr<base::Environment> env(base::Environment::Create());
if (!env->HasVar("GOOGLE_API_KEY")) if (!env->HasVar("GOOGLE_API_KEY"))
env->SetVar("GOOGLE_API_KEY", GOOGLEAPIS_API_KEY); env->SetVar("GOOGLE_API_KEY", GOOGLEAPIS_API_KEY);
auto command_line = base::CommandLine::ForCurrentProcess(); auto command_line = base::CommandLine::ForCurrentProcess();
std::string process_type = command_line->GetSwitchValueASCII( std::string process_type = command_line->GetSwitchValueASCII(
switches::kProcessType); switches::kProcessType);
// Only append arguments for browser process. // Only append arguments for browser process.
if (!IsBrowserProcess(command_line)) if (!IsBrowserProcess(command_line))
return; return;
// Disable renderer sandbox for most of node's functions. // Disable renderer sandbox for most of node's functions.
command_line->AppendSwitch(switches::kNoSandbox); command_line->AppendSwitch(switches::kNoSandbox);
// Allow file:// URIs to read other file:// URIs by default. // Allow file:// URIs to read other file:// URIs by default.
command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Enable AVFoundation. // Enable AVFoundation.
command_line->AppendSwitch("enable-avfoundation"); command_line->AppendSwitch("enable-avfoundation");
#endif #endif
} }
content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() { content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
browser_client_.reset(new AtomBrowserClient); browser_client_.reset(new AtomBrowserClient);
return browser_client_.get(); return browser_client_.get();
} }
content::ContentRendererClient* content::ContentRendererClient*
AtomMainDelegate::CreateContentRendererClient() { AtomMainDelegate::CreateContentRendererClient() {
renderer_client_.reset(new AtomRendererClient); renderer_client_.reset(new AtomRendererClient);
return renderer_client_.get(); return renderer_client_.get();
} }
content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() { content::ContentUtilityClient* AtomMainDelegate::CreateContentUtilityClient() {
utility_client_.reset(new AtomContentUtilityClient); utility_client_.reset(new AtomContentUtilityClient);
return utility_client_.get(); return utility_client_.get();
} }
int AtomMainDelegate::RunProcess( int AtomMainDelegate::RunProcess(
const std::string& process_type, const std::string& process_type,
const content::MainFunctionParams& main_function_params) { const content::MainFunctionParams& main_function_params) {
if (process_type == kRelauncherProcess) if (process_type == kRelauncherProcess)
return relauncher::RelauncherMain(main_function_params); return relauncher::RelauncherMain(main_function_params);
else else
return -1; return -1;
} }
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
bool AtomMainDelegate::ShouldSendMachPort(const std::string& process_type) { bool AtomMainDelegate::ShouldSendMachPort(const std::string& process_type) {
return process_type != kRelauncherProcess; return process_type != kRelauncherProcess;
} }
bool AtomMainDelegate::DelaySandboxInitialization( bool AtomMainDelegate::DelaySandboxInitialization(
const std::string& process_type) { const std::string& process_type) {
return process_type == kRelauncherProcess; return process_type == kRelauncherProcess;
} }
#endif #endif
std::unique_ptr<brightray::ContentClient> std::unique_ptr<brightray::ContentClient>
AtomMainDelegate::CreateContentClient() { AtomMainDelegate::CreateContentClient() {
return std::unique_ptr<brightray::ContentClient>(new AtomContentClient); return std::unique_ptr<brightray::ContentClient>(new AtomContentClient);
} }
} // namespace atom } // namespace atom

View file

@ -1,57 +1,57 @@
// Copyright (c) 2013 GitHub, Inc. // Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATOM_APP_ATOM_MAIN_DELEGATE_H_ #ifndef ATOM_APP_ATOM_MAIN_DELEGATE_H_
#define ATOM_APP_ATOM_MAIN_DELEGATE_H_ #define ATOM_APP_ATOM_MAIN_DELEGATE_H_
#include <string> #include <string>
#include "brightray/common/main_delegate.h" #include "brightray/common/main_delegate.h"
#include "brightray/common/content_client.h" #include "brightray/common/content_client.h"
namespace atom { namespace atom {
class AtomMainDelegate : public brightray::MainDelegate { class AtomMainDelegate : public brightray::MainDelegate {
public: public:
AtomMainDelegate(); AtomMainDelegate();
~AtomMainDelegate(); ~AtomMainDelegate();
protected: protected:
// content::ContentMainDelegate: // content::ContentMainDelegate:
bool BasicStartupComplete(int* exit_code) override; bool BasicStartupComplete(int* exit_code) override;
void PreSandboxStartup() override; void PreSandboxStartup() override;
content::ContentBrowserClient* CreateContentBrowserClient() override; content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentRendererClient* CreateContentRendererClient() override; content::ContentRendererClient* CreateContentRendererClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override; content::ContentUtilityClient* CreateContentUtilityClient() override;
int RunProcess( int RunProcess(
const std::string& process_type, const std::string& process_type,
const content::MainFunctionParams& main_function_params) override; const content::MainFunctionParams& main_function_params) override;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
bool ShouldSendMachPort(const std::string& process_type) override; bool ShouldSendMachPort(const std::string& process_type) override;
bool DelaySandboxInitialization(const std::string& process_type) override; bool DelaySandboxInitialization(const std::string& process_type) override;
#endif #endif
// brightray::MainDelegate: // brightray::MainDelegate:
std::unique_ptr<brightray::ContentClient> CreateContentClient() override; std::unique_ptr<brightray::ContentClient> CreateContentClient() override;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
void OverrideChildProcessPath() override; void OverrideChildProcessPath() override;
void OverrideFrameworkBundlePath() override; void OverrideFrameworkBundlePath() override;
#endif #endif
private: private:
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
void SetUpBundleOverrides(); void SetUpBundleOverrides();
#endif #endif
brightray::ContentClient content_client_; brightray::ContentClient content_client_;
std::unique_ptr<content::ContentBrowserClient> browser_client_; std::unique_ptr<content::ContentBrowserClient> browser_client_;
std::unique_ptr<content::ContentRendererClient> renderer_client_; std::unique_ptr<content::ContentRendererClient> renderer_client_;
std::unique_ptr<content::ContentUtilityClient> utility_client_; std::unique_ptr<content::ContentUtilityClient> utility_client_;
DISALLOW_COPY_AND_ASSIGN(AtomMainDelegate); DISALLOW_COPY_AND_ASSIGN(AtomMainDelegate);
}; };
} // namespace atom } // namespace atom
#endif // ATOM_APP_ATOM_MAIN_DELEGATE_H_ #endif // ATOM_APP_ATOM_MAIN_DELEGATE_H_