2 Copyright (C) 2012 Samsung Electronics
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #include "ewk_history.h"
24 #include "WKAPICast.h"
26 #include "WKBackForwardList.h"
27 #include "WKBackForwardListItem.h"
28 #include "WKRetainPtr.h"
29 #include "ewk_history_private.h"
30 #include <wtf/text/CString.h>
32 using namespace WebKit;
35 WKBackForwardListRef wkBackForwardList;
37 Ewk_History_Item* item;
40 struct _Ewk_History_Item {
41 WKRetainPtr<WKBackForwardListItemRef> itemRef;
47 Ewk_History* ewkHistoryCreate(WKBackForwardListRef wkBackForwardList)
49 EINA_SAFETY_ON_NULL_RETURN_VAL(wkBackForwardList, 0);
51 Ewk_History* history = new Ewk_History;
53 history->wkBackForwardList = wkBackForwardList;
59 int ewk_history_back_list_length_get(Ewk_History* history)
61 EINA_SAFETY_ON_NULL_RETURN_VAL(history, 0);
63 return WKBackForwardListGetBackListCount(history->wkBackForwardList);
66 int ewk_history_forward_list_length_get(Ewk_History* history)
68 EINA_SAFETY_ON_NULL_RETURN_VAL(history, 0);
70 return WKBackForwardListGetForwardListCount(history->wkBackForwardList);
73 Ewk_History_Item* ewk_history_nth_item_get(Ewk_History* history, int index)
75 EINA_SAFETY_ON_NULL_RETURN_VAL(history, 0);
80 WKBackForwardListItemRef itemRef = WKBackForwardListGetItemAtIndex(history->wkBackForwardList, index);
84 history->item = new Ewk_History_Item;
85 history->item->itemRef = itemRef;
90 const char* ewk_history_item_uri_get(Ewk_History_Item* item)
92 EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0);
94 WKRetainPtr<WKURLRef> wkURI(AdoptWK, WKBackForwardListItemCopyURL(item->itemRef.get()));
96 if (toImpl(wkURI.get())->string().isEmpty())
99 item->uri = toImpl(wkURI.get())->string().utf8();
100 return item->uri.data();
103 const char* ewk_history_item_title_get(Ewk_History_Item* item)
105 EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0);
107 WKRetainPtr<WKStringRef> wkTitle(AdoptWK, WKBackForwardListItemCopyTitle(item->itemRef.get()));
109 if (toImpl(wkTitle.get())->string().isEmpty())
112 item->title = toImpl(wkTitle.get())->string().utf8();
113 return item->title.data();
116 void ewk_history_free(Ewk_History* history)
118 EINA_SAFETY_ON_NULL_RETURN(history);
121 delete history->item;
126 Eina_List* ewk_history_back_list_get(Ewk_History* history)
131 Eina_List* ewk_history_forward_list_get(Ewk_History* history)
136 void ewk_history_item_list_free(Eina_List* items)
140 #endif // #if OS(TIZEN)