[NUI] Implement WebView.GetPlainTextAsynchronously method (#3344)
authorJiyun Yang <ji.yang@samsung.com>
Mon, 26 Jul 2021 01:23:09 +0000 (10:23 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 26 Jul 2021 09:00:32 +0000 (18:00 +0900)
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs
src/Tizen.NUI/src/internal/WebView/WebView.cs

index 5a99892..52cd3ec 100755 (executable)
@@ -300,6 +300,9 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_RegisterContextMenuHiddenCallback")]
             public static extern void RegisterContextMenuHiddenCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+            [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);
         }
     }
 }
index 8bef486..7e511d1 100755 (executable)
@@ -88,6 +88,8 @@ namespace Tizen.NUI.BaseComponents
         private EventHandler<WebViewContextMenuHiddenEventArgs> contextMenuHiddenEventHandler;
         private WebViewContextMenuHiddenCallbackDelegate contextMenuHiddenCallback;
 
+        private PlainTextReceivedCallback plainTextReceivedCallback;
+
         /// <summary>
         /// Creates a WebView.
         /// </summary>
@@ -228,6 +230,13 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         public delegate void HitTestFinishedCallback(WebHitTestResult test);
 
+        /// <summary>
+        /// The callback function that is invoked when the plain text of the current page is received.
+        /// </summary>
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public delegate void PlainTextReceivedCallback(string plainText);
+
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void WebViewPageLoadCallbackDelegate(string pageUrl);
 
@@ -1943,6 +1952,20 @@ namespace Tizen.NUI.BaseComponents
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        /// <summary>
+        /// Get a plain text of current web page asynchronously.
+        /// Please note that it gets plain text of currently loaded page so please call this method after page load finished.
+        /// <param name="callback">The callback for getting plain text</param>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void GetPlainTextAsynchronously(PlainTextReceivedCallback callback)
+        {
+            plainTextReceivedCallback = callback;
+            System.IntPtr ip = Marshal.GetFunctionPointerForDelegate(plainTextReceivedCallback);
+            Interop.WebView.GetPlainTextAsynchronously(SwigCPtr, new HandleRef(this, ip));
+            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);