LegacyJavascriptBinding - Enabled field was overwritten when a popup was opened

Popups don't transmit their own bound object information, _legacyBindingEnabled was being set to false
This commit is contained in:
amaitland
2019-08-11 18:28:42 +10:00
parent c7655e95c6
commit aa0970268f
@@ -55,28 +55,34 @@ namespace CefSharp
//Multiple CefBrowserWrappers created when opening popups
_browserWrappers->TryAdd(browser->GetIdentifier(), wrapper);
_legacyBindingEnabled = extraInfo->GetBool("LegacyBindingEnabled");
if (_legacyBindingEnabled)
//For the main browser only we check LegacyBindingEnabled and
//load the objects. Popups don't send this information and checking
//will override the _legacyBindingEnabled field
if (!browser->IsPopup())
{
auto objects = extraInfo->GetList("LegacyBindingObjects");
if (objects.get() && objects->IsValid())
{
auto javascriptObjects = DeserializeJsObjects(objects, 0);
_legacyBindingEnabled = extraInfo->GetBool("LegacyBindingEnabled");
for each (JavascriptObject^ obj in Enumerable::OfType<JavascriptObject^>(javascriptObjects))
if (_legacyBindingEnabled)
{
auto objects = extraInfo->GetList("LegacyBindingObjects");
if (objects.get() && objects->IsValid())
{
//Using LegacyBinding with multiple ChromiumWebBrowser instances that share the same
//render process and using LegacyBinding will cause problems for the limited caching implementation
//that exists at the moment, for now we'll remove an object if already exists, same behaviour
//as the new binding method.
//TODO: This should be removed when https://github.com/cefsharp/CefSharp/issues/2306
//Is complete as objects will be stored at the browser level
if (_javascriptObjects->ContainsKey(obj->JavascriptName))
auto javascriptObjects = DeserializeJsObjects(objects, 0);
for each (JavascriptObject^ obj in Enumerable::OfType<JavascriptObject^>(javascriptObjects))
{
_javascriptObjects->Remove(obj->JavascriptName);
//Using LegacyBinding with multiple ChromiumWebBrowser instances that share the same
//render process and using LegacyBinding will cause problems for the limited caching implementation
//that exists at the moment, for now we'll remove an object if already exists, same behaviour
//as the new binding method.
//TODO: This should be removed when https://github.com/cefsharp/CefSharp/issues/2306
//Is complete as objects will be stored at the browser level
if (_javascriptObjects->ContainsKey(obj->JavascriptName))
{
_javascriptObjects->Remove(obj->JavascriptName);
}
_javascriptObjects->Add(obj->JavascriptName, obj);
}
_javascriptObjects->Add(obj->JavascriptName, obj);
}
}
}