Skip to content

Commit

Permalink
Allow for custom JavascriptObjectRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
amaitland committed Jan 2, 2025
1 parent 7ef8e3e commit acda14f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CefSharp.Core.Runtime/ManagedCefBrowserAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace CefSharp
}

_webBrowserInternal = webBrowserInternal;
_javaScriptObjectRepository = gcnew CefSharp::Internals::JavascriptObjectRepository();
_javaScriptObjectRepository = CefSharpSettings::ObjectFactory->CreateJavascriptObjectRepository(_webBrowserInternal);
_javascriptCallbackFactory = gcnew CefSharp::Internals::JavascriptCallbackFactory(_clientAdapter->GetPendingTaskRepository());

_methodRunnerQueue = CefSharpSettings::ObjectFactory->CreateMethodRunnerQueue(_webBrowserInternal, _javaScriptObjectRepository);
Expand Down
7 changes: 7 additions & 0 deletions CefSharp/ICefSharpObjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ public interface ICefSharpObjectFactory
/// <param name="javascriptObjectRepository">Javascript Object Repository</param>
/// <returns>Returns a new instance of <see cref="IMethodRunnerQueue"/>. Cannot be null.</returns>
IMethodRunnerQueue CreateMethodRunnerQueue(IWebBrowser webBrowser, IJavascriptObjectRepositoryInternal javascriptObjectRepository);

/// <summary>
/// Creates a new instance of <see cref="IJavascriptObjectRepositoryInternal"/
/// </summary>
/// <param name="webBrowser">The ChromiumWebBrowser instance.</param>
/// <returns>Returns a new instance of <see cref="IJavascriptObjectRepositoryInternal"/>. Cannot be null.</returns>
IJavascriptObjectRepositoryInternal CreateJavascriptObjectRepository(IWebBrowser webBrowser);
}
}
5 changes: 5 additions & 0 deletions CefSharp/Internals/CefSharpObjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace CefSharp.Internals
{
public sealed class CefSharpObjectFactory : ICefSharpObjectFactory
{
public IJavascriptObjectRepositoryInternal CreateJavascriptObjectRepository(IWebBrowser webBrowser)
{
return new JavascriptObjectRepository();
}

public IMethodRunnerQueue CreateMethodRunnerQueue(IWebBrowser webBrowser, IJavascriptObjectRepositoryInternal javascriptObjectRepository)
{
if (CefSharpSettings.ConcurrentTaskExecution)
Expand Down

0 comments on commit acda14f

Please sign in to comment.