@@ -25,13 +25,37 @@ public BrowserTabView()
2525 InitializeComponent ( ) ;
2626
2727 browser . RequestHandler = new RequestHandler ( ) ;
28- browser . JavascriptObjectRepository . Register ( "bound" , new BoundObject ( ) , isAsync : false , options : BindingOptions . DefaultBinder ) ;
28+
29+ //See https://github.com/cefsharp/CefSharp/issues/2246 for details on the two different binding options
30+ if ( CefSharpSettings . LegacyJavascriptBindingEnabled )
31+ {
32+ browser . RegisterJsObject ( "bound" , new BoundObject ( ) , options : BindingOptions . DefaultBinder ) ;
33+ }
34+ else
35+ {
36+ //Register the new way
37+ browser . JavascriptObjectRepository . Register ( "bound" , new BoundObject ( ) , isAsync : false , options : BindingOptions . DefaultBinder ) ;
38+ }
39+
2940 var bindingOptions = new BindingOptions ( )
3041 {
3142 Binder = BindingOptions . DefaultBinder . Binder ,
3243 MethodInterceptor = new MethodInterceptorLogger ( ) // intercept .net methods calls from js and log it
3344 } ;
34- browser . JavascriptObjectRepository . Register ( "boundAsync" , new AsyncBoundObject ( ) , isAsync : true , options : bindingOptions ) ;
45+
46+ //See https://github.com/cefsharp/CefSharp/issues/2246 for details on the two different binding options
47+ if ( CefSharpSettings . LegacyJavascriptBindingEnabled )
48+ {
49+ browser . RegisterAsyncJsObject ( "boundAsync" , new AsyncBoundObject ( ) , options : bindingOptions ) ;
50+ }
51+ else
52+ {
53+ //Register the new way
54+ browser . JavascriptObjectRepository . Register ( "boundAsync" , new AsyncBoundObject ( ) , isAsync : true , options : bindingOptions ) ;
55+ }
56+
57+ //If you call CefSharp.BindObjectAsync in javascript and pass in the name of an object which is not yet
58+ //bound, then ResolveObject will be called, you can then register it
3559 browser . JavascriptObjectRepository . ResolveObject += ( sender , e ) =>
3660 {
3761 var repo = e . ObjectRepository ;
0 commit comments