936e3c4e177ed9e19569ad9e2d81c5f4566e9c4c
[platform/core/csapi/tizenfx.git] / src / Tizen.WebView / Tizen.WebView / BackForwardList.cs
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections;
19 using System.ComponentModel;
20 using System.Collections.Generic;
21
22 namespace Tizen.WebView
23 {
24     /// <summary>
25     /// This class provides the properties of Back Forward list item of a specific WebView.
26     /// </summary>
27     /// <since_tizen> 6 </since_tizen>
28     [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
29     public class BackForwardListItem
30     {
31         private IntPtr _item_handle;
32
33         /// <summary>
34         /// Creates a Back Forward List Item object.
35         /// </summary>
36         /// <since_tizen> 6 </since_tizen>
37         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
38         internal BackForwardListItem(IntPtr handle)
39         {
40             _item_handle = handle;
41         }
42
43         /// <summary>
44         /// Url of the back forward list item.
45         /// </summary>
46         /// <since_tizen> 6 </since_tizen>
47         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
48         public string Url
49         {
50             get
51             {
52                 return Interop.ChromiumEwk.ewk_back_forward_list_item_url_get(_item_handle);
53             }
54         }
55
56         /// <summary>
57         /// Title of the back forward list item.
58         /// </summary>
59         /// <since_tizen> 6 </since_tizen>
60         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
61         public string Title
62         {
63             get
64             {
65                 return Interop.ChromiumEwk.ewk_back_forward_list_item_title_get(_item_handle);
66             }
67         }
68
69         /// <summary>
70         /// Original Url of the back forward list item.
71         /// </summary>
72         /// <since_tizen> 6 </since_tizen>
73         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
74         public string OriginalUrl
75         {
76             get
77             {
78                 return Interop.ChromiumEwk.ewk_back_forward_list_item_original_url_get(_item_handle);
79             }
80         }
81     }
82
83     /// <summary>
84     /// This class provides the properties of Back Forward list of a specific WebView.
85     /// </summary>
86     /// <since_tizen> 6 </since_tizen>
87     [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
88     public class BackForwardList
89     {
90         private IntPtr _list_handle;
91
92         internal BackForwardList(IntPtr handle)
93         {
94             _list_handle = handle;
95         }
96
97         /// <summary>
98         /// Current item of the back forward list.
99         /// </summary>
100         /// <remarks>
101         /// BackForward List can be null if there is no current item.
102         /// </remarks>
103         /// <since_tizen> 6 </since_tizen>
104         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
105         public BackForwardListItem CurrentItem
106         {
107             get
108             {
109                 IntPtr itemPtr = Interop.ChromiumEwk.ewk_back_forward_list_current_item_get(_list_handle);
110                 if(itemPtr != null) {
111                     BackForwardListItem item = new BackForwardListItem(itemPtr);
112                     return item;
113                 }
114                 else {
115                    return null;
116                 }
117             }
118         }
119
120         /// <summary>
121         /// Previous item of the back forward list and null if no previous item.
122         /// </summary>
123         /// <remarks>
124         /// BackForward List can be null if there is no previous item.
125         /// </remarks>
126         /// <since_tizen> 6 </since_tizen>
127         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
128         public BackForwardListItem PreviousItem
129         {
130             get
131             {
132                 IntPtr itemPtr = Interop.ChromiumEwk.ewk_back_forward_list_previous_item_get(_list_handle);
133                 if(itemPtr != null) {
134                     BackForwardListItem item = new BackForwardListItem(itemPtr);
135                     return item;
136                 }
137                 else {
138                    return null;
139                 }
140             }
141         }
142
143         /// <summary>
144         /// Gets the back forward list count.
145         /// </summary>
146         /// <since_tizen> 6 </since_tizen>
147         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
148         public uint Count
149         {
150             get
151             {
152                 return Interop.ChromiumEwk.ewk_back_forward_list_count(_list_handle);
153             }
154         }
155         /// <summary>
156         /// Gets the list containing the items preceding the current item
157         /// limited by limit.
158         /// </summary>
159         /// <param name="limit"> limit The number of items to retrieve, if limit -1 all items preceding current item are returned.</param>
160         /// <returns>The list of the BackForwardListItem of back items.</returns>
161         /// <since_tizen> 6 </since_tizen>
162         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
163         public IList<BackForwardListItem> BackItems(int limit)
164         {
165             IntPtr list = Interop.ChromiumEwk.ewk_back_forward_list_n_back_items_copy(_list_handle, limit);
166             List<BackForwardListItem> backItemsList = new List<BackForwardListItem>();
167
168             var iter = Interop.Eina.eina_list_iterator_new(list);
169             for (IntPtr data; Interop.Eina.eina_iterator_next(iter, out data);) {
170               backItemsList.Add(new BackForwardListItem(data));
171             }
172
173             Interop.Eina.eina_iterator_free(iter);
174             Interop.Eina.eina_list_free(list);
175
176             return backItemsList;
177         }
178
179         /// <summary>
180         /// Gets the list containing the items following the current item
181         /// limited by limit.
182         /// </summary>
183         /// <param name="limit"> limit The number of items to retrieve, if limit is -1 all items following current item are returned.</param>
184         /// <returns>The list of the BackForwardListItem of forward items.</returns>
185         /// <since_tizen> 6 </since_tizen>
186         [Obsolete("Deprecated since API Level 10. Will be removed in API Level 12.")]
187         public IList<BackForwardListItem> ForwardItems(int limit)
188         {
189             IntPtr list = Interop.ChromiumEwk.ewk_back_forward_list_n_forward_items_copy(_list_handle, limit);
190             List<BackForwardListItem> forwardItemsList = new List<BackForwardListItem>();
191
192             var iter = Interop.Eina.eina_list_iterator_new(list);
193             for (IntPtr data; Interop.Eina.eina_iterator_next(iter, out data);) {
194               forwardItemsList.Add(new BackForwardListItem(data));
195             }
196
197             Interop.Eina.eina_iterator_free(iter);
198             Interop.Eina.eina_list_free(list);
199
200             return forwardItemsList;
201         }
202     }
203 }