/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
namespace Tizen.WebView
{
///
/// This class provides the properties of Back Forward list item of a specific WebView.
///
/// 6
public class BackForwardListItem
{
private IntPtr _item_handle;
///
/// Creates a Back Forward List Item object.
///
/// 6
internal BackForwardListItem(IntPtr handle)
{
_item_handle = handle;
}
///
/// Url of the back forward list item.
///
/// 6
public string Url
{
get
{
return Interop.ChromiumEwk.ewk_back_forward_list_item_url_get(_item_handle);
}
}
///
/// Title of the back forward list item.
///
/// 6
public string Title
{
get
{
return Interop.ChromiumEwk.ewk_back_forward_list_item_title_get(_item_handle);
}
}
///
/// Original Url of the back forward list item.
///
/// 6
public string OriginalUrl
{
get
{
return Interop.ChromiumEwk.ewk_back_forward_list_item_original_url_get(_item_handle);
}
}
}
///
/// This class provides the properties of Back Forward list of a specific WebView.
///
/// 6
public class BackForwardList
{
private IntPtr _list_handle;
///
/// Creates a Back Forward List object.
///
/// 6
internal BackForwardList(IntPtr handle)
{
_list_handle = handle;
}
///
/// Current item of the back forward list.
///
///
/// BackForward List can be null if there is no current item.
///
/// 6
public BackForwardListItem CurrentItem
{
get
{
IntPtr itemPtr = Interop.ChromiumEwk.ewk_back_forward_list_current_item_get(_list_handle);
if(itemPtr != null) {
BackForwardListItem item = new BackForwardListItem(itemPtr);
return item;
}
else {
return null;
}
}
}
///
/// Previous item of the back forward list and null if no previous item.
///
///
/// BackForward List can be null if there is no previous item.
///
/// 6
public BackForwardListItem PreviousItem
{
get
{
IntPtr itemPtr = Interop.ChromiumEwk.ewk_back_forward_list_previous_item_get(_list_handle);
if(itemPtr != null) {
BackForwardListItem item = new BackForwardListItem(itemPtr);
return item;
}
else {
return null;
}
}
}
///
/// Gets the back forward list count.
///
/// 6
public uint Count
{
get
{
return Interop.ChromiumEwk.ewk_back_forward_list_count(_list_handle);
}
}
///
/// Gets the list containing the items preceding the current item
/// limited by limit.
///
/// limit The number of items to retrieve, if limit -1 all items preceding current item are returned.
/// The list of the BackForwardListItem of back items.
/// 6
public IList BackItems(int limit)
{
IntPtr list = Interop.ChromiumEwk.ewk_back_forward_list_n_back_items_copy(_list_handle, limit);
List backItemsList = new List();
var iter = Interop.Eina.eina_list_iterator_new(list);
for (IntPtr data; Interop.Eina.eina_iterator_next(iter, out data);) {
backItemsList.Add(new BackForwardListItem(data));
}
Interop.Eina.eina_iterator_free(iter);
Interop.Eina.eina_list_free(list);
return backItemsList;
}
///
/// Gets the list containing the items following the current item
/// limited by limit.
///
/// limit The number of items to retrieve, if limit is -1 all items following current item are returned.
/// The list of the BackForwardListItem of forward items.
/// 6
public IList ForwardItems(int limit)
{
IntPtr list = Interop.ChromiumEwk.ewk_back_forward_list_n_forward_items_copy(_list_handle, limit);
List forwardItemsList = new List();
var iter = Interop.Eina.eina_list_iterator_new(list);
for (IntPtr data; Interop.Eina.eina_iterator_next(iter, out data);) {
forwardItemsList.Add(new BackForwardListItem(data));
}
Interop.Eina.eina_iterator_free(iter);
Interop.Eina.eina_list_free(list);
return forwardItemsList;
}
}
}