From 010bc8cca545781fd2922bcbde440cc705ca63a0 Mon Sep 17 00:00:00 2001 From: amaitland Date: Sun, 5 Aug 2018 19:56:41 +1000 Subject: [PATCH] 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 --- .../CefAppUnmanagedWrapper.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp index df1d7e9f4..928aff733 100644 --- a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp +++ b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp @@ -61,18 +61,6 @@ namespace CefSharp void CefAppUnmanagedWrapper::OnContextCreated(CefRefPtr browser, CefRefPtr frame, CefRefPtr 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 browser, CefRefPtr frame, CefRefPtr context)