diff --git a/src/Tizen.NUI/src/public/WebView/WebView.cs b/src/Tizen.NUI/src/public/WebView/WebView.cs index 2a3fbe4d233..df03a386776 100755 --- a/src/Tizen.NUI/src/public/WebView/WebView.cs +++ b/src/Tizen.NUI/src/public/WebView/WebView.cs @@ -167,6 +167,8 @@ static WebView() private EventHandler userMediaPermissionRequestEventHandler; private WebViewUserMediaPermissionRequestCallback userMediaPermissionRequestCallback; + private WebContext webContext = null; + private WebCookieManager webCookieManager = null; /// /// Default constructor to create a WebView. @@ -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) { @@ -1223,7 +1236,8 @@ public WebContext Context { get { - return new WebContext(Interop.WebView.GetWebContext(), false); + webContext ??= new WebContext(Interop.WebView.GetWebContext(), false); + return webContext; } } @@ -1235,7 +1249,8 @@ public WebCookieManager CookieManager { get { - return new WebCookieManager(Interop.WebView.GetWebCookieManager(), false); + webCookieManager ??= new WebCookieManager(Interop.WebView.GetWebCookieManager(), false); + return webCookieManager; } }