Skip to content

Commit

Permalink
[NUI] Modified the WebView to hold the instances of WebContext and We…
Browse files Browse the repository at this point in the history
…bCookieManager
  • Loading branch information
dongsug-song committed Oct 31, 2024
1 parent bc221dd commit dc40cc2
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/Tizen.NUI/src/public/WebView/WebView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ static WebView()
private EventHandler<WebViewUserMediaPermissionRequestEventArgs> userMediaPermissionRequestEventHandler;
private WebViewUserMediaPermissionRequestCallback userMediaPermissionRequestCallback;

private WebContext webContext = null;
private WebCookieManager webCookieManager = null;

/// <summary>
/// Default constructor to create a WebView.
Expand Down Expand Up @@ -244,9 +246,20 @@ protected override void Dispose(DisposeTypes type)
return;
}

Context.RegisterDownloadStartedCallback(null);
Context.RegisterMimeOverriddenCallback(null);
Context.RegisterHttpRequestInterceptedCallback(null);
if (webContext != null)
{
webContext.RegisterDownloadStartedCallback(null);
webContext.RegisterMimeOverriddenCallback(null);
webContext.RegisterHttpRequestInterceptedCallback(null);
webContext.Dispose();
webContext = null;
}

if (webCookieManager != null)
{
webCookieManager.Dispose();
webCookieManager = null;
}

if (type == DisposeTypes.Explicit)
{
Expand Down Expand Up @@ -1223,7 +1236,8 @@ public WebContext Context
{
get
{
return new WebContext(Interop.WebView.GetWebContext(), false);
webContext ??= new WebContext(Interop.WebView.GetWebContext(), false);
return webContext;
}
}

Expand All @@ -1235,7 +1249,8 @@ public WebCookieManager CookieManager
{
get
{
return new WebCookieManager(Interop.WebView.GetWebCookieManager(), false);
webCookieManager ??= new WebCookieManager(Interop.WebView.GetWebCookieManager(), false);
return webCookieManager;
}
}

Expand Down

0 comments on commit dc40cc2

Please sign in to comment.