[NUI] Add APIs of webview back forward list
authorzhouleonlei <zhouleon.lei@samsung.com>
Tue, 13 Apr 2021 06:47:41 +0000 (14:47 +0800)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Tue, 20 Apr 2021 06:13:00 +0000 (15:13 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.WebBackForwardList.cs
src/Tizen.NUI/src/internal/WebView/WebBackForwardList.cs

index 83aac7e..dc95638 100755 (executable)
@@ -29,18 +29,45 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardListItem_GetOriginalUrl")]
             public static extern string GetOriginalUrl(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_DeleteItem")]
+            public static extern void DeleteItem(global::System.Runtime.InteropServices.HandleRef jarg1);
+        }
+
+        internal static partial class WebBackForwardSubList
+        {
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_DeleteCopiedItems")]
+            public static extern void DeleteCopiedItems(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetCopiedItemsCount")]
+            public static extern uint GetItemCount(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetItemAtIndexFromCopiedItems")]
+            public static extern global::System.IntPtr GetItemAtIndex(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2);
         }
 
         internal static partial class WebBackForwardList
         {
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetItemCount")]
-            public static extern int GetItemCount(global::System.Runtime.InteropServices.HandleRef jarg1);
+            public static extern uint GetItemCount(global::System.Runtime.InteropServices.HandleRef jarg1);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetCurrentItem")]
             public static extern global::System.IntPtr GetCurrentItem(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetPreviousItem")]
+            public static extern global::System.IntPtr GetPreviousItem(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetNextItem")]
+            public static extern global::System.IntPtr GetNextItem(global::System.Runtime.InteropServices.HandleRef jarg1);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetItemAtIndex")]
             public static extern global::System.IntPtr GetItemAtIndex(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetBackwardItems")]
+            public static extern global::System.IntPtr GetBackwardItems(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WebBackForwardList_GetForwardItems")]
+            public static extern global::System.IntPtr GetForwardItems(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
         }
     }
 }
index 37d85c9..f799c7e 100755 (executable)
@@ -30,15 +30,20 @@ namespace Tizen.NUI
         {
         }
 
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+        {
+            Interop.WebBackForwardListItem.DeleteItem(swigCPtr);
+        }
+
         /// <summary>
         /// Get uri.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Uri Url
+        public string Url
         {
             get
             {
-                return new Uri(Interop.WebBackForwardListItem.GetUrl(SwigCPtr));
+                return Interop.WebBackForwardListItem.GetUrl(SwigCPtr);
             }
         }
 
@@ -58,16 +63,57 @@ namespace Tizen.NUI
         /// Get original url.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Uri OriginalUrl
+        public string OriginalUrl
         {
             get
             {
-                return new Uri(Interop.WebBackForwardListItem.GetOriginalUrl(SwigCPtr));
+                return Interop.WebBackForwardListItem.GetOriginalUrl(SwigCPtr);
             }
         }
     }
 
     /// <summary>
+    /// WebBackForwardSubList is a class for back-forward copied list item of web view.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class WebBackForwardSubList : Disposable
+    {
+        internal WebBackForwardSubList(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+        {
+        }
+
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+        {
+            Interop.WebBackForwardSubList.DeleteCopiedItems(swigCPtr);
+        }
+
+        /// <summary>
+        /// Get item count.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public uint ItemCount
+        {
+            get
+            {
+                return Interop.WebBackForwardSubList.GetItemCount(SwigCPtr);
+            }
+        }
+
+        /// <summary>
+        /// Get item with index.
+        /// </summary>
+        /// <param name="index">The index of list item.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public WebBackForwardListItem GetItemAtIndex(uint index)
+        {
+            System.IntPtr itemPtr = Interop.WebBackForwardSubList.GetItemAtIndex(SwigCPtr, index);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            WebBackForwardListItem ret = new WebBackForwardListItem(itemPtr, false);
+            return ret;
+        }
+    }
+
+    /// <summary>
     /// WebBackForwardList is a class for back-forward list of web view.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
@@ -81,7 +127,7 @@ namespace Tizen.NUI
         /// Get item count.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public int ItemCount
+        public uint ItemCount
         {
             get
             {
@@ -96,17 +142,72 @@ namespace Tizen.NUI
         public WebBackForwardListItem GetCurrentItem()
         {
             System.IntPtr itemPtr = Interop.WebBackForwardList.GetCurrentItem(SwigCPtr);
-            return new WebBackForwardListItem(itemPtr, false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            WebBackForwardListItem ret = new WebBackForwardListItem(itemPtr, true);
+            return ret;
         }
 
         /// <summary>
-        /// Get current item.
+        /// Get previous item.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public WebBackForwardListItem GetPreviousItem()
+        {
+            System.IntPtr itemPtr = Interop.WebBackForwardList.GetPreviousItem(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            WebBackForwardListItem ret = new WebBackForwardListItem(itemPtr, true);
+            return ret;
+        }
+
+        /// <summary>
+        /// Get next item.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
+        public WebBackForwardListItem GetNextItem()
+        {
+            System.IntPtr itemPtr = Interop.WebBackForwardList.GetNextItem(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            WebBackForwardListItem ret = new WebBackForwardListItem(itemPtr, true);
+            return ret;
+        }
+
+        /// <summary>
+        /// Get item with index.
+        /// </summary>
+        /// <param name="index">The index of list item.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public WebBackForwardListItem GetItemAtIndex(int index)
         {
             System.IntPtr itemPtr = Interop.WebBackForwardList.GetItemAtIndex(SwigCPtr, index);
-            return new WebBackForwardListItem(itemPtr, false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            WebBackForwardListItem ret = new WebBackForwardListItem(itemPtr, true);
+            return ret;
+        }
+
+        /// <summary>
+        /// Get copied backward items.
+        /// </summary>
+        /// <param name="index">limit The number of items to retrieve.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public WebBackForwardSubList GetBackwardItems(int index)
+        {
+            System.IntPtr itemPtr = Interop.WebBackForwardList.GetBackwardItems(SwigCPtr, index);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            WebBackForwardSubList ret = new WebBackForwardSubList(itemPtr, true);
+            return ret;
+        }
+
+        /// <summary>
+        /// Get copied forward items.
+        /// </summary>
+        /// <param name="index">limit The number of items to retrieve.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public WebBackForwardSubList GetForwardItems(int index)
+        {
+            System.IntPtr itemPtr = Interop.WebBackForwardList.GetBackwardItems(SwigCPtr, index);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            WebBackForwardSubList ret = new WebBackForwardSubList(itemPtr, true);
+            return ret;
         }
     }
 }