[NUI] Add WebView's JavascriptMessageHandler callback
authordongsug.song <dongsug.song@samsung.com>
Wed, 7 Aug 2024 06:32:44 +0000 (15:32 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 8 Aug 2024 03:05:40 +0000 (12:05 +0900)
- JavascriptMessageHandler callback which has two arguments of msg name and body

src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs
src/Tizen.NUI/src/public/WebView/WebView.cs

index c35ad24d03d5ca90761785e952fa4696035f9dd3..93a471f79bb95a473e916008c4873e0e2105da8d 100755 (executable)
@@ -195,6 +195,9 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_AddJavaScriptMessageHandler")]
             public static extern void AddJavaScriptMessageHandler(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_AddJavaScriptEntireMessageHandler")]
+            public static extern void AddJavaScriptEntireMessageHandler(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterJavaScriptAlertCallback")]
             public static extern void RegisterJavaScriptAlertCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
index d0999046913c57670865fe2e2e482ce0314ed134..b0134213dbc3bfb1178b51f4234fb336772298e0 100755 (executable)
@@ -254,6 +254,13 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public delegate void JavaScriptMessageHandler(string message);
 
+        /// <summary>
+        /// The callback function that is invoked when the message is received from the script.
+        /// </summary>
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public delegate void JavaScriptEntireMessageHandler(string messageName, string messageBody);
+
         /// <summary>
         /// The callback function that is invoked when the message is received from the script.
         /// </summary>
@@ -2470,6 +2477,19 @@ namespace Tizen.NUI.BaseComponents
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        /// <summary>
+        /// Add a message handler into the WebView.
+        /// </summary>
+        /// <param name="objectName">The name of exposed object</param>
+        /// <param name="handler">The callback function</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void AddJavaScriptMessageHandler(string objectName, JavaScriptEntireMessageHandler handler)
+        {
+            System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(handler);
+            Interop.WebView.AddJavaScriptEntireMessageHandler(SwigCPtr, objectName, new System.Runtime.InteropServices.HandleRef(this, ip));
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
         /// <summary>
         /// Registers a callback for JS alert.
         /// </summary>