[NUI][API10] Add a LoadContents API with byte array for WebView.
authorhuayong.xu <huayong.xu@samsung.com>
Tue, 4 Apr 2023 09:20:03 +0000 (17:20 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 6 Apr 2023 11:43:22 +0000 (20:43 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.WebView.cs
src/Tizen.NUI/src/internal/WebView/WebBackForwardList.cs
src/Tizen.NUI/src/internal/WebView/WebHttpRequestInterceptor.cs
src/Tizen.NUI/src/public/WebView/WebView.cs

index 794adc1..01c7d10 100755 (executable)
@@ -15,6 +15,8 @@
  *
  */
 
+using System.Runtime.InteropServices;
+
 namespace Tizen.NUI
 {
     internal static partial class Interop
@@ -122,6 +124,10 @@ namespace Tizen.NUI
             [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
             public static extern bool LoadContents(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, uint jarg3, string jarg4, string jarg5, string jarg6);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "CSharp_Dali_WebView_LoadContents")]
+            [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+            public static extern bool LoadContents(global::System.Runtime.InteropServices.HandleRef jarg1, [MarshalAs(UnmanagedType.LPArray)] byte[] jarg2, uint jarg3, string jarg4, string jarg5, string jarg6);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebView_Reload")]
             public static extern void Reload(global::System.Runtime.InteropServices.HandleRef jarg1);
 
index d4c8b5f..0e3f596 100755 (executable)
@@ -205,7 +205,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public IList<WebBackForwardListItem> GetForwardItems(int limit)
         {
-            System.IntPtr itemPtr = Interop.WebBackForwardList.GetBackwardItems(SwigCPtr, limit);
+            System.IntPtr itemPtr = Interop.WebBackForwardList.GetForwardItems(SwigCPtr, limit);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
             if (forwardItemList != null)
index b897f96..c5b0811 100755 (executable)
@@ -188,7 +188,7 @@ namespace Tizen.NUI
         /// This function can be used inside or outside WebContext.HttpRequestIntercepted.
         /// After this call, any further call on WebHttpRequestInterceptor results in undefined behavior.
         /// </summary>
-        /// <param name="body">Contents of response</param>
+        /// <param name="body">Contents of response. For UTF-8 encoding, body would be got like System.Text.Encoding.UTF8.GetString(...)</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool SetResponseBody(string body)
         {
@@ -223,7 +223,7 @@ namespace Tizen.NUI
         /// After this call, any further call on WebHttpRequestInterceptor results in undefined behavior.
         /// </summary>
         /// <param name="headers">Headers of response</param>
-        /// <param name="body">Contents of response</param>
+        /// <param name="body">Contents of response. For UTF-8 encoding, body would be got like System.Text.Encoding.UTF8.GetString(...)</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool SetResponse(string headers, string body)
         {
@@ -263,7 +263,7 @@ namespace Tizen.NUI
         /// After writing full response body in chunks using this function,
         /// call it again with null as chunk, to signal that response body is finished.
         /// </summary>
-        /// <param name="chunk">Chunk of response</param>
+        /// <param name="chunk">Chunk of response. For UTF-8 encoding, chunk would be got like System.Text.Encoding.UTF8.GetString(...)</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool WriteResponseChunk(string chunk)
         {
index 0358b7a..0ecc8f1 100755 (executable)
@@ -1115,6 +1115,7 @@ namespace Tizen.NUI.BaseComponents
 
         /// <summary>
         /// Background color of web page.
+        /// Please note that it only works after LoadUrl, etc.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public Color ContentBackgroundColor
@@ -1574,7 +1575,23 @@ namespace Tizen.NUI.BaseComponents
         /// <summary>
         /// Requests to load the given contents by MIME type.
         /// </summary>
-        /// <param name="contents">The contents to be loaded</param>
+        /// <param name="contents">The contents to be loaded in bytes</param>
+        /// <param name="mimeType">The type of contents, "text/html" is assumed if null</param>
+        /// <param name="encoding">The encoding for contents, "UTF-8" is assumed if null</param>
+        /// <param name="baseUri">The base URI to use for relative resources</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool LoadContents(byte[] contents, string mimeType, string encoding, string baseUri)
+        {
+            int length = contents != null ? contents.Length : 0;
+            bool result = Interop.WebView.LoadContents(SwigCPtr, contents, (uint)length, mimeType, encoding, baseUri);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return result;
+        }
+
+        /// <summary>
+        /// Requests to load the given contents by MIME type.
+        /// </summary>
+        /// <param name="contents">The contents to be loaded. For UTF-8 encoding, contents would be got like System.Text.Encoding.UTF8.GetString(...)</param>
         /// <param name="contentSize">The size of contents (in bytes)</param>
         /// <param name="mimeType">The type of contents, "text/html" is assumed if null</param>
         /// <param name="encoding">The encoding for contents, "UTF-8" is assumed if null</param>