diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h
index 23ecd81e7..38266e340 100644
--- a/CefSharp.Core/Cef.h
+++ b/CefSharp.Core/Cef.h
@@ -62,6 +62,11 @@ namespace CefSharp
}
public:
+ ///
+ /// Called on the browser process UI thread immediately after the CEF context has been initialized.
+ ///
+ static property Action^ OnContextInitialized;
+
static void AddDisposable(IDisposable^ item)
{
msclr::lock l(_sync);
@@ -161,7 +166,7 @@ namespace CefSharp
}
CefMainArgs main_args;
- CefRefPtr app(new CefSharpApp(cefSettings));
+ CefRefPtr app(new CefSharpApp(cefSettings, OnContextInitialized));
success = CefInitialize(main_args, *(cefSettings->_cefSettings), app.get(), NULL);
app->CompleteSchemeRegistrations();
diff --git a/CefSharp.Core/Internals/CefSharpApp.h b/CefSharp.Core/Internals/CefSharpApp.h
index 1237a1941..52ae1409a 100644
--- a/CefSharp.Core/Internals/CefSharpApp.h
+++ b/CefSharp.Core/Internals/CefSharpApp.h
@@ -11,19 +11,36 @@
namespace CefSharp
{
- class CefSharpApp : public CefApp
+ private class CefSharpApp : public CefApp,
+ public CefBrowserProcessHandler
{
gcroot _cefSettings;
+ gcroot _onContextInitialized;
public:
- CefSharpApp(CefSettings^ cefSettings) :
- _cefSettings(cefSettings)
+ CefSharpApp(CefSettings^ cefSettings, Action^ onContextInitialized) :
+ _cefSettings(cefSettings),
+ _onContextInitialized(onContextInitialized)
{
}
~CefSharpApp()
{
_cefSettings = nullptr;
+ _onContextInitialized = nullptr;
+ }
+
+ virtual CefRefPtr GetBrowserProcessHandler() OVERRIDE
+ {
+ return this;
+ }
+
+ virtual void OnContextInitialized() OVERRIDE
+ {
+ if (static_cast(_onContextInitialized) != nullptr)
+ {
+ _onContextInitialized->Invoke();
+ }
}
virtual void OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr command_line) OVERRIDE