Skip to content

Commit

Permalink
JSB - JavascriptObjectRepository.ResolveObject was only being called …
Browse files Browse the repository at this point in the history
…when object previously registered

The HasBoundObjects check has been removed, now we always attempt to GetObjects and return a response

Resolves #2273
  • Loading branch information
amaitland committed Feb 13, 2018
1 parent bea70cc commit 38663e3
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions CefSharp.Core/Internals/ClientAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,9 @@ namespace CefSharp
{
auto objectRepository = _browserAdapter->JavascriptObjectRepository;

//For legacy binding we only send kJavascriptRootObjectResponse when we have bound objects
if (objectRepository->HasBoundObjects)
{
/*auto jsRootObjectMessage = CefProcessMessage::Create(kJavascriptRootObjectRequest);
auto argList = jsRootObjectMessage->GetArgumentList();
SerializeJsObject(objectRepository->GetObjects(nullptr), argList, 0);
browser->SendProcessMessage(CefProcessId::PID_RENDERER, jsRootObjectMessage);*/

auto msg = CefProcessMessage::Create(kJavascriptRootObjectResponse);
auto responseArgList = msg->GetArgumentList();
responseArgList->SetBool(0, true); //Use Legacy Behaviour (auto bind on context creation)
Expand Down Expand Up @@ -1145,28 +1141,30 @@ namespace CefSharp
{
auto objectRepository = _browserAdapter->JavascriptObjectRepository;

if (objectRepository->HasBoundObjects)
{
auto browserId = argList->GetInt(0);
auto frameId = GetInt64(argList, 1);
auto callbackId = GetInt64(argList, 2);
auto objectNames = argList->GetList(3);
auto browserId = argList->GetInt(0);
auto frameId = GetInt64(argList, 1);
auto callbackId = GetInt64(argList, 2);
auto objectNames = argList->GetList(3);

auto names = gcnew List<String^>(objectNames->GetSize());
for (auto i = 0; i < objectNames->GetSize(); i++)
{
names->Add(StringUtils::ToClr(objectNames->GetString(i)));
}

auto msg = CefProcessMessage::Create(kJavascriptRootObjectResponse);
auto responseArgList = msg->GetArgumentList();
responseArgList->SetBool(0, false); //Use LegacyBehaviour (false)
responseArgList->SetInt(1, browserId);
SetInt64(responseArgList, 2, frameId);
SetInt64(responseArgList, 3, callbackId);
SerializeJsObjects(objectRepository->GetObjects(names), responseArgList, 4);
browser->SendProcessMessage(CefProcessId::PID_RENDERER, msg);
auto names = gcnew List<String^>(objectNames->GetSize());
for (auto i = 0; i < objectNames->GetSize(); i++)
{
names->Add(StringUtils::ToClr(objectNames->GetString(i)));
}

//Call GetObjects with the list of names provided (will default to all if the list is empty
//Previously we only sent a response if there were bound objects, now we always send
//a response so the promise is resolved.
auto objs = objectRepository->GetObjects(names);

auto msg = CefProcessMessage::Create(kJavascriptRootObjectResponse);
auto responseArgList = msg->GetArgumentList();
responseArgList->SetBool(0, false); //Use LegacyBehaviour (false)
responseArgList->SetInt(1, browserId);
SetInt64(responseArgList, 2, frameId);
SetInt64(responseArgList, 3, callbackId);
SerializeJsObjects(objs, responseArgList, 4);
browser->SendProcessMessage(CefProcessId::PID_RENDERER, msg);
}

handled = true;
Expand Down

0 comments on commit 38663e3

Please sign in to comment.