Skip to content

Commit 55ea42b

Browse files
committed
JSB BindObjectAsync return response object
Can now return additional properties, still need better error handling
1 parent 8ff2041 commit 55ea42b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,28 @@ namespace CefSharp
469469
JavascriptAsyncMethodCallback^ callback;
470470
if (_registerBoundObjectRegistry->TryGetAndRemoveMethodCallback(callbackId, callback))
471471
{
472-
callback->Success(CefV8Value::CreateBool(true));
472+
//Response object has no Accessor or Interceptor
473+
auto response = CefV8Value::CreateObject(NULL, NULL);
474+
475+
if (javascriptObjects->Count > 0)
476+
{
477+
//TODO: JSB Should we include a list of successfully bound object names?
478+
response->SetValue("Success", CefV8Value::CreateBool(true), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
479+
response->SetValue("Message", CefV8Value::CreateString("OK"), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
480+
callback->Success(response);
481+
}
482+
else
483+
{
484+
response->SetValue("Success", CefV8Value::CreateBool(false), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
485+
response->SetValue("Message", CefV8Value::CreateString("Zero objects bounds"), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
486+
callback->Success(response);
487+
}
473488

474489
//TODO: JSB deal with failure - no object matching bound
475490

476491
//Send message notifying Browser Process of which objects were bound
492+
//We do this after the objects have been created in the V8Context to gurantee
493+
//they are accessible.
477494
auto msg = CefProcessMessage::Create(kJavascriptObjectsBoundInJavascript);
478495
auto args = msg->GetArgumentList();
479496

0 commit comments

Comments
 (0)