[NUI] Add WebAuthDisplayQR, Response and MediaPermission
authordongsug.song <dongsug.song@samsung.com>
Thu, 5 Sep 2024 13:12:37 +0000 (22:12 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Thu, 10 Oct 2024 10:57:23 +0000 (19:57 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.WebUserMediaPermissionRequest.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs
src/Tizen.NUI/src/internal/WebView/WebUserMediaPermissionRequest.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/WebView/WebViewUserMediaPermissionRequestEventArgs.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/WebView/WebViewWebAuthDisplayQREventArgs.cs [new file with mode: 0755]
src/Tizen.NUI/src/public/WebView/WebView.cs

diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WebUserMediaPermissionRequest.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WebUserMediaPermissionRequest.cs
new file mode 100755 (executable)
index 0000000..93b1d93
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Tizen.NUI
+{
+    internal static partial class Interop
+    {
+        internal static partial class WebUserMediaPermissionRequest
+        {
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_UserMediaPermissionRequest")]
+            public static extern void Delete(global::System.Runtime.InteropServices.HandleRef webPermission);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_UserMediaPermissionRequest_Set")]
+            public static extern void Set(global::System.Runtime.InteropServices.HandleRef webPermission, bool allowed);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_UserMediaPermissionRequest_Suspend")]
+            [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+            public static extern bool Suspend(global::System.Runtime.InteropServices.HandleRef webPermission);
+        }
+    }
+}
+
index 57882328105019375c561d5ada48b5d322122434..faa326dfdaa1da442fb1008c39bd988c3774f76f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -336,6 +336,18 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_GetPlainTextAsynchronously")]
             public static extern void GetPlainTextAsynchronously(global::System.Runtime.InteropServices.HandleRef webViewRef, global::System.Runtime.InteropServices.HandleRef callbackRef);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_WebAuthenticationCancel")]
+            public static extern void WebAuthenticationCancel(global::System.Runtime.InteropServices.HandleRef webViewRef);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterWebAuthDisplayQRCallback")]
+            public static extern void RegisterWebAuthDisplayQRCallback(global::System.Runtime.InteropServices.HandleRef webViewRef, global::System.Runtime.InteropServices.HandleRef callbackRef);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterWebAuthResponseCallback")]
+            public static extern void RegisterWebAuthResponseCallback(global::System.Runtime.InteropServices.HandleRef webViewRef, global::System.Runtime.InteropServices.HandleRef callbackRef);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterUserMediaPermissionRequestCallback")]
+            public static extern void RegisterUserMediaPermissionRequestCallback(global::System.Runtime.InteropServices.HandleRef webViewRef, global::System.Runtime.InteropServices.HandleRef callbackRef);
         }
     }
 }
