'efl_integration/private/api_static_check.cc',
'efl_integration/private/chromium_glue.cc',
'efl_integration/private/chromium_glue.h',
+ 'efl_integration/private/ewk_back_forward_list_private.h',
+ 'efl_integration/private/ewk_back_forward_list_private.cc',
'efl_integration/private/ewk_context_private.cc',
'efl_integration/private/ewk_context_private.h',
'efl_integration/private/ewk_hit_test_private.h',
--- /dev/null
+// Copyright 2014 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ewk_back_forward_list_private.h"
+
+_Ewk_Back_Forward_List* chromium_glue::from(
+ tizen_webview::BackForwardList* list) {
+ return static_cast<_Ewk_Back_Forward_List*>(list);
+}
+
+_Ewk_Back_Forward_List_Item* chromium_glue::from(
+ tizen_webview::BackForwardListItem* item) {
+ return static_cast<_Ewk_Back_Forward_List_Item*>(item);
+}
--- /dev/null
+// Copyright 2014 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EWK_BACK_FORWARD_LIST_PRIVATE_H
+#define EWK_BACK_FORWARD_LIST_PRIVATE_H
+
+#include <tizen_webview/public/tw_back_forward_list_impl.h>
+
+struct _Ewk_Back_Forward_List : public tizen_webview::BackForwardList {
+};
+
+struct _Ewk_Back_Forward_List_Item
+ : public tizen_webview::BackForwardListItem {
+};
+
+namespace chromium_glue {
+
+_Ewk_Back_Forward_List* from(tizen_webview::BackForwardList*);
+_Ewk_Back_Forward_List_Item* from(tizen_webview::BackForwardListItem*);
+
+}
+
+#endif // EWK_BACK_FORWARD_LIST_PRIVATE_H
#include "ewk_history_private.h"
-#if !defined(EWK_BRINGUP)
-
-_Ewk_History *chromium_glue::from(tizen_webview::BackForwardList *list) {
- return static_cast<_Ewk_History *>(list);
+_Ewk_History* chromium_glue::from(tizen_webview::BackForwardHistory* list) {
+ return static_cast<_Ewk_History*>(list);
}
-_Ewk_History_Item *chromium_glue::from(tizen_webview::BackForwardListItem *item) {
- return static_cast<_Ewk_History_Item *>(item);
+_Ewk_History_Item *chromium_glue::from(
+ tizen_webview::BackForwardHistoryItem* item) {
+ return static_cast<_Ewk_History_Item*>(item);
}
-
-#endif
#ifndef EWK_HISTORY_PRIVATE_H
#define EWK_HISTORY_PRIVATE_H
-#if !defined(EWK_BRINGUP)
+#include <tizen_webview/public/tw_back_forward_history.h>
-#include <tizen_webview/public/tw_back_forward_list.h>
-
-struct _Ewk_History : public tizen_webview::BackForwardList {
+struct _Ewk_History : public tizen_webview::BackForwardHistory {
};
-struct _Ewk_History_Item : public tizen_webview::BackForwardListItem {
+struct _Ewk_History_Item : public tizen_webview::BackForwardHistoryItem {
};
namespace chromium_glue {
-_Ewk_History *from(tizen_webview::BackForwardList *);
-_Ewk_History_Item *from(tizen_webview::BackForwardListItem *);
+_Ewk_History* from(tizen_webview::BackForwardHistory*);
+_Ewk_History_Item* from(tizen_webview::BackForwardHistoryItem*);
}
-#endif // EWK_BRINGUP
#endif // EWK_HISTORY_PRIVATE_H
*/
#include "ewk_back_forward_list.h"
-#include "private/ewk_private.h"
+#include "private/ewk_back_forward_list_private.h"
-#if defined(OS_TIZEN_TV)
Ewk_Back_Forward_List_Item* ewk_back_forward_list_current_item_get(const Ewk_Back_Forward_List* list)
{
- LOG_EWK_API_MOCKUP("for Tizen TV Browser");
- return NULL;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ return chromium_glue::from(static_cast<tizen_webview::BackForwardListItem *>(list->GetCurrentItem()));
+}
+
+Ewk_Back_Forward_List_Item *ewk_back_forward_list_previous_item_get(const Ewk_Back_Forward_List *list)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ return chromium_glue::from(static_cast<tizen_webview::BackForwardListItem *>(list->GetPrevItem()));
+}
+
+Ewk_Back_Forward_List_Item *ewk_back_forward_list_next_item_get(const Ewk_Back_Forward_List *list)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ return chromium_glue::from(static_cast<tizen_webview::BackForwardListItem *>(list->GetNextItem()));
+}
+
+Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_at_index_get(const Ewk_Back_Forward_List *list, int index)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ return chromium_glue::from(static_cast<tizen_webview::BackForwardListItem *>(list->GetItemAtIndex(index)));
+}
+
+unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List *list)
+{
+ // Maybe -1 would be better when list is NULL
+ // but 0 is here to be compliant with WebKit-EFL
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, 0);
+ return list->GetLength();
+}
+
+Eina_List *ewk_back_forward_list_n_back_items_copy(const Ewk_Back_Forward_List *list, int limit)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ int count = list->GetBackListLength();
+ if (limit > -1 && limit < count) {
+ count = limit;
+ }
+ Eina_List *result = NULL;
+ for (int i = 1; i <= count; ++i) {
+ result = eina_list_prepend(result, list->GetItemAtIndex(-i));
+ }
+ return result;
+}
+
+Eina_List *ewk_back_forward_list_n_forward_items_copy(const Ewk_Back_Forward_List *list, int limit)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
+ int count = list->GetForwardListLength();
+ if (limit > -1 && limit < count) {
+ count = limit;
+ }
+ Eina_List *result = NULL;
+ for (int i = 1; i <= count; ++i) {
+ result = eina_list_append(result, list->GetItemAtIndex(i));
+ }
+ return result;
}
-#endif // OS_TIZEN_TV
#endif
/** Creates a type name for Ewk_Back_Forward_List */
-typedef struct EwkBackForwardList Ewk_Back_Forward_List;
+typedef struct _Ewk_Back_Forward_List Ewk_Back_Forward_List;
/**
- * Returns the current item in the @a list.
- *
- * @param list the back-forward list instance
- *
- * @return the current item in the @a list or @c NULL in case of error
- */
+* Returns the current item in the @a list.
+*
+* @param list the back-forward list instance
+*
+* @return the current item in the @a list or @c NULL in case of error
+*/
EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_current_item_get(const Ewk_Back_Forward_List *list);
+/**
+* Returns the item that precedes the current item in the @a list.
+*
+* @param list the back-forward list instance
+*
+* @return the item that precedes the current item the @a list or @c NULL in case of error
+*/
+EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_previous_item_get(const Ewk_Back_Forward_List *list);
+
+/**
+* Returns the item that follows the current item in the @a list.
+*
+* @param list the back-forward list instance
+*
+* @return the item that follows the current item in the @a list or @c NULL in case of error
+*/
+EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_next_item_get(const Ewk_Back_Forward_List *list);
+
+/**
+* Returns the item at a given @a index relative to the current item.
+*
+* @param list the back-forward list instance
+* @param index the index of the item
+*
+* @return the item at a given @a index relative to the current item or @c NULL in case of error
+*/
+EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_at_index_get(const Ewk_Back_Forward_List *list, int index);
+
+/**
+* Returns the length of the back-forward list including current item.
+*
+* @param list the back-forward list instance
+*
+* @return the length of the back-forward list including current item or @c 0 in case of error
+*/
+EAPI unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List *list);
+
+/**
+* Creates the list containing the items preceding the current item limited by @a limit.
+*
+* The @c Ewk_Back_Forward_List_Item elements are located in the result list starting with the oldest one.
+* if @a limit is equal to @c -1 all the items preceding the current item are returned.
+*
+* @param list the back-forward list instance
+* @param limit the number of items to retrieve
+*
+* @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error,
+* the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref()
+* to free the items
+*/
+EAPI Eina_List *ewk_back_forward_list_n_back_items_copy(const Ewk_Back_Forward_List *list, int limit);
+
+/**
+* Creates the list containing the items following the current item limited by @a limit.
+*
+* The @c Ewk_Back_Forward_List_Item elements are located in the result list starting with the oldest one.
+* if @a limit is equal to @c -1 all the items preceding the current item are returned.
+*
+* @param list the back-forward list instance
+* @param limit the number of items to retrieve
+*
+* @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error,
+* the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref()
+* to free the items
+*/
+EAPI Eina_List *ewk_back_forward_list_n_forward_items_copy(const Ewk_Back_Forward_List *list, int limit);
+
+/**
+* Creates the list containing the items preceding the current item.
+*
+* The @c Ewk_Back_Forward_List_Item elements are located in the result list starting with the oldest one.
+*
+* @param list the back-forward list instance
+*
+* @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error,
+* the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref()
+* to free the items
+*
+* @see ewk_back_forward_list_n_back_items_copy
+*/
+#define ewk_back_forward_list_back_items_copy(list) \
+ ewk_back_forward_list_n_back_items_copy(list, -1)
+
+/**
+* Creates the list containing the items following the current item.
+*
+* The @c Ewk_Back_Forward_List_Item elements are located in the result list starting with the oldest one.
+*
+* @param list the back-forward list instance
+*
+* @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error,
+* the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref()
+* to free the items
+*
+* @see ewk_back_forward_list_n_forward_items_copy
+*/
+#define ewk_back_forward_list_forward_items_copy(list) \
+ ewk_back_forward_list_n_forward_items_copy(list, -1)
+
#ifdef __cplusplus
}
#endif
*/
#include "ewk_back_forward_list_item.h"
-#include "private/ewk_private.h"
+#include "private/ewk_back_forward_list_private.h"
-#if defined(OS_TIZEN_TV)
-const char* ewk_back_forward_list_item_original_url_get(const Ewk_Back_Forward_List_Item* item)
+Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_ref(Ewk_Back_Forward_List_Item *item)
{
- LOG_EWK_API_MOCKUP("for Tizen TV Browser");
- return NULL;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
+ item->AddRef();
+ return item;
+}
+
+void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item *item)
+{
+ EINA_SAFETY_ON_NULL_RETURN(item);
+ item->Release();
+}
+
+const char *ewk_back_forward_list_item_url_get(const Ewk_Back_Forward_List_Item *item)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
+ return eina_stringshare_add(item->GetURL().spec().c_str());
+}
+
+const char *ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item *item)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
+ return eina_stringshare_add(item->GetTitle().c_str());
+}
+
+const char *ewk_back_forward_list_item_original_url_get(const Ewk_Back_Forward_List_Item *item)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
+ return eina_stringshare_add(item->GetOriginalURL().spec().c_str());
}
-#endif // OS_TIZEN_TV
*
* @see Ewk_Object
*/
-typedef struct EwkObject Ewk_Back_Forward_List_Item;
+typedef struct _Ewk_Back_Forward_List_Item Ewk_Back_Forward_List_Item;
+
+/**
+ * Increases the reference count of the given object.
+ *
+ * @param item the back-forward list item instance to increase the reference count
+ *
+ * @return a pointer to the object on success, @c NULL otherwise.
+ */
+EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_ref(Ewk_Back_Forward_List_Item *item);
+
+/**
+ * Decreases the reference count of the given object, possibly freeing it.
+ *
+ * When the reference count reaches 0, the item is freed.
+ *
+ * @param item the back-forward list item instance to decrease the reference count
+ */
+EAPI void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item *item);
+
+/**
+ * Returns URL of the item.
+ *
+ * The returned URL may differ from the original URL (For example if the page was redirected).
+ *
+ * @see ewk_back_forward_list_item_original_url_get()
+ *
+ * @param item the back-forward list item instance
+ *
+ * @return the URL of the @a item or @c NULL in case of error. This pointer is
+ * guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use
+ * eina_stringshare_ref() instead of eina_stringshare_add() or
+ * strdup()
+ */
+EAPI const char *ewk_back_forward_list_item_url_get(const Ewk_Back_Forward_List_Item *item);
+
+/**
+ * Returns title of the item.
+ *
+ * @param item the back-forward list item instance
+ *
+ * @return the title of the @a item or @c NULL in case of error. This pointer is
+ * guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use
+ * eina_stringshare_ref() instead of eina_stringshare_add() or
+ * strdup()
+ */
+EAPI const char *ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item *item);
/**
* Returns original URL of the item.
-// Copyright 2012 Samsung Electronics. All rights reserved.
+// Copyright 2014 Samsung Electronics. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#if !defined(EWK_BRINGUP)
-
#include "ewk_history.h"
#include "private/ewk_private.h"
#include "private/ewk_history_private.h"
// returning -1 here would be better to indicate the error
// but we need to stick to the WebKit-EFL implementation
EINA_SAFETY_ON_NULL_RETURN_VAL(history, 0);
- history->GetBackListLength();
+ return history->GetBackListLength();
}
int ewk_history_forward_list_length_get(Ewk_History* history)
Ewk_History_Item* ewk_history_nth_item_get(Ewk_History* history, int index)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(history, NULL);
- return chromium_glue::from(history->GetItemAtIndex(index));
+ return chromium_glue::from(static_cast<tizen_webview::BackForwardHistoryItem *>(history->GetItemAtIndex(index)));
}
const char* ewk_history_item_uri_get(Ewk_History_Item* item)
EINA_SAFETY_ON_NULL_RETURN(history);
delete history;
}
-
-#endif
#ifndef ewk_history
#define ewk_history
-#if !defined(EWK_BRINGUP)
-
#include <Eina.h>
#include "ewk_export.h"
}
#endif
-#endif // EWK_BRINGUP
-
#endif // ewk_history
/*
* Copyright (C) 2009-2010 ProFUSION embedded systems
- * Copyright (C) 2009-2013 Samsung Electronics. All rights reserved.
+ * Copyright (C) 2009-2014 Samsung Electronics. All rights reserved.
* Copyright (C) 2012 Intel Corporation
*
* This library is free software; you can redistribute it and/or
#include "private/ewk_private.h"
#if !defined(EWK_BRINGUP)
#include "private/ewk_quota_permission_request_private.h"
-#include "private/ewk_history_private.h"
#endif
-#include "private/ewk_view_private.h"
#include "private/chromium_glue.h"
+#include "private/ewk_back_forward_list_private.h"
+#include "private/ewk_history_private.h"
#include "private/ewk_view_private.h"
using tizen_webview::WebView;
return impl->AsyncRequestHitTestDataAt(x, y, chromium_glue::to(static_cast<Ewk_Hit_Test_Mode>(hit_test_mode)), chromium_glue::to(callback), user_data);
}
-#if !defined(EWK_BRINGUP)
Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
{
EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
- return chromium_glue::from(impl->GetBackForwardList());
+ return chromium_glue::from(impl->GetBackForwardHistory());
}
-#endif
Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
{
return false;
}
-#if defined(OS_TIZEN_TV)
Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
{
- LOG_EWK_API_MOCKUP("for Tizen TV Browser");
- return NULL;
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
+ return chromium_glue::from(impl->GetBackForwardList());
}
-#endif
void ewk_view_draw_focus_ring_enable_set(Evas_Object* ewkView, Eina_Bool enable)
{
'selection_magnifier_efl.h',
# tizen_webview
#TODO: making separate gyp for tizen_webview
+ 'tizen_webview/public/tw_back_forward_history.h',
+ 'tizen_webview/public/tw_back_forward_history.cc',
+ 'tizen_webview/public/tw_back_forward_list.h',
+ 'tizen_webview/public/tw_back_forward_list_impl.h',
+ 'tizen_webview/public/tw_back_forward_list_impl.cc',
'tizen_webview/public/tw_content_security_policy.h',
'tizen_webview/public/tw_context_menu_controller.h',
'tizen_webview/public/tw_context_menu_controller.cc',
}
web_contents_delegate_.reset(new WebContentsDelegateEfl(this));
web_contents_->SetDelegate(web_contents_delegate_.get());
+ back_forward_list_.reset(new tizen_webview::BackForwardList(
+ web_contents_->GetController()));
// Activate Event handler
evas_event_handler_->BindFocusEventHandlers();
}
}
- if (entry_removed)
+ if (entry_removed) {
+ back_forward_list_->ClearCache();
InvokeBackForwardListChangedCallback();
+ }
+}
+
+tizen_webview::BackForwardList* EWebView::GetBackForwardList() const {
+ return back_forward_list_.get();
}
void EWebView::InvokeBackForwardListChangedCallback() {
SmartCallback<EWebViewCallbacks::BackForwardListChange>().call();
}
+tizen_webview::BackForwardHistory* EWebView::GetBackForwardHistory() const {
+ return new tizen_webview::BackForwardHistory(web_contents_->GetController());
+}
+
bool EWebView::WebAppCapableGet(tizen_webview::Web_App_Capable_Get_Callback callback, void *userData) {
RenderViewHost *renderViewHost = web_contents_->GetRenderViewHost();
if (!renderViewHost) {
#include "browser/selectpicker/popup_picker.h"
#endif
+#include "tizen_webview/public/tw_back_forward_history.h"
+#include "tizen_webview/public/tw_back_forward_list_impl.h"
#include "tizen_webview/public/tw_hit_test.h"
#include "tizen_webview/public/tw_touch_event.h"
#include "tizen_webview/public/tw_callbacks.h"
const char* GetTitle();
bool SaveAsPdf(int width, int height, const std::string& file_name);
void BackForwardListClear();
+ tizen_webview::BackForwardList* GetBackForwardList() const;
void InvokeBackForwardListChangedCallback();
+ tizen_webview::BackForwardHistory* GetBackForwardHistory() const;
bool WebAppCapableGet(tizen_webview::Web_App_Capable_Get_Callback callback, void *userData);
bool WebAppIconUrlGet(tizen_webview::Web_App_Icon_URL_Get_Callback callback, void *userData);
bool WebAppIconUrlsGet(tizen_webview::Web_App_Icon_URLs_Get_Callback callback, void *userData);
bool is_initialized_;
std::map<int64_t, AsyncHitTestRequest*> m_pendingAsyncHitTests;
+ scoped_ptr<tizen_webview::BackForwardList> back_forward_list_;
private:
// only tizen_webview::WebView can create and delete this
--- /dev/null
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tw_back_forward_history.h"
+
+namespace tizen_webview {
+
+BackForwardHistory::BackForwardHistory(
+ content::NavigationController &controller)
+ : current_index_(controller.GetCurrentEntryIndex()) {
+ int cnt = controller.GetEntryCount();
+ if (cnt) {
+ items_.resize(cnt, 0);
+ for (int i = 0; i < cnt; ++i) {
+ BackForwardHistoryItem* item = new BackForwardHistoryItem(
+ controller.GetEntryAtIndex(i));
+ items_[i] = item;
+ }
+ }
+}
+
+BackForwardHistory::~BackForwardHistory() {
+ for (unsigned i = 0; i < items_.size(); ++i) {
+ delete items_[i];
+ }
+}
+
+int BackForwardHistory::GetCurrentIndex() const {
+ return current_index_;
+}
+
+int BackForwardHistory::GetLength() const {
+ return items_.size();
+}
+
+int BackForwardHistory::GetBackListLength() const {
+ return current_index_ < 0 ? 0 : current_index_;
+}
+
+int BackForwardHistory::GetForwardListLength() const {
+ return items_.size() - current_index_ - 1;
+}
+
+back_forward_list::Item* BackForwardHistory::GetItemAtIndex(int index) const {
+ int actualIndex = index + current_index_;
+ if (actualIndex < 0 || actualIndex >= static_cast<int>(items_.size())) {
+ return 0;
+ }
+ return items_[actualIndex];
+}
+
+}
--- /dev/null
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TW_BACK_FORWARD_HISTORY_H
+#define TW_BACK_FORWARD_HISTORY_H
+
+#include "tw_back_forward_list.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
+
+namespace tizen_webview {
+
+
+class BackForwardHistoryItem :
+ public back_forward_list::Item {
+ public:
+ BackForwardHistoryItem(content::NavigationEntry* entry) {
+ if (entry) {
+ url_ = entry->GetURL();
+ original_url_ = entry->GetUserTypedURL();
+ title_ = base::UTF16ToUTF8(entry->GetTitle());
+ }
+ }
+
+ const GURL& GetURL() const {
+ return url_;
+ }
+
+ const GURL& GetOriginalURL() const {
+ return original_url_;
+ }
+
+ const std::string& GetTitle() const {
+ return title_;
+ }
+
+ private:
+ GURL url_;
+ GURL original_url_;
+ std::string title_;
+};
+
+class BackForwardHistory :
+ public back_forward_list::List {
+ public:
+ BackForwardHistory(content::NavigationController &controller);
+ ~BackForwardHistory();
+
+ int GetCurrentIndex() const;
+ int GetLength() const;
+ int GetBackListLength() const;
+ int GetForwardListLength() const;
+ back_forward_list::Item* GetItemAtIndex(int index) const;
+
+ private:
+ const int current_index_;
+ std::vector<BackForwardHistoryItem*> items_;
+};
+
+}
+
+#endif // TW_BACK_FORWARD_HISTORY_H
--- /dev/null
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TW_BACK_FORWARD_LIST_H
+#define TW_BACK_FORWARD_LIST_H
+
+#include "url/gurl.h"
+
+namespace tizen_webview {
+
+namespace back_forward_list {
+
+class Item {
+ public:
+ virtual ~Item() {}
+ // Returns actually loaded URL.
+ virtual const GURL& GetURL() const = 0;
+ // Returns user typed URL.
+ virtual const GURL& GetOriginalURL() const = 0;
+ // Returns page title.
+ virtual const std::string& GetTitle() const = 0;
+};
+
+class List {
+ public:
+ virtual ~List() {}
+ // Returns current position in back-forward list
+ // which is -1 when list is empty.
+ virtual int GetCurrentIndex() const = 0;
+
+ // Returns the length of the list.
+ virtual int GetLength() const = 0;
+
+ // Returns number of back items available from
+ // current position.
+ // Returns 0 when the list is empty - to be compatible
+ // with WebKit-EFL implementation.
+ virtual int GetBackListLength() const = 0;
+
+ // Returns number od forward items available from
+ // current position.
+ // Returns 0 when the list is empty - to be compatible
+ // with WebKit-EFL implementation.
+ virtual int GetForwardListLength() const = 0;
+
+ // Returns item at given index, while index 0 points to
+ // the current item, back items are returned for negative indices
+ // and forward items are returned for positive indices.
+ virtual Item* GetItemAtIndex(int index) const = 0;
+
+ // Returns item preceding current item.
+ virtual Item* GetPrevItem() const {
+ return GetItemAtIndex(-1);
+ }
+
+ // Returns item following current item.
+ virtual Item* GetNextItem() const {
+ return GetItemAtIndex(1);
+ }
+
+ // Returns current item.
+ virtual Item* GetCurrentItem() const {
+ return GetItemAtIndex(0);
+ }
+};
+
+} // namespace back_forward_list
+
+} // namespace tizen_webview
+
+#endif // TW_BACK_FORWARD_LIST_H
--- /dev/null
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/navigation_details.h"
+#include "tizen_webview/public/tw_back_forward_list_impl.h"
+
+namespace tizen_webview {
+
+BackForwardList::BackForwardList(content::NavigationController &controller)
+ : navigation_controller_(controller) {
+ notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED,
+ content::NotificationService::AllBrowserContextsAndSources());
+ notification_registrar_.Add(this,
+ content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
+ content::NotificationService::AllBrowserContextsAndSources());
+ notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
+ content::NotificationService::AllBrowserContextsAndSources());
+}
+
+int BackForwardList::GetCurrentIndex() const {
+ return navigation_controller_.GetCurrentEntryIndex();
+}
+
+int BackForwardList::GetLength() const {
+ return navigation_controller_.GetEntryCount();
+}
+
+int BackForwardList::GetBackListLength() const {
+ int current = navigation_controller_.GetCurrentEntryIndex();
+ return current < 0 ? 0 : current;
+}
+
+int BackForwardList::GetForwardListLength() const {
+ int current = navigation_controller_.GetCurrentEntryIndex();
+ return navigation_controller_.GetEntryCount() - current - 1;
+}
+
+back_forward_list::Item* BackForwardList::GetItemAtIndex(int index) const {
+ index += navigation_controller_.GetCurrentEntryIndex();
+ int count = navigation_controller_.GetEntryCount();
+ if (index < 0 || index >= count) {
+ return NULL;
+ }
+ return FindOrCreateItem(index);
+}
+
+void BackForwardList::NewPageCommited(int prev_entry_index,
+ content::NavigationEntry* new_entry) {
+ int current = prev_entry_index + 1;
+ if (current != navigation_controller_.GetCurrentEntryIndex()) {
+ return;
+ }
+
+ // When user went back several pages and now loaded
+ // some new page (so new entry is commited) then all forward items
+ // were deleted, so we have to do the same in our cache.
+ for (unsigned i = current; i < indexes_.size(); ++i) {
+ content::NavigationEntry* entry = indexes_[i];
+ indexes_[i] = NULL;
+ if (entry) {
+ cache_.erase(entry);
+ }
+ }
+
+ InsertEntryToIndexes(current, new_entry);
+ cache_[new_entry] = scoped_refptr<BackForwardListItem>(new BackForwardListItem(new_entry));
+}
+
+void BackForwardList::UpdateItemWithEntry(
+ const content::NavigationEntry* entry) {
+ if (entry) {
+ CacheMap::iterator it = cache_.find(entry);
+ if (it != cache_.end()) {
+ it->second->Update(entry);
+ }
+ }
+}
+
+void BackForwardList::ClearCache() {
+ indexes_.clear();
+ cache_.clear();
+}
+
+void BackForwardList::Observe(int type,
+ const content::NotificationSource &source,
+ const content::NotificationDetails &details) {
+ switch (static_cast<content::NotificationType>(type)) {
+ case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
+ content::Details<content::LoadCommittedDetails> d = details;
+ NewPageCommited(d->previous_entry_index, d->entry);
+ break;
+ }
+ case content::NOTIFICATION_NAV_ENTRY_CHANGED: {
+ content::Details<content::EntryChangedDetails> d = details;
+ const content::NavigationEntry* entry = d->changed_entry;
+ UpdateItemWithEntry(entry);
+ break;
+ }
+ case content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED: {
+ content::Details<std::pair<content::NavigationEntry*, bool> > d = details;
+ const content::NavigationEntry* entry = d->first;
+ UpdateItemWithEntry(entry);
+ break;
+ }
+ default: {
+ return;
+ }
+ }
+}
+
+BackForwardListItem* BackForwardList::FindOrCreateItem(int index) const {
+ content::NavigationEntry* entry =
+ navigation_controller_.GetEntryAtIndex(index);
+
+ if (!entry) {
+ return NULL;
+ }
+
+ BackForwardListItem* item = NULL;
+ CacheMap::iterator it = cache_.find(entry);
+ if (it != cache_.end()) {
+ // item already in cache
+ item = it->second.get();
+ } else {
+ // need to create new item
+ item = new BackForwardListItem(entry);
+ cache_[entry] = scoped_refptr<BackForwardListItem>(item);
+ }
+
+ InsertEntryToIndexes(index, entry);
+
+ return item;
+}
+
+void BackForwardList::InsertEntryToIndexes(
+ unsigned index, content::NavigationEntry* entry) const {
+ if (index == indexes_.size()) {
+ indexes_.push_back(entry);
+ return;
+ }
+
+ if (index > indexes_.size()) {
+ indexes_.resize(index + 1, NULL);
+ }
+ indexes_[index] = entry;
+}
+
+} // namespace tizen_webview
--- /dev/null
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TW_BACK_FORWARD_LIST_IMPL_H
+#define TW_BACK_FORWARD_LIST_IMPL_H
+
+#include "tw_back_forward_list.h"
+#include "base/memory/ref_counted.h"
+#include "base/strings/string16.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+#include <map>
+
+namespace tizen_webview {
+
+class BackForwardListItem :
+ public back_forward_list::Item,
+ public base::RefCounted<BackForwardListItem> {
+ public:
+ BackForwardListItem(content::NavigationEntry* entry) {
+ Update(entry);
+ }
+
+ void Update(const content::NavigationEntry* entry) {
+ if (entry) {
+ url_ = entry->GetURL();
+ original_url_ = entry->GetUserTypedURL();
+ title_ = base::UTF16ToUTF8(entry->GetTitle());
+ }
+ }
+
+ const GURL& GetURL() const {
+ return url_;
+ }
+
+ const GURL& GetOriginalURL() const {
+ return original_url_;
+ }
+
+ const std::string& GetTitle() const {
+ return title_;
+ }
+
+ private:
+ GURL url_;
+ GURL original_url_;
+ std::string title_;
+};
+
+class BackForwardList :
+ public back_forward_list::List,
+ public content::NotificationObserver {
+ public:
+ typedef std::map<const content::NavigationEntry*,
+ scoped_refptr<BackForwardListItem> > CacheMap;
+
+ BackForwardList(content::NavigationController &controller);
+ ~BackForwardList() {}
+
+ int GetCurrentIndex() const;
+ int GetLength() const;
+ int GetBackListLength() const;
+ int GetForwardListLength() const;
+ back_forward_list::Item* GetItemAtIndex(int index) const;
+
+ void NewPageCommited(int prev_entry_index,
+ content::NavigationEntry* new_entry);
+ void UpdateItemWithEntry(const content::NavigationEntry* entry);
+ void ClearCache();
+
+ void Observe(int type, const content::NotificationSource &source,
+ const content::NotificationDetails &details);
+
+ private:
+ BackForwardListItem* FindOrCreateItem(int index) const;
+ void InsertEntryToIndexes(unsigned index,
+ content::NavigationEntry* entry) const;
+
+ private:
+ content::NavigationController &navigation_controller_;
+ content::NotificationRegistrar notification_registrar_;
+ mutable CacheMap cache_;
+ mutable std::vector<content::NavigationEntry*> indexes_;
+};
+
+}
+
+#endif // TW_BACK_FORWARD_LIST_IMPL_H
return impl_->BackForwardListClear();
}
+BackForwardList* WebView::GetBackForwardList() const {
+ return impl_->GetBackForwardList();
+}
+
+BackForwardHistory* WebView::GetBackForwardHistory() const {
+ return impl_->GetBackForwardHistory();
+}
+
const char* WebView::GetTitle() {
return impl_->GetTitle();
}
#include <Evas.h>
#include <string>
#include <map>
+#include "tizen_webview/public/tw_back_forward_history.h"
+#include "tizen_webview/public/tw_back_forward_list_impl.h"
#include "tizen_webview/public/tw_callbacks.h"
#include "tizen_webview/public/tw_content_security_policy.h"
#include "tizen_webview/public/tw_hit_test.h"
bool CanGoBack();
bool CanGoForward();
void BackForwardListClear();
+ BackForwardList* GetBackForwardList() const;
+ BackForwardHistory* GetBackForwardHistory() const;
// ---- Contents
const char* GetTitle();