Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow calling managed methods from objects bound with RegisterAsyncJsObject that return arrays #1979

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ namespace CefSharp
{
auto frameId = GetInt64(argList, 0);
auto callbackId = GetInt64(argList, 1);

JavascriptRootObjectWrapper^ rootObjectWrapper;
browserWrapper->JavascriptRootObjectWrappers->TryGetValue(frameId, rootObjectWrapper);

Expand All @@ -405,17 +405,44 @@ namespace CefSharp
JavascriptAsyncMethodCallback^ callback;
if (rootObjectWrapper->TryGetAndRemoveMethodCallback(callbackId, callback))
{
auto success = argList->GetBool(2);
if (success)

try
{
callback->Success(DeserializeV8Object(argList, 3));
auto frame = browser->GetFrame(frameId);
if (frame.get())
{
auto context = frame->GetV8Context();

if (context.get() && context->Enter())
{
try
{
auto success = argList->GetBool(2);
if (success)
{
callback->Success(DeserializeV8Object(argList, 3));
}
else
{
callback->Fail(argList->GetString(3));
}
}
finally
{
context->Exit();
}
}
else
{
callback->Fail("Unable to Enter Context");
}
}
}
else
finally
{
callback->Fail(argList->GetString(3));
//dispose
delete callback;
}
//dispose
delete callback;
}
}
handled = true;
Expand Down