mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
Add OnContextInitialized delegate (Simple .Net Action that is called after the context has been initialized)
This commit is contained in:
+6
-1
@@ -62,6 +62,11 @@ namespace CefSharp
|
||||
}
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Called on the browser process UI thread immediately after the CEF context has been initialized.
|
||||
/// </summary>
|
||||
static property Action^ OnContextInitialized;
|
||||
|
||||
static void AddDisposable(IDisposable^ item)
|
||||
{
|
||||
msclr::lock l(_sync);
|
||||
@@ -161,7 +166,7 @@ namespace CefSharp
|
||||
}
|
||||
|
||||
CefMainArgs main_args;
|
||||
CefRefPtr<CefSharpApp> app(new CefSharpApp(cefSettings));
|
||||
CefRefPtr<CefSharpApp> app(new CefSharpApp(cefSettings, OnContextInitialized));
|
||||
|
||||
success = CefInitialize(main_args, *(cefSettings->_cefSettings), app.get(), NULL);
|
||||
app->CompleteSchemeRegistrations();
|
||||
|
||||
@@ -11,19 +11,36 @@
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
class CefSharpApp : public CefApp
|
||||
private class CefSharpApp : public CefApp,
|
||||
public CefBrowserProcessHandler
|
||||
{
|
||||
gcroot<CefSettings^> _cefSettings;
|
||||
gcroot<Action^> _onContextInitialized;
|
||||
|
||||
public:
|
||||
CefSharpApp(CefSettings^ cefSettings) :
|
||||
_cefSettings(cefSettings)
|
||||
CefSharpApp(CefSettings^ cefSettings, Action^ onContextInitialized) :
|
||||
_cefSettings(cefSettings),
|
||||
_onContextInitialized(onContextInitialized)
|
||||
{
|
||||
}
|
||||
|
||||
~CefSharpApp()
|
||||
{
|
||||
_cefSettings = nullptr;
|
||||
_onContextInitialized = nullptr;
|
||||
}
|
||||
|
||||
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() OVERRIDE
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
virtual void OnContextInitialized() OVERRIDE
|
||||
{
|
||||
if (static_cast<Action^>(_onContextInitialized) != nullptr)
|
||||
{
|
||||
_onContextInitialized->Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line) OVERRIDE
|
||||
|
||||
Reference in New Issue
Block a user