mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-03 23:12:42 +00:00
70de3a6d9c
* WinForms/WPF - Dispose of IFrame after calling LoadUrl * BrowserProcess - Add initial implementation of IRenderProcessHandler.OnContextCreated/OnContextReleased - IV8Context.Execute is the only method to be implemented so far (execute script without returning a result) - Wrappers for CefFrame and CefBrowser have yet to be imported yet, still need to determine if they should be included individually or reference to CefSharp.Core added * BrowserProcess - Add wrappers for Browser and Frame Ultimately we should probably remove the CefSharp.BrowserSubprocess.Core project and move all the code into a folder/namespace within CefSharp.Core This would allow us to share the a lot of existing code, major refactor required * CefSharp.Common.props - Add CefSharpBrowserProcessCore32/64 properties Make creating your own custom browser process easier * BrowserProcess - Remove example and add comments about creating your own custom version
85 lines
2.5 KiB
C++
85 lines
2.5 KiB
C++
// Copyright © 2016 The CefSharp Authors. 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;
|
|
using namespace CefSharp::RenderProcess;
|
|
|
|
namespace CefSharp
|
|
{
|
|
namespace BrowserSubprocess
|
|
{
|
|
// Wrap CefAppUnmangedWrapper in a nice managed wrapper
|
|
public ref class SubProcess
|
|
{
|
|
private:
|
|
MCefRefPtr<CefAppUnmanagedWrapper> _cefApp;
|
|
|
|
public:
|
|
SubProcess(IRenderProcessHandler^ handler, IEnumerable<String^>^ args)
|
|
{
|
|
auto onBrowserCreated = gcnew Action<CefBrowserWrapper^>(this, &SubProcess::OnBrowserCreated);
|
|
auto onBrowserDestroyed = gcnew Action<CefBrowserWrapper^>(this, &SubProcess::OnBrowserDestroyed);
|
|
auto schemes = CefCustomScheme::ParseCommandLineArguments(args);
|
|
auto enableFocusedNodeChanged = CommandLineArgsParser::HasArgument(args, CefSharpArguments::FocusedNodeChangedEnabledArgument);
|
|
|
|
_cefApp = new CefAppUnmanagedWrapper(handler, schemes, enableFocusedNodeChanged, onBrowserCreated, onBrowserDestroyed);
|
|
}
|
|
|
|
!SubProcess()
|
|
{
|
|
_cefApp = nullptr;
|
|
}
|
|
|
|
~SubProcess()
|
|
{
|
|
this->!SubProcess();
|
|
}
|
|
|
|
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);
|
|
}
|
|
};
|
|
}
|
|
}
|