Back-forward list implementation.
authorTomasz Czekala <t.czekala@partner.samsung.com>
Wed, 12 Nov 2014 12:41:27 +0000 (13:41 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Following EWK API functions were implemented in this commit:
1.  ewk_view_back_forward_list_get
2.  ewk_back_forward_list_item_url_get
3.  ewk_back_forward_list_item_unref
4.  ewk_back_forward_list_item_title_get
5.  ewk_back_forward_list_item_ref
6.  ewk_back_forward_list_item_original_url_get
7.  ewk_back_forward_list_previous_item_get
8.  ewk_back_forward_list_next_item_get
9.  ewk_back_forward_list_n_forward_items_copy
10. ewk_back_forward_list_n_back_items_copy
11. ewk_back_forward_list_current_item_get
12. ewk_back_forward_list_count
13. ewk_back_forward_list_item_at_index_get
These functions are a C wrappers on a C++ implementation in chromium-efl

This commit is a merge of 3 patches made by Filip Piechocki:
Ibc45f932d7bfc98837bd330fcf9c2c4f886410d2
 f4fdf69e5c40b8e3b0dc78dd3cfa13bf97561aec
I2fc1871a9f34a9f5fa7038e10e666767b9a90e5c
 df2b2cd674e289ebd00a5f7415e7163ae7e24eca
Ia153812ecb5ba4942be89e7f483e83704f26cbc2
 50aa4c9308f63bfdde5dea042eb7b1cd98d33c3c

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=8237
Reviewed by: SeungSeop Park, Viatcheslav Ostapenko

Change-Id: I9b70d36e7bfae57c9ad4afec0434c383b3f2ecc8
Signed-off-by: Tomasz Czekala <t.czekala@partner.samsung.com>
22 files changed:
tizen_src/ewk/chromium-ewk.gyp
tizen_src/ewk/efl_integration/private/ewk_back_forward_list_private.cc [new file with mode: 0644]
tizen_src/ewk/efl_integration/private/ewk_back_forward_list_private.h [new file with mode: 0644]
tizen_src/ewk/efl_integration/private/ewk_history_private.cc
tizen_src/ewk/efl_integration/private/ewk_history_private.h
tizen_src/ewk/efl_integration/public/ewk_back_forward_list.cc
tizen_src/ewk/efl_integration/public/ewk_back_forward_list.h
tizen_src/ewk/efl_integration/public/ewk_back_forward_list_item.cc
tizen_src/ewk/efl_integration/public/ewk_back_forward_list_item.h
tizen_src/ewk/efl_integration/public/ewk_history.cc
tizen_src/ewk/efl_integration/public/ewk_history.h
tizen_src/ewk/efl_integration/public/ewk_view.cc
tizen_src/impl/chromium-efl.gyp
tizen_src/impl/eweb_view.cc
tizen_src/impl/eweb_view.h
tizen_src/impl/tizen_webview/public/tw_back_forward_history.cc [new file with mode: 0644]
tizen_src/impl/tizen_webview/public/tw_back_forward_history.h [new file with mode: 0644]
tizen_src/impl/tizen_webview/public/tw_back_forward_list.h [new file with mode: 0644]
tizen_src/impl/tizen_webview/public/tw_back_forward_list_impl.cc [new file with mode: 0644]
tizen_src/impl/tizen_webview/public/tw_back_forward_list_impl.h [new file with mode: 0644]
tizen_src/impl/tizen_webview/public/tw_webview.cc
tizen_src/impl/tizen_webview/public/tw_webview.h

index 9cd472e83eabe2331191f33909ec80b15230e6cb..677657856889ac2d224d93e527274ad7e7352659 100644 (file)
       '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',
diff --git a/tizen_src/ewk/efl_integration/private/ewk_back_forward_list_private.cc b/tizen_src/ewk/efl_integration/private/ewk_back_forward_list_private.cc
new file mode 100644 (file)
index 0000000..bc0edf8
--- /dev/null
@@ -0,0 +1,15 @@
+// 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);
+}
diff --git a/tizen_src/ewk/efl_integration/private/ewk_back_forward_list_private.h b/tizen_src/ewk/efl_integration/private/ewk_back_forward_list_private.h
new file mode 100644 (file)
index 0000000..647620a
--- /dev/null
@@ -0,0 +1,24 @@
+// 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
index d9b5cd5a0ded2fc81ca8880c02980fab4063b8aa..674125148efc8b39ef462ce3e28b987fff850056 100644 (file)
@@ -4,14 +4,11 @@
 
 #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
index 021b4ffe30c5cb90033ec892223dd79058007555..259684fb2d7d57bea330de37d9d72f10ee8bc828 100644 (file)
@@ -5,22 +5,19 @@
 #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
index 395ec6e9fe405c1e96d727d8fc07ffe335429d70..3546d9552a59d5aca4eb4e3171afbcf224f89423 100644 (file)
  */
 
 #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
