Skip to content

Commit aa09702

Browse files
committed
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
1 parent c7655e9 commit aa09702

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,34 @@ namespace CefSharp
5555
//Multiple CefBrowserWrappers created when opening popups
5656
_browserWrappers->TryAdd(browser->GetIdentifier(), wrapper);
5757

58-
_legacyBindingEnabled = extraInfo->GetBool("LegacyBindingEnabled");
59-
60-
if (_legacyBindingEnabled)
58+
//For the main browser only we check LegacyBindingEnabled and
59+
//load the objects. Popups don't send this information and checking
60+
//will override the _legacyBindingEnabled field
61+
if (!browser->IsPopup())
6162
{
62-
auto objects = extraInfo->GetList("LegacyBindingObjects");
63-
if (objects.get() && objects->IsValid())
64-
{
65-
auto javascriptObjects = DeserializeJsObjects(objects, 0);
63+
_legacyBindingEnabled = extraInfo->GetBool("LegacyBindingEnabled");
6664

67-
for each (JavascriptObject^ obj in Enumerable::OfType<JavascriptObject^>(javascriptObjects))
65+
if (_legacyBindingEnabled)
66+
{
67+
auto objects = extraInfo->GetList("LegacyBindingObjects");
68+
if (objects.get() && objects->IsValid())
6869
{
69-
//Using LegacyBinding with multiple ChromiumWebBrowser instances that share the same
70-
//render process and using LegacyBinding will cause problems for the limited caching implementation
71-
//that exists at the moment, for now we'll remove an object if already exists, same behaviour
72-
//as the new binding method.
73-
//TODO: This should be removed when https://github.com/cefsharp/CefSharp/issues/2306
74-
//Is complete as objects will be stored at the browser level
75-
if (_javascriptObjects->ContainsKey(obj->JavascriptName))
70+
auto javascriptObjects = DeserializeJsObjects(objects, 0);
71+
72+
for each (JavascriptObject^ obj in Enumerable::OfType<JavascriptObject^>(javascriptObjects))
7673
{
77-
_javascriptObjects->Remove(obj->JavascriptName);
74+
//Using LegacyBinding with multiple ChromiumWebBrowser instances that share the same
75+
//render process and using LegacyBinding will cause problems for the limited caching implementation
76+
//that exists at the moment, for now we'll remove an object if already exists, same behaviour
77+
//as the new binding method.
78+
//TODO: This should be removed when https://github.com/cefsharp/CefSharp/issues/2306
79+
//Is complete as objects will be stored at the browser level
80+
if (_javascriptObjects->ContainsKey(obj->JavascriptName))
81+
{
82+
_javascriptObjects->Remove(obj->JavascriptName);
83+
}
84+
_javascriptObjects->Add(obj->JavascriptName, obj);
7885
}
79-
_javascriptObjects->Add(obj->JavascriptName, obj);
8086
}
8187
}
8288
}

0 commit comments

Comments
 (0)