diff --git a/src/Tizen.NUI/src/internal/WebView/WebUserMediaPermissionRequest.cs b/src/Tizen.NUI/src/internal/WebView/WebUserMediaPermissionRequest.cs
new file mode 100755 (executable)
index 0000000..16b01c3
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.NUI
+{
+    /// <summary>
+    /// WebUserMediaPermissionRequest.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class WebUserMediaPermissionRequest : Disposable
+    {
+        internal WebUserMediaPermissionRequest(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+        {
+        }
+
+        /// This will not be public opened.
+        /// <param name="swigCPtr"></param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+        {
+            Interop.WebUserMediaPermissionRequest.Delete(swigCPtr);
+        }
+
+        /// <summary>
+        /// Set allowed.
+        /// </summary>
+        /// <param name="allowed">Allowed or not</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void Set(bool allowed)
+        {
+            Interop.WebUserMediaPermissionRequest.Set(SwigCPtr, allowed);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Suspend.
+        /// </summary>
+        /// <returns>true for done, otherwise, false</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool Suspend()
+        {
+            bool ret = Interop.WebUserMediaPermissionRequest.Suspend(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+    }
+}
diff --git a/src/Tizen.NUI/src/internal/WebView/WebViewUserMediaPermissionRequestEventArgs.cs b/src/Tizen.NUI/src/internal/WebView/WebViewUserMediaPermissionRequestEventArgs.cs
new file mode 100755 (executable)
index 0000000..788cdf4
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.NUI
+{
+    /// <summary>
+    /// Event arguments that WebViewUserMediaPermissionRequest.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class WebViewUserMediaPermissionRequestEventArgs : EventArgs
+    {
+        internal WebViewUserMediaPermissionRequestEventArgs(WebUserMediaPermissionRequest permission, string message)
+        {
+            UserMediaPermissionRequest = permission;
+            Message = message;
+        }
+
+        /// <summary>
+        /// Gets UserMediaPermissionRequest.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public WebUserMediaPermissionRequest UserMediaPermissionRequest { get; }
+
+        /// <summary>
+        /// Gets Message.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public string Message { get; }
+
+    }
+}
diff --git a/src/Tizen.NUI/src/internal/WebView/WebViewWebAuthDisplayQREventArgs.cs b/src/Tizen.NUI/src/internal/WebView/WebViewWebAuthDisplayQREventArgs.cs
new file mode 100755 (executable)
index 0000000..4e7507b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.NUI
+{
+    /// <summary>
+    /// Event arguments that passed via the WebView.WebAuthDisplayQR.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class WebViewWebAuthDisplayQREventArgs : EventArgs
+    {
+        internal WebViewWebAuthDisplayQREventArgs(string contents)
+        {
+            Contents = contents;
+        }
+
+        /// <summary>
+        /// The string contents to make QR code image in user side.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public string Contents { get; }
+    }
+}
index 8edc0c59b6e1e06f950e3104a849d3921a954be8..12b5557724ed18dcf868dd93ef3e68135f439b0c 100755 (executable)
@@ -159,6 +159,14 @@ namespace Tizen.NUI.BaseComponents
 
         private PlainTextReceivedCallback plainTextReceivedCallback;
 
+        private EventHandler<WebViewWebAuthDisplayQREventArgs> webAuthDisplayQREventHandler;
+        private WebViewWebAuthDisplayQRCallback webAuthDisplayQRCallback;
+        private EventHandler webAuthResponseEventHandler;
+        private WebViewWebAuthResponseCallback webAuthResponseCallback;
+
+        private EventHandler<WebViewUserMediaPermissionRequestEventArgs> userMediaPermissionRequestEventHandler;
+        private WebViewUserMediaPermissionRequestCallback userMediaPermissionRequestCallback;
+
 
         /// <summary>
         /// Default constructor to create a WebView.
@@ -333,6 +341,10 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public delegate void GeolocationPermissionCallback(string host, string protocol);
 
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public delegate void UserMediaPermissionCallback(IntPtr permission);
+
         /// <summary>
         /// The callback function that is invoked when hit test is finished.
         /// </summary>
@@ -401,6 +413,16 @@ namespace Tizen.NUI.BaseComponents
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void WebViewTextFoundCallback(uint count);
 
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        private delegate void WebViewWebAuthDisplayQRCallback(string contents);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        private delegate void WebViewWebAuthResponseCallback();
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        private delegate void WebViewUserMediaPermissionRequestCallback(IntPtr permission, string message);
+       
+
         /// <summary>
         /// Event for the PageLoadStarted signal which can be used to subscribe or unsubscribe the event handler.<br />
         /// This signal is emitted when page loading has started.<br />
@@ -989,6 +1011,89 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        /// <summary>
+        /// Event to informs user application to display QR code popup for passkey scenario.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandler<WebViewWebAuthDisplayQREventArgs> WebAuthDisplayQR
+        {
+            add
+            {
+                if (webAuthDisplayQREventHandler == null)
+                {
+                    webAuthDisplayQRCallback = OnWebAuthDisplayQR;
+                    IntPtr ip = Marshal.GetFunctionPointerForDelegate(webAuthDisplayQRCallback);
+                    Interop.WebView.RegisterWebAuthDisplayQRCallback(SwigCPtr, new HandleRef(this, ip));
+                }
+                webAuthDisplayQREventHandler += value;
+            }
+            remove
+            {
+                webAuthDisplayQREventHandler -= value;
+                if (webAuthDisplayQREventHandler == null)
+                {
+                    IntPtr ip = IntPtr.Zero;
+                    Interop.WebView.RegisterWebAuthDisplayQRCallback(SwigCPtr, new HandleRef(this, ip));
+                }
+            }
+        }
+
+        /// <summary>
+        /// Event to informs user application that the passkey registration and authentication has been successful.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandler WebAuthResponse
+        {
+            add
+            {
+                if (webAuthResponseEventHandler == null)
+                {
+                    webAuthResponseCallback = OnWebAuthResponse;
+                    IntPtr ip = Marshal.GetFunctionPointerForDelegate(webAuthResponseCallback);
+                    Interop.WebView.RegisterWebAuthResponseCallback(SwigCPtr, new HandleRef(this, ip));
+                }
+                webAuthResponseEventHandler += value;
+            }
+            remove
+            {
+                webAuthResponseEventHandler -= value;
+                if (webAuthResponseEventHandler == null)
+                {
+                    IntPtr ip = IntPtr.Zero;
+                    Interop.WebView.RegisterWebAuthResponseCallback(SwigCPtr, new HandleRef(this, ip));
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// Event to UserMediaPermissionRequest.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandler<WebViewUserMediaPermissionRequestEventArgs> UserMediaPermissionRequest
+        {
+            add
+            {
+                if (userMediaPermissionRequestEventHandler == null)
+                {
+                    userMediaPermissionRequestCallback = OnUserMediaPermissionRequset;
+                    IntPtr ip = Marshal.GetFunctionPointerForDelegate(userMediaPermissionRequestCallback);
+                    Interop.WebView.RegisterUserMediaPermissionRequestCallback(SwigCPtr, new HandleRef(this, ip));
+                }
+                userMediaPermissionRequestEventHandler += value;
+            }
+            remove
+            {
+                userMediaPermissionRequestEventHandler -= value;
+                if (userMediaPermissionRequestEventHandler == null)
+                {
+                    IntPtr ip = IntPtr.Zero;
+                    Interop.WebView.RegisterUserMediaPermissionRequestCallback(SwigCPtr, new HandleRef(this, ip));
+                }
+            }
+        }
+
+
         /// <summary>
         /// Options for searching texts.
         /// </summary>
@@ -2854,6 +2959,16 @@ namespace Tizen.NUI.BaseComponents
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        /// <summary>
+        /// cancel in progress web authentication that is passkey operation.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void WebAuthenticationCancel()
+        {
+            Interop.WebView.WebAuthenticationCancel(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
         internal static WebView DownCast(BaseHandle handle)
         {
             WebView ret = new WebView(Interop.WebView.DownCast(BaseHandle.getCPtr(handle)), true);
@@ -3014,5 +3129,21 @@ namespace Tizen.NUI.BaseComponents
         {
             textFoundEventHandler?.Invoke(this, new WebViewTextFoundEventArgs(count));
         }
+
+        private void OnWebAuthDisplayQR(string contents)
+        {
+            webAuthDisplayQREventHandler?.Invoke(this, new WebViewWebAuthDisplayQREventArgs(contents));
+        }
+
+        private void OnWebAuthResponse()
+        {
+            webAuthResponseEventHandler?.Invoke(this, new EventArgs());
+        }
+
+        private void OnUserMediaPermissionRequset(IntPtr permission, string message)
+        {
+            userMediaPermissionRequestEventHandler?.Invoke(this, new WebViewUserMediaPermissionRequestEventArgs(new WebUserMediaPermissionRequest(permission, true), message));
+        }
+
     }
 }