CefAppUnmanagedWrapper::OnContextCreated - Send OnContextCreated message after Objects created

Message is now sent once the CefSharp.BindObjectAsync and helper functions are created and Legacy objects
are bound.

It should now be reliable to call CefSharp.BindObjectAsync in OnContextCreated
This commit is contained in:
amaitland
2018-08-05 19:56:41 +10:00
parent 366d3a898c
commit 010bc8cca5
@@ -61,18 +61,6 @@ namespace CefSharp
void CefAppUnmanagedWrapper::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context)
{
//Send a message to the browser processing signaling that OnContextCreated has been called
//only param is the FrameId. Currently an IPC message is only sent for the main frame - will see
//how viable this solution is and if it's worth expanding to sub/child frames.
if (frame->IsMain())
{
auto contextCreatedMessage = CefProcessMessage::Create(kOnContextCreatedRequest);
SetInt64(contextCreatedMessage->GetArgumentList(), 0, frame->GetIdentifier());
browser->SendProcessMessage(CefProcessId::PID_BROWSER, contextCreatedMessage);
}
if (_legacyBindingEnabled)
{
if (_javascriptObjects->Count > 0)
@@ -112,6 +100,18 @@ namespace CefSharp
cefSharpObjCamelCase->SetValue(kDeleteBoundObjectCamelCase, unBindObjFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kRemoveObjectFromCacheCamelCase, removeObjectFromCacheFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
cefSharpObjCamelCase->SetValue(kIsObjectCachedCamelCase, isObjectCachedFunction, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
//Send a message to the browser processing signaling that OnContextCreated has been called
//only param is the FrameId. Currently an IPC message is only sent for the main frame - will see
//how viable this solution is and if it's worth expanding to sub/child frames.
if (frame->IsMain())
{
auto contextCreatedMessage = CefProcessMessage::Create(kOnContextCreatedRequest);
SetInt64(contextCreatedMessage->GetArgumentList(), 0, frame->GetIdentifier());
browser->SendProcessMessage(CefProcessId::PID_BROWSER, contextCreatedMessage);
}
};
void CefAppUnmanagedWrapper::OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context)