[NUI] Add an API for create,window event.
authorhuayong.xu <huayong.xu@samsung.com>
Thu, 5 Jan 2023 06:18:33 +0000 (14:18 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 17 Jan 2023 08:40:26 +0000 (17:40 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs
src/Tizen.NUI/src/public/WebView/WebView.cs

index b3cf6c1..794adc1 100755 (executable)
@@ -286,6 +286,9 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterNavigationPolicyDecidedCallback")]
             public static extern void RegisterNavigationPolicyDecidedCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterNewWindowCreatedCallback")]
+            public static extern void RegisterNewWindowCreatedCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterCertificateConfirmedCallback")]
             public static extern void RegisterCertificateConfirmedCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
index a1e3e9b..0358b7a 100755 (executable)
@@ -73,6 +73,9 @@ namespace Tizen.NUI.BaseComponents
         private EventHandler<WebViewPolicyDecidedEventArgs> navigationPolicyDecidedEventHandler;
         private WebViewPolicyDecidedCallback navigationPolicyDecidedCallback;
 
+        private EventHandlerWithReturnType<object, EventArgs, WebView> newWindowCreatedEventHandler;
+        private WebViewNewWindowCreatedCallback newWindowCreatedCallback;
+
         private EventHandler<WebViewCertificateReceivedEventArgs> certificateConfirmedEventHandler;
         private WebViewCertificateReceivedCallback certificateConfirmedCallback;
 
@@ -265,6 +268,9 @@ namespace Tizen.NUI.BaseComponents
         private delegate void WebViewPolicyDecidedCallback(IntPtr maker);
 
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        private delegate void WebViewNewWindowCreatedCallback(out IntPtr outView);
+
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void WebViewCertificateReceivedCallback(IntPtr certificate);
 
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
@@ -510,6 +516,29 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Event for the NewWindowCreated signal which can be used to subscribe or unsubscribe the event handler.<br />
+        /// This signal is emitted when a new window would be created.<br />
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandlerWithReturnType<object, EventArgs, WebView> NewWindowCreated
+        {
+            add
+            {
+                if (newWindowCreatedEventHandler == null)
+                {
+                    newWindowCreatedCallback = OnNewWindowCreated;
+                    System.IntPtr ip = Marshal.GetFunctionPointerForDelegate(newWindowCreatedCallback);
+                    Interop.WebView.RegisterNewWindowCreatedCallback(SwigCPtr, new HandleRef(this, ip));
+                }
+                newWindowCreatedEventHandler += value;
+            }
+            remove
+            {
+                newWindowCreatedEventHandler -= value;
+            }
+        }
+
+        /// <summary>
         /// Event for the CertificateConfirmed signal which can be used to subscribe or unsubscribe the event handler.<br />
         /// This signal is emitted when certificate would be confirmed.<br />
         /// </summary>
@@ -2154,6 +2183,12 @@ namespace Tizen.NUI.BaseComponents
             navigationPolicyDecidedEventHandler?.Invoke(this, new WebViewPolicyDecidedEventArgs(new WebPolicyDecisionMaker(maker, true)));
         }
 
+        private void OnNewWindowCreated(out IntPtr viewHandle)
+        {
+            WebView view = newWindowCreatedEventHandler?.Invoke(this, new EventArgs());
+            viewHandle = (IntPtr)view.SwigCPtr;
+        }
+
         private void OnCertificateConfirmed(IntPtr certificate)
         {
             certificateConfirmedEventHandler?.Invoke(this, new WebViewCertificateReceivedEventArgs(new WebCertificate(certificate, true)));