diff --git a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp
index 7872d78b4..fb018efb4 100644
--- a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp
+++ b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp
@@ -9,7 +9,7 @@
#include "CefAppUnmanagedWrapper.h"
#include "JavascriptRootObjectWrapper.h"
#include "Serialization\V8Serialization.h"
-#include "Serialization\ObjectsSerialization.h"
+#include "Serialization\JsObjectsSerialization.h"
#include "Async/JavascriptAsyncMethodCallback.h"
#include "..\CefSharp.Core\Internals\Messaging\Messages.h"
#include "..\CefSharp.Core\Internals\Serialization\Primitives.h"
@@ -106,7 +106,7 @@ namespace CefSharp
if (browserWrapper == nullptr)
{
if (name == kJavascriptCallbackDestroyRequest ||
- name == kJavascriptAsyncRootObjectRequest ||
+ name == kJavascriptRootObjectRequest ||
name == kJavascriptAsyncMethodCallResponse)
{
//If we can't find the browser wrapper then we'll just
@@ -271,9 +271,10 @@ namespace CefSharp
handled = true;
}
- else if (name == kJavascriptAsyncRootObjectRequest)
+ else if (name == kJavascriptRootObjectRequest)
{
- browserWrapper->JavascriptAsyncRootObject = DeserializeJsObject(argList, 0);
+ browserWrapper->JavascriptAsyncRootObject = DeserializeJsRootObject(argList, 0);
+ browserWrapper->JavascriptRootObject = DeserializeJsRootObject(argList, 1);
handled = true;
}
else if (name == kJavascriptAsyncMethodCallResponse && rootObjectWrapper != nullptr)
diff --git a/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj b/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj
index d688649d6..c547ce352 100644
--- a/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj
+++ b/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj
@@ -155,6 +155,7 @@
+
@@ -172,13 +173,14 @@
-
+
+
@@ -195,7 +197,7 @@
-
+
Create
Create
diff --git a/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj.filters b/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj.filters
index 82a5d3d39..1b9b28ec3 100644
--- a/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj.filters
+++ b/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj.filters
@@ -68,9 +68,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -83,6 +80,12 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
@@ -130,9 +133,6 @@
Source Files
-
- Source Files
-
Source Files
@@ -145,6 +145,12 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
diff --git a/CefSharp.BrowserSubprocess.Core/Serialization/JsObjectsSerialization.cpp b/CefSharp.BrowserSubprocess.Core/Serialization/JsObjectsSerialization.cpp
new file mode 100644
index 000000000..9e238bcc4
--- /dev/null
+++ b/CefSharp.BrowserSubprocess.Core/Serialization/JsObjectsSerialization.cpp
@@ -0,0 +1,79 @@
+// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
+
+#include "stdafx.h"
+#include "JsObjectsSerialization.h"
+#include "../CefSharp.Core/Internals/Serialization/Primitives.h"
+#include "../CefSharp.Core/Internals/Serialization/ObjectsSerialization.h"
+
+namespace CefSharp
+{
+ namespace Internals
+ {
+ namespace Serialization
+ {
+ JavascriptObject^ DeserializeJsObject(const CefRefPtr& rootList, int index)
+ {
+ if (rootList->GetType(index) == VTYPE_INVALID ||
+ rootList->GetType(index) == VTYPE_NULL)
+ {
+ return nullptr;
+ }
+
+ auto list = rootList->GetList(index);
+ auto jsObject = gcnew JavascriptObject();
+ jsObject->Id = GetInt64(list, 0);
+ jsObject->Name = StringUtils::ToClr(list->GetString(1));
+ jsObject->JavascriptName = StringUtils::ToClr(list->GetString(2));
+
+ auto methodList = list->GetList(3);
+ auto methodCount = methodList->GetInt(0);
+ auto k = 1;
+ for (auto j = 0; j < methodCount; j++)
+ {
+ auto jsMethod = gcnew JavascriptMethod();
+
+ jsMethod->Id = GetInt64(methodList, k++);
+ jsMethod->ManagedName = StringUtils::ToClr(methodList->GetString(k++));
+ jsMethod->JavascriptName = StringUtils::ToClr(methodList->GetString(k++));
+ jsMethod->ParameterCount = methodList->GetInt(k++);
+
+ jsObject->Methods->Add(jsMethod);
+ }
+
+ auto propertyList = list->GetList(4);
+ auto propertyCount = propertyList->GetInt(0);
+ k = 1;
+ for (auto j = 0; j < propertyCount; j++)
+ {
+ auto jsProperty = gcnew JavascriptProperty();
+
+ jsProperty->Id = GetInt64(propertyList, k++);
+ jsProperty->ManagedName = StringUtils::ToClr(propertyList->GetString(k++));
+ jsProperty->JavascriptName = StringUtils::ToClr(propertyList->GetString(k++));
+ jsProperty->IsComplexType = propertyList->GetBool(k++);
+ jsProperty->IsReadOnly = propertyList->GetBool(k++);
+
+ jsProperty->JsObject = DeserializeJsObject(propertyList, k++);
+ jsProperty->PropertyValue = DeserializeObject(propertyList, k++, nullptr);
+
+ jsObject->Properties->Add(jsProperty);
+ }
+ return jsObject;
+ }
+
+ JavascriptRootObject^ DeserializeJsRootObject(const CefRefPtr& list, int index)
+ {
+ auto result = gcnew JavascriptRootObject();
+ auto subList = list->GetList(index);
+ for (auto i = 0; i < subList->GetSize(); i++)
+ {
+ result->MemberObjects->Add(DeserializeJsObject(subList, i));
+ }
+
+ return result;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/CefSharp.BrowserSubprocess.Core/Serialization/JsObjectsSerialization.h b/CefSharp.BrowserSubprocess.Core/Serialization/JsObjectsSerialization.h
new file mode 100644
index 000000000..ddb70cb2c
--- /dev/null
+++ b/CefSharp.BrowserSubprocess.Core/Serialization/JsObjectsSerialization.h
@@ -0,0 +1,19 @@
+// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
+
+#pragma once
+
+#include "include/cef_values.h"
+
+namespace CefSharp
+{
+ namespace Internals
+ {
+ namespace Serialization
+ {
+ JavascriptObject^ DeserializeJsObject(const CefRefPtr& list, int index);
+ JavascriptRootObject^ DeserializeJsRootObject(const CefRefPtr& list, int index);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CefSharp.BrowserSubprocess.Core/Serialization/ObjectsSerialization.cpp b/CefSharp.BrowserSubprocess.Core/Serialization/ObjectsSerialization.cpp
deleted file mode 100644
index 887d7f30c..000000000
--- a/CefSharp.BrowserSubprocess.Core/Serialization/ObjectsSerialization.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
-
-#include "stdafx.h"
-#include "ObjectsSerialization.h"
-#include "../CefSharp.Core/Internals/Serialization/Primitives.h"
-
-namespace CefSharp
-{
- namespace Internals
- {
- namespace Serialization
- {
- JavascriptRootObject^ DeserializeJsObject(const CefRefPtr& list, int index)
- {
- auto result = gcnew JavascriptRootObject();
- auto subList = list->GetList(index);
- for (auto i = 0; i < subList->GetSize(); i++)
- {
- auto objList = subList->GetList(i);
- auto jsObject = gcnew JavascriptObject();
- jsObject->Id = GetInt64(objList, 0);
- jsObject->Name = StringUtils::ToClr(objList->GetString(1));
- jsObject->JavascriptName = StringUtils::ToClr(objList->GetString(2));
-
- auto methodList = objList->GetList(3);
- auto methodCount = methodList->GetInt(0);
- auto k = 1;
- for (auto j = 0; j < methodCount; j++)
- {
- auto jsMethod = gcnew JavascriptMethod();
-
- jsMethod->Id = GetInt64(methodList, k++);
- jsMethod->ManagedName = StringUtils::ToClr(methodList->GetString(k++));
- jsMethod->JavascriptName = StringUtils::ToClr(methodList->GetString(k++));
- jsMethod->ParameterCount = methodList->GetInt(k++);
-
- jsObject->Methods->Add(jsMethod);
- }
-
- result->MemberObjects->Add(jsObject);
- }
-
- return result;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj
index b1e097d23..2018d6c21 100644
--- a/CefSharp.Core/CefSharp.Core.vcxproj
+++ b/CefSharp.Core/CefSharp.Core.vcxproj
@@ -230,12 +230,13 @@
+
-
+
Create
@@ -282,6 +283,7 @@
+
@@ -291,7 +293,7 @@
-
+
diff --git a/CefSharp.Core/CefSharp.Core.vcxproj.filters b/CefSharp.Core/CefSharp.Core.vcxproj.filters
index 1bc5f9948..82049122d 100644
--- a/CefSharp.Core/CefSharp.Core.vcxproj.filters
+++ b/CefSharp.Core/CefSharp.Core.vcxproj.filters
@@ -74,6 +74,9 @@
Source Files
+
+ Source Files
+
Source Files
@@ -226,10 +229,13 @@
Header Files
-
+
Header Files
-
+
+ Header Files
+
+
Header Files
diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp
index 27f057431..83cf8bd51 100644
--- a/CefSharp.Core/Internals/ClientAdapter.cpp
+++ b/CefSharp.Core/Internals/ClientAdapter.cpp
@@ -21,6 +21,7 @@
#include "CefWindowInfoWrapper.h"
#include "Serialization\Primitives.h"
#include "Serialization\V8Serialization.h"
+#include "Serialization\JsObjectsSerialization.h"
#include "Serialization\ObjectsSerialization.h"
#include "Messaging\Messages.h"
@@ -158,9 +159,10 @@ namespace CefSharp
_javascriptCallbackFactories->Add(browser->GetIdentifier(), _browserAdapter->JavascriptCallbackFactory);
//transmit async bound objects
- auto jsRootObjectMessage = CefProcessMessage::Create(kJavascriptAsyncRootObjectRequest);
+ auto jsRootObjectMessage = CefProcessMessage::Create(kJavascriptRootObjectRequest);
auto argList = jsRootObjectMessage->GetArgumentList();
SerializeJsObject(_browserAdapter->JavascriptObjectRepository->AsyncRootObject, argList, 0);
+ SerializeJsObject(_browserAdapter->JavascriptObjectRepository->RootObject, argList, 1);
browser->SendProcessMessage(CefProcessId::PID_RENDERER, jsRootObjectMessage);
}
@@ -918,7 +920,7 @@ namespace CefSharp
if (success)
{
- response->Result = DeserializeV8Object(argList, 2, callbackFactory);
+ response->Result = DeserializeObject(argList, 2, callbackFactory);
}
else
{
@@ -941,7 +943,7 @@ namespace CefSharp
auto methodInvocation = gcnew MethodInvocation(objectId, methodName, (callbackId > 0 ? Nullable(callbackId) : Nullable()));
for (auto i = 0; i < arguments->GetSize(); i++)
{
- methodInvocation->Parameters->Add(DeserializeV8Object(arguments, i, callbackFactory));
+ methodInvocation->Parameters->Add(DeserializeObject(arguments, i, callbackFactory));
}
_browserAdapter->MethodRunnerQueue->Enqueue(methodInvocation);
diff --git a/CefSharp.Core/Internals/Messaging/Messages.h b/CefSharp.Core/Internals/Messaging/Messages.h
index 85c37ef86..42a466f76 100644
--- a/CefSharp.Core/Internals/Messaging/Messages.h
+++ b/CefSharp.Core/Internals/Messaging/Messages.h
@@ -24,8 +24,8 @@ namespace CefSharp
const CefString kJavascriptCallbackDestroyRequest = "JavascriptCallbackDestroyRequest";
//Message containing the result of a given js function call
const CefString kJavascriptCallbackResponse = "JavascriptCallbackDoneResponse";
- //Message containing a js root object for async bindings
- const CefString kJavascriptAsyncRootObjectRequest = "JavascriptRootObjectRequest";
+ //Message containing a js root object for js bindings
+ const CefString kJavascriptRootObjectRequest = "JavascriptRootObjectRequest";
//Message from the render process to request a method invocation on a bound object
const CefString kJavascriptAsyncMethodCallRequest = "JavascriptAsyncMethodCallRequest";
//Message from the browser process containing the result of a bound method invocation
diff --git a/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.cpp b/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.cpp
new file mode 100644
index 000000000..8518be406
--- /dev/null
+++ b/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.cpp
@@ -0,0 +1,81 @@
+// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
+
+#include "Stdafx.h"
+#include "Primitives.h"
+#include "JsObjectsSerialization.h"
+#include "V8Serialization.h"
+
+namespace CefSharp
+{
+ namespace Internals
+ {
+ namespace Serialization
+ {
+ void SerializeJsObject(JavascriptObject^ jsObject, CefRefPtr &list, int index)
+ {
+ auto objList = CefListValue::Create();
+ SetInt64(jsObject->Id, objList, 0);
+ objList->SetString(1, StringUtils::ToNative(jsObject->Name));
+ objList->SetString(2, StringUtils::ToNative(jsObject->JavascriptName));
+
+ auto methodList = CefListValue::Create();
+ auto j = 0;
+ methodList->SetInt(j++, jsObject->Methods->Count);
+ for each (JavascriptMethod^ jsMethod in jsObject->Methods)
+ {
+ SetInt64(jsMethod->Id, methodList, j++);
+ methodList->SetString(j++, StringUtils::ToNative(jsMethod->ManagedName));
+ methodList->SetString(j++, StringUtils::ToNative(jsMethod->JavascriptName));
+ methodList->SetInt(j++, jsMethod->ParameterCount);
+ }
+ objList->SetList(3, methodList);
+
+ auto propertyList = CefListValue::Create();
+ j = 0;
+ propertyList->SetInt(j++, jsObject->Properties->Count);
+ for each(JavascriptProperty^ jsProperty in jsObject->Properties)
+ {
+ SetInt64(jsProperty->Id, propertyList, j++);
+ propertyList->SetString(j++, StringUtils::ToNative(jsProperty->ManagedName));
+ propertyList->SetString(j++, StringUtils::ToNative(jsProperty->JavascriptName));
+ propertyList->SetBool(j++, jsProperty->IsComplexType);
+ propertyList->SetBool(j++, jsProperty->IsReadOnly);
+
+ if (jsProperty->JsObject != nullptr)
+ {
+ SerializeJsObject(jsProperty->JsObject, propertyList, j++);
+ }
+ else
+ {
+ propertyList->SetNull(j++);
+ }
+
+ if (jsProperty->PropertyValue != nullptr)
+ {
+ SerializeV8Object(jsProperty->PropertyValue, propertyList, j++);
+ }
+ else
+ {
+ propertyList->SetNull(j++);
+ }
+ }
+ objList->SetList(4, propertyList);
+
+ list->SetList(index, objList);
+ }
+
+ void SerializeJsObject(JavascriptRootObject^ object, CefRefPtr &list, int index)
+ {
+ auto subList = CefListValue::Create();
+ auto i = 0;
+ for each (JavascriptObject^ jsObject in object->MemberObjects)
+ {
+ SerializeJsObject(jsObject, subList, i++);
+ }
+ list->SetList(index, subList);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/CefSharp.BrowserSubprocess.Core/Serialization/ObjectsSerialization.h b/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.h
similarity index 68%
rename from CefSharp.BrowserSubprocess.Core/Serialization/ObjectsSerialization.h
rename to CefSharp.Core/Internals/Serialization/JsObjectsSerialization.h
index 3f1d02f77..ab2afd4f3 100644
--- a/CefSharp.BrowserSubprocess.Core/Serialization/ObjectsSerialization.h
+++ b/CefSharp.Core/Internals/Serialization/JsObjectsSerialization.h
@@ -4,15 +4,13 @@
#pragma once
-#include "include/cef_values.h"
-
namespace CefSharp
{
namespace Internals
{
namespace Serialization
{
- JavascriptRootObject^ DeserializeJsObject(const CefRefPtr& list, int index);
+ void SerializeJsObject(JavascriptRootObject^ object, CefRefPtr &list, int index);
}
}
}
\ No newline at end of file
diff --git a/CefSharp.Core/Internals/Serialization/ObjectsSerialization.cpp b/CefSharp.Core/Internals/Serialization/ObjectsSerialization.cpp
index 244e41947..356042e1a 100644
--- a/CefSharp.Core/Internals/Serialization/ObjectsSerialization.cpp
+++ b/CefSharp.Core/Internals/Serialization/ObjectsSerialization.cpp
@@ -3,8 +3,10 @@
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "Stdafx.h"
-#include "Primitives.h"
#include "ObjectsSerialization.h"
+#include "Primitives.h"
+
+using namespace System::Collections::Generic;
namespace CefSharp
{
@@ -12,33 +14,82 @@ namespace CefSharp
{
namespace Serialization
{
- void SerializeJsObject(JavascriptRootObject^ object, CefRefPtr &list, int index)
+ template
+ Object^ DeserializeObject(CefRefPtr list, TIndex index, IJavascriptCallbackFactory^ javascriptCallbackFactory)
{
- auto subList = CefListValue::Create();
- auto i = 0;
- for each (JavascriptObject^ jsObject in object->MemberObjects)
+ Object^ result = nullptr;
+ auto type = list->GetType(index);
+
+ if (type == VTYPE_BOOL)
{
- auto objList = CefListValue::Create();
- SetInt64(jsObject->Id, objList, 0);
- objList->SetString(1, StringUtils::ToNative(jsObject->Name));
- objList->SetString(2, StringUtils::ToNative(jsObject->JavascriptName));
-
- auto methodList = CefListValue::Create();
- auto j = 0;
- methodList->SetInt(j++, jsObject->Methods->Count);
- for each (JavascriptMethod^ jsMethod in jsObject->Methods)
- {
- SetInt64(jsMethod->Id, methodList, j++);
- methodList->SetString(j++, StringUtils::ToNative(jsMethod->ManagedName));
- methodList->SetString(j++, StringUtils::ToNative(jsMethod->JavascriptName));
- methodList->SetInt(j++, jsMethod->ParameterCount);
- }
- objList->SetList(3, methodList);
-
- subList->SetList(i++, objList);
+ result = list->GetBool(index);
}
- list->SetList(index, subList);
+ else if (type == VTYPE_INT)
+ {
+ result = list->GetInt(index);
+ }
+ else if (IsInt64(list, index))
+ {
+ result = GetInt64(list, index);
+ }
+ else if (IsCefTime(list, index))
+ {
+ auto cefTime = GetCefTime(list, index);
+ result = ConvertCefTimeToDateTime(cefTime);
+ }
+ else if (IsJsCallback(list, index) && javascriptCallbackFactory != nullptr)
+ {
+ auto jsCallbackDto = GetJsCallback(list, index);
+ result = javascriptCallbackFactory->Create(jsCallbackDto);
+ }
+ else if (type == VTYPE_DOUBLE)
+ {
+ result = list->GetDouble(index);
+ }
+ else if (type == VTYPE_STRING)
+ {
+ result = StringUtils::ToClr(list->GetString(index));
+ }
+ else if (type == VTYPE_LIST)
+ {
+ auto subList = list->GetList(index);
+ auto array = gcnew List