index 16622ebf1dc83be06aa177272a5d75a3aacfe08e..edaa89de17bb4bf207e09231b79aa131d02c53d3 100644 (file)
@@ -40,17 +40,116 @@ extern "C" {
 #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
index 85b52f48a5025ec1e31def631a62f89a23f17d8d..6a0f298f109debd7cff1bdaccfa274b4bdd9a573 100644 (file)
  */
 
 #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
index ad1633f4f09a9a5b8132545df621ff2fbc80e50e..d9344317ab17fb4c5fe805c89e7c3bd70142d5cc 100644 (file)
@@ -44,7 +44,55 @@ extern "C" {
  *
  * @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.
index 8d7ed2241c0e427531a929e86f99094be024ab7a..8c34fab0ecf00d1d6bbd82ca70a460d100568822 100644 (file)
@@ -1,9 +1,7 @@
-// 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"
@@ -14,7 +12,7 @@ int ewk_history_back_list_length_get(Ewk_History* history)
   // 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)
@@ -28,7 +26,7 @@ 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)
@@ -50,5 +48,3 @@ void ewk_history_free(Ewk_History* history)
   EINA_SAFETY_ON_NULL_RETURN(history);
   delete history;
 }
-
-#endif
index d7648f3a5bad6951b91edb0d24407f7e5a8ed797..274899f66c8536030fa89a400e0d8416d5b8e7fe 100644 (file)
@@ -10,8 +10,6 @@
 #ifndef ewk_history
 #define ewk_history
 
-#if !defined(EWK_BRINGUP)
-
 #include <Eina.h>
 #include "ewk_export.h"
 
@@ -84,6 +82,4 @@ EAPI void ewk_history_free(Ewk_History* history);
 }
 #endif
 
-#endif // EWK_BRINGUP
-
 #endif // ewk_history
index 4d54426fc44bc5cdb5baaa1dc0f7d7cbf8cc998f..19530a7b864813b0216c7b7c34cf3436da2532d4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * 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;
@@ -634,13 +634,11 @@ Eina_Bool ewk_view_hit_test_request(Evas_Object* o, int x, int y, int hit_test_m
   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)
 {
@@ -993,13 +991,11 @@ Eina_Bool ewk_view_split_scroll_overflow_enabled_set(Evas_Object* ewkView, const
   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)
 {
index db31a443b6a608c43e0bfda14397b37d93961485..06e21dcf297e84c35599d4c88450ff90f251b01d 100644 (file)
       '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',
index d7efc668d0cb99509209360e6c9f12e8a7f78675..f1de228937d9198a1d59da2f010bbdfd207ba36e 100644 (file)
@@ -290,6 +290,8 @@ void EWebView::Initialize() {
   }
   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();
@@ -1348,14 +1350,24 @@ void EWebView::BackForwardListClear() {
     }
   }
 
-  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) {
index 7252dcea29581c4d895e4771bfa6c440377baf39..73c568e6fb9c59ff779ce33178d4297fce1e7aec 100644 (file)
@@ -55,6 +55,8 @@
 #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"
@@ -323,7 +325,9 @@ class EWebView {
   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);
@@ -485,6 +489,7 @@ class EWebView {
   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
diff --git a/tizen_src/impl/tizen_webview/public/tw_back_forward_history.cc b/tizen_src/impl/tizen_webview/public/tw_back_forward_history.cc
new file mode 100644 (file)
index 0000000..5968489
--- /dev/null
@@ -0,0 +1,53 @@
+// 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];
+}
+
+}
diff --git a/tizen_src/impl/tizen_webview/public/tw_back_forward_history.h b/tizen_src/impl/tizen_webview/public/tw_back_forward_history.h
new file mode 100644 (file)
index 0000000..9f78548
--- /dev/null
@@ -0,0 +1,64 @@
+// 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
diff --git a/tizen_src/impl/tizen_webview/public/tw_back_forward_list.h b/tizen_src/impl/tizen_webview/public/tw_back_forward_list.h
new file mode 100644 (file)
index 0000000..6543dec
--- /dev/null
@@ -0,0 +1,72 @@
+// 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
diff --git a/tizen_src/impl/tizen_webview/public/tw_back_forward_list_impl.cc b/tizen_src/impl/tizen_webview/public/tw_back_forward_list_impl.cc
new file mode 100644 (file)
index 0000000..17d69f8
--- /dev/null
@@ -0,0 +1,151 @@
+// 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
diff --git a/tizen_src/impl/tizen_webview/public/tw_back_forward_list_impl.h b/tizen_src/impl/tizen_webview/public/tw_back_forward_list_impl.h
new file mode 100644 (file)
index 0000000..b297ae0
--- /dev/null
@@ -0,0 +1,93 @@
+// 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
index e80f821c7a12c941b97ce0371efcfc61f6886003..5e7188c6610634c2dd61b9d1694f16030ea41ec0 100644 (file)
@@ -173,6 +173,14 @@ void WebView::BackForwardListClear() {
   return impl_->BackForwardListClear();
 }
 
+BackForwardList* WebView::GetBackForwardList() const {
+  return impl_->GetBackForwardList();
+}
+
+BackForwardHistory* WebView::GetBackForwardHistory() const {
+  return impl_->GetBackForwardHistory();
+}
+
 const char* WebView::GetTitle() {
   return impl_->GetTitle();
 }
index c7d34f63f78d15da2e0f8570e9296f4f4410dfe3..a8def808d88cf0f2cb5f76358a18d5e1363b5ede 100644 (file)
@@ -9,6 +9,8 @@
 #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"
@@ -93,6 +95,8 @@ class WebView {
   bool CanGoBack();
   bool CanGoForward();
   void BackForwardListClear();
+  BackForwardList* GetBackForwardList() const;
+  BackForwardHistory* GetBackForwardHistory() const;
 
   // ---- Contents
   const char* GetTitle();