Files
cefsharp/CefSharp.BrowserSubprocess.Core/CefSubProcess.h
T
amaitland 7bbcf162f9 Remove CefSubProcess.cpp - having such trivial cpp files seems silly
Convert CefRenderProcess into a cpp class - this should theoretically allow users to add CefSharp.BrowserSubprocess.Core as a reference then use their own process to spawn it
Move CefRenderProcess and CefSubProcess into CefSharp.BrowserSubprocess namespace - otherclasses should really be moved as well

Only use our custom subProcess when type is render, for gpu and plugin processes the standard implementation is just fine

Remove CefSubProcess
Rename CefAppWrapper to CefSubProcess
2016-05-16 19:46:30 +10:00

84 lines
2.0 KiB
C++

// Copyright © 2010-2016 The CefSharp Project. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "Stdafx.h"
#include "include/cef_app.h"
#include "include/cef_base.h"
#include "CefBrowserWrapper.h"
#include "CefAppUnmanagedWrapper.h"
using namespace System::Collections::Generic;
using namespace System::Linq;
using namespace CefSharp::Internals;
namespace CefSharp
{
namespace BrowserSubprocess
{
// Wrap CefAppUnmangedWrapper in a nice managed wrapper
public ref class CefSubProcess
{
private:
MCefRefPtr<CefAppUnmanagedWrapper> _cefApp;
public:
CefSubProcess(IEnumerable<String^>^ args)
{
auto onBrowserCreated = gcnew Action<CefBrowserWrapper^>(this, &CefSubProcess::OnBrowserCreated);
auto onBrowserDestroyed = gcnew Action<CefBrowserWrapper^>(this, &CefSubProcess::OnBrowserDestroyed);
auto schemes = CefCustomScheme::ParseCommandLineArguments(args);
auto enableFocusedNodeChanged = CommandLineArgsParser::HasArgument(args, CefSharpArguments::FocusedNodeChangedEnabledArgument);
_cefApp = new CefAppUnmanagedWrapper(schemes, enableFocusedNodeChanged, onBrowserCreated, onBrowserDestroyed);
}
!CefSubProcess()
{
_cefApp = nullptr;
}
~CefSubProcess()
{
this->!CefSubProcess();
}
int Run()
{
auto hInstance = Process::GetCurrentProcess()->Handle;
CefMainArgs cefMainArgs((HINSTANCE)hInstance.ToPointer());
return CefExecuteProcess(cefMainArgs, (CefApp*)_cefApp.get(), NULL);
}
virtual void OnBrowserCreated(CefBrowserWrapper^ cefBrowserWrapper)
{
}
virtual void OnBrowserDestroyed(CefBrowserWrapper^ cefBrowserWrapper)
{
}
static void EnableHighDPISupport()
{
CefEnableHighDPISupport();
}
static int ExecuteProcess()
{
auto hInstance = Process::GetCurrentProcess()->Handle;
CefMainArgs cefMainArgs((HINSTANCE)hInstance.ToPointer());
return CefExecuteProcess(cefMainArgs, NULL, NULL);
}
};
}
}