From b44eb9e1794ff7233196be2e9dc2bc787730005f Mon Sep 17 00:00:00 2001 From: "huayong.xu" Date: Tue, 12 Jul 2022 18:08:16 +0800 Subject: [PATCH] [NUI] Make webcontext/cookiemanager static. --- .../src/internal/Interop/Interop.WebView.cs | 12 ++++++------ src/Tizen.NUI/src/public/WebView/WebView.cs | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs index da9fc65..b3cf6c1 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs @@ -30,6 +30,12 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_New_3")] public static extern global::System.IntPtr New3(int jarg1, string[] jarg2); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetContext")] + public static extern global::System.IntPtr GetWebContext(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetCookieManager")] + public static extern global::System.IntPtr GetWebCookieManager(); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WebView__SWIG_1")] public static extern global::System.IntPtr NewWebView(global::System.Runtime.InteropServices.HandleRef jarg1); @@ -51,12 +57,6 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetBackForwardList")] public static extern global::System.IntPtr GetWebBackForwardList(global::System.Runtime.InteropServices.HandleRef jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetContext")] - public static extern global::System.IntPtr GetWebContext(global::System.Runtime.InteropServices.HandleRef jarg1); - - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetCookieManager")] - public static extern global::System.IntPtr GetWebCookieManager(global::System.Runtime.InteropServices.HandleRef jarg1); - [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetSettings")] public static extern global::System.IntPtr GetWebSettings(global::System.Runtime.InteropServices.HandleRef jarg1); diff --git a/src/Tizen.NUI/src/public/WebView/WebView.cs b/src/Tizen.NUI/src/public/WebView/WebView.cs index f21a44f..bb90018 100755 --- a/src/Tizen.NUI/src/public/WebView/WebView.cs +++ b/src/Tizen.NUI/src/public/WebView/WebView.cs @@ -29,6 +29,9 @@ namespace Tizen.NUI.BaseComponents /// 9 public partial class WebView : View { + private static readonly WebContext context = new WebContext(Interop.WebView.GetWebContext(), false); + private static readonly WebCookieManager cookieManager = new WebCookieManager(Interop.WebView.GetWebCookieManager(), false); + private Color contentBackgroundColor; private bool tilesClearedWhenHidden; private float tileCoverAreaMultiplier; @@ -90,6 +93,7 @@ namespace Tizen.NUI.BaseComponents private PlainTextReceivedCallback plainTextReceivedCallback; + /// /// Creates a WebView. /// @@ -136,8 +140,6 @@ namespace Tizen.NUI.BaseComponents hitTestFinishedProxyCallback = OnHitTestFinished; BackForwardList = new WebBackForwardList(Interop.WebView.GetWebBackForwardList(SwigCPtr), false); - Context = new WebContext(Interop.WebView.GetWebContext(SwigCPtr), false); - CookieManager = new WebCookieManager(Interop.WebView.GetWebCookieManager(SwigCPtr), false); Settings = new WebSettings(Interop.WebView.GetWebSettings(SwigCPtr), false); } @@ -158,8 +160,6 @@ namespace Tizen.NUI.BaseComponents //Release your own managed resources here. //You should release all of your own disposable objects here. BackForwardList.Dispose(); - Context.Dispose(); - CookieManager.Dispose(); Settings.Dispose(); } @@ -740,22 +740,22 @@ namespace Tizen.NUI.BaseComponents } /// - /// BackForwardList. + /// Context. /// [EditorBrowsable(EditorBrowsableState.Never)] - public WebBackForwardList BackForwardList { get; } + public static WebContext Context => context; /// - /// Context. + /// CookieManager. /// [EditorBrowsable(EditorBrowsableState.Never)] - public WebContext Context { get; } + public static WebCookieManager CookieManager => cookieManager; /// - /// CookieManager. + /// BackForwardList. /// [EditorBrowsable(EditorBrowsableState.Never)] - public WebCookieManager CookieManager { get; } + public WebBackForwardList BackForwardList { get; } /// /// BackForwardList. -- 2.7.4