@@ -537,93 +537,17 @@ public void Load(string url)
537537 }
538538 }
539539
540- /// <summary>
541- /// Registers a Javascript object in this specific browser instance.
542- /// </summary>
543- /// <param name="name">The name of the object. (e.g. "foo", if you want the object to be accessible as window.foo).</param>
544- /// <param name="objectToBind">The object to be made accessible to Javascript.</param>
545- /// <param name="options">binding options - camelCaseJavascriptNames default to true </param>
546- /// <exception cref="System.Exception">Browser is already initialized. RegisterJsObject must be +
547- /// called before the underlying CEF browser is created.</exception>
548- public void RegisterJsObject ( string name , object objectToBind , BindingOptions options = null )
549- {
550- if ( ! CefSharpSettings . LegacyJavascriptBindingEnabled )
551- {
552- throw new Exception ( @"CefSharpSettings.LegacyJavascriptBindingEnabled is currently false,
553- for legacy binding you must set CefSharpSettings.LegacyJavascriptBindingEnabled = true
554- before registering your first object see https://github.com/cefsharp/CefSharp/issues/2246
555- for details on the new binding options. If you perform cross-site navigations bound objects will
556- no longer be registered and you will have to migrate to the new method." ) ;
557- }
558-
559- if ( IsBrowserInitialized )
560- {
561- throw new Exception ( "Browser is already initialized. RegisterJsObject must be " +
562- "called before the underlying CEF browser is created." ) ;
563- }
564-
565- InitializeFieldsAndCefIfRequired ( ) ;
566-
567- //Enable WCF if not already enabled
568- CefSharpSettings . WcfEnabled = true ;
569-
570- var objectRepository = managedCefBrowserAdapter . JavascriptObjectRepository ;
571-
572- if ( objectRepository == null )
573- {
574- throw new Exception ( "Object Repository Null, Browser has likely been Disposed." ) ;
575- }
576-
577- objectRepository . Register ( name , objectToBind , false , options ) ;
578- }
579-
580- /// <summary>
581- /// <para>Asynchronously registers a Javascript object in this specific browser instance.</para>
582- /// <para>Only methods of the object will be availabe.</para>
583- /// </summary>
584- /// <param name="name">The name of the object. (e.g. "foo", if you want the object to be accessible as window.foo).</param>
585- /// <param name="objectToBind">The object to be made accessible to Javascript.</param>
586- /// <param name="options">binding options - camelCaseJavascriptNames default to true </param>
587- /// <exception cref="System.Exception">Browser is already initialized. RegisterJsObject must be +
588- /// called before the underlying CEF browser is created.</exception>
589- /// <remarks>The registered methods can only be called in an async way, they will all return immeditaly and the resulting
590- /// object will be a standard javascript Promise object which is usable to wait for completion or failure.</remarks>
591- public void RegisterAsyncJsObject ( string name , object objectToBind , BindingOptions options = null )
592- {
593- if ( ! CefSharpSettings . LegacyJavascriptBindingEnabled )
594- {
595- throw new Exception ( @"CefSharpSettings.LegacyJavascriptBindingEnabled is currently false,
596- for legacy binding you must set CefSharpSettings.LegacyJavascriptBindingEnabled = true
597- before registering your first object see https://github.com/cefsharp/CefSharp/issues/2246
598- for details on the new binding options. If you perform cross-site navigations bound objects will
599- no longer be registered and you will have to migrate to the new method." ) ;
600- }
601-
602- if ( IsBrowserInitialized )
603- {
604- throw new Exception ( "Browser is already initialized. RegisterJsObject must be " +
605- "called before the underlying CEF browser is created." ) ;
606- }
607-
608- InitializeFieldsAndCefIfRequired ( ) ;
609-
610- var objectRepository = managedCefBrowserAdapter . JavascriptObjectRepository ;
611-
612- if ( objectRepository == null )
613- {
614- throw new Exception ( "Object Repository Null, Browser has likely been Disposed." ) ;
615- }
616-
617- objectRepository . Register ( name , objectToBind , true , options ) ;
618- }
619-
620540 /// <summary>
621541 /// The javascript object repository, one repository per ChromiumWebBrowser instance.
622542 /// </summary>
623543 [ Browsable ( false ) , EditorBrowsable ( EditorBrowsableState . Never ) ]
624544 public IJavascriptObjectRepository JavascriptObjectRepository
625545 {
626- get { return managedCefBrowserAdapter == null ? null : managedCefBrowserAdapter . JavascriptObjectRepository ; }
546+ get
547+ {
548+ InitializeFieldsAndCefIfRequired ( ) ;
549+ return managedCefBrowserAdapter == null ? null : managedCefBrowserAdapter . JavascriptObjectRepository ;
550+ }
627551 }
628552
629553 /// <summary>
0 commit comments