[NUI] Make webcontext/cookiemanager static.
authorhuayong.xu <huayong.xu@samsung.com>
Tue, 12 Jul 2022 10:08:16 +0000 (18:08 +0800)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Mon, 25 Jul 2022 08:33:12 +0000 (17:33 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs
src/Tizen.NUI/src/public/WebView/WebView.cs

index da9fc65..b3cf6c1 100755 (executable)
@@ -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);
 
index f21a44f..bb90018 100755 (executable)
@@ -29,6 +29,9 @@ namespace Tizen.NUI.BaseComponents
     /// <since_tizen> 9 </since_tizen>
     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;
 
+
         /// <summary>
         /// Creates a WebView.
         /// </summary>
@@ -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
         }
 
         /// <summary>
-        /// BackForwardList.
+        /// Context.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public WebBackForwardList BackForwardList { get; }
+        public static WebContext Context => context;
 
         /// <summary>
-        /// Context.
+        /// CookieManager.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public WebContext Context { get; }
+        public static WebCookieManager CookieManager => cookieManager;
 
         /// <summary>
-        /// CookieManager.
+        /// BackForwardList.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public WebCookieManager CookieManager { get; }
+        public WebBackForwardList BackForwardList { get; }
 
         /// <summary>
         /// BackForwardList.