Remove tw_back_forward_list_impl.h and tw_back_forward_history.h
authorArnaud Renevier <a.renevier@samsung.com>
Thu, 12 Mar 2015 23:57:12 +0000 (16:57 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Use _Ewk_Back_Forward_List struct directly instead of
tizen_webview::BackForwardList. And use +_Ewk_History struct instead of
tizen_webview::BackForwardHistory

Change-Id: I881ff0623cd096ac53188506355517a0f8ed7302
Signed-off-by: Arnaud Renevier <a.renevier@samsung.com>
Signed-off-by: hh4813.kim <hh4813.kim@samsung.com>
17 files changed:
tizen_src/ewk/efl_integration/efl_integration.gypi
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/private/back_forward_list.h [moved from tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_list.h with 92% similarity]
tizen_src/ewk/efl_integration/private/ewk_back_forward_list_private.cc
tizen_src/ewk/efl_integration/private/ewk_back_forward_list_private.h
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_history.cc
tizen_src/ewk/efl_integration/public/ewk_view.cc
tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_history.cc [deleted file]
tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_history.h [deleted file]
tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_list_impl.cc [deleted file]
tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_list_impl.h [deleted file]
tizen_src/ewk/efl_integration/tizen_webview/public/tw_webview.cc
tizen_src/ewk/efl_integration/tizen_webview/public/tw_webview.h

index bcc7257..4a3d78a 100644 (file)
       'common/web_contents_utils.h',
 
       'private/api_static_check.cc',
+      'private/back_forward_list.h',
       'private/chromium_glue.cc',
       'private/chromium_glue.h',
       'private/ewk_auth_challenge_private.h',
 
       'tizen_webview/public/tw_settings.h',
       'tizen_webview/public/tw_legacy_font_size_mode.h',
-      'tizen_webview/public/tw_back_forward_list_impl.cc',
       'tizen_webview/public/tw_find_options.h',
       'tizen_webview/public/tw_context_menu_controller.cc',
-      'tizen_webview/public/tw_back_forward_list.h',
       'tizen_webview/public/tw_policy_decision.cc',
       'tizen_webview/public/tw_touch_point.h',
       'tizen_webview/public/tw_webview_delegate.cc',
       'tizen_webview/public/tw_selection_controller.cc',
       'tizen_webview/public/tw_hit_test.h',
       'tizen_webview/public/tw_web_context.h',
-      'tizen_webview/public/tw_back_forward_history.h',
       #'tizen_webview/public/tw_webview_evas_event_handler.h',
       #'tizen_webview/public/tw_webview_evas_event_handler.cc',
       'tizen_webview/public/tw_webview.h',
       'tizen_webview/public/tw_webview.cc',
       'tizen_webview/public/tw_web_context.cc',
       'tizen_webview/public/tw_error.h',
-      'tizen_webview/public/tw_back_forward_history.cc',
-      'tizen_webview/public/tw_back_forward_list_impl.h',
       'tizen_webview/public/tw_content_security_policy.h',
       'tizen_webview/public/tw_cookie_accept_policy.h',
       'tizen_webview/public/tw_policy_decision.h',
index c818bfe..768feb7 100644 (file)
@@ -14,6 +14,7 @@
 #include "common/web_contents_utils.h"
 #include "components/sessions/serialized_navigation_entry.h"
 #include "components/sessions/content/content_serialized_navigation_builder.h"
+#include "private/ewk_back_forward_list_private.h"
 #include "private/ewk_frame_private.h"
 #include "private/ewk_policy_decision_private.h"
 #include "private/ewk_settings_private.h"
@@ -387,7 +388,7 @@ void EWebView::Initialize() {
 #ifdef TIZEN_EDGE_EFFECT
   edge_effect_ = EdgeEffect::create(evas_object_);
 #endif
-  back_forward_list_.reset(new tizen_webview::BackForwardList(
+  back_forward_list_.reset(new _Ewk_Back_Forward_List(
       web_contents_->GetController()));
 
   geolocation_permission_cb_.reset(new WebViewGeolocationPermissionCallback(NULL, NULL));
@@ -1792,7 +1793,7 @@ void EWebView::BackForwardListClear() {
   }
 }
 
-tizen_webview::BackForwardList* EWebView::GetBackForwardList() const {
+_Ewk_Back_Forward_List* EWebView::GetBackForwardList() const {
   return back_forward_list_.get();
 }
 
@@ -1800,8 +1801,8 @@ void EWebView::InvokeBackForwardListChangedCallback() {
   SmartCallback<EWebViewCallbacks::BackForwardListChange>().call();
 }
 
-tizen_webview::BackForwardHistory* EWebView::GetBackForwardHistory() const {
-  return new tizen_webview::BackForwardHistory(web_contents_->GetController());
+_Ewk_History* EWebView::GetBackForwardHistory() const {
+  return new _Ewk_History(web_contents_->GetController());
 }
 
 bool EWebView::WebAppCapableGet(tizen_webview::Web_App_Capable_Get_Callback callback, void *userData) {
@@ -2298,11 +2299,11 @@ void EWebView::InitializeContent() {
   }
   web_contents_delegate_.reset(new WebContentsDelegateEfl(this));
   web_contents_->SetDelegate(web_contents_delegate_.get());
-  back_forward_list_.reset(new tizen_webview::BackForwardList(
+  back_forward_list_.reset(new _Ewk_Back_Forward_List(
       web_contents_->GetController()));
 
   back_forward_list_.reset(
-    new tizen_webview::BackForwardList(web_contents_->GetController()));
+    new _Ewk_Back_Forward_List(web_contents_->GetController()));
 
   native_view_ = static_cast<Evas_Object*>(web_contents_->GetNativeView());
   evas_object_smart_member_add(native_view_, evas_object_);
index e166946..71ad4f3 100644 (file)
 #include "context_menu_controller_efl.h"
 #include "eweb_context.h"
 #include "ewk_touch.h"
+#include "private/ewk_history_private.h"
 #include "private/ewk_hit_test_private.h"
 #include "private/ewk_auth_challenge_private.h"
+#include "private/ewk_back_forward_list_private.h"
 #include "private/ewk_settings_private.h"
 #include "private/ewk_web_application_icon_data_private.h"
 #include "eweb_view_callbacks.h"
@@ -59,8 +61,6 @@
 #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_callbacks.h"
 #include "tizen_webview/public/tw_content_security_policy.h"
@@ -392,9 +392,9 @@ class EWebView {
   const char* GetTitle();
   bool SaveAsPdf(int width, int height, const std::string& file_name);
   void BackForwardListClear();
-  tizen_webview::BackForwardList* GetBackForwardList() const;
+  _Ewk_Back_Forward_List* GetBackForwardList() const;
   void InvokeBackForwardListChangedCallback();
-  tizen_webview::BackForwardHistory* GetBackForwardHistory() const;
+  _Ewk_History* 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);
@@ -572,7 +572,7 @@ class EWebView {
 #endif
   bool is_initialized_;
 
-  scoped_ptr<tizen_webview::BackForwardList> back_forward_list_;
+  scoped_ptr<_Ewk_Back_Forward_List> back_forward_list_;
 
   static content::WebContentsDelegate::WebContentsCreateCallback
       create_new_window_web_contents_cb_;
@@ -2,13 +2,11 @@
 // 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
+#ifndef BACK_FORWARD_LIST_H
+#define BACK_FORWARD_LIST_H
 
 #include "url/gurl.h"
 
-namespace tizen_webview {
-
 namespace back_forward_list {
 
 class Item {
@@ -67,6 +65,4 @@ class List {
 
 } // namespace back_forward_list
 
-} // namespace tizen_webview
-
-#endif // TW_BACK_FORWARD_LIST_H
+#endif // BACK_FORWARD_LIST_H
index bc0edf8..b6106fd 100644 (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);
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/navigation_details.h"
+
+_Ewk_Back_Forward_List::_Ewk_Back_Forward_List(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 _Ewk_Back_Forward_List::GetCurrentIndex() const {
+  return navigation_controller_.GetCurrentEntryIndex();
+}
+
+int _Ewk_Back_Forward_List::GetLength() const {
+  return navigation_controller_.GetEntryCount();
+}
+
+int _Ewk_Back_Forward_List::GetBackListLength() const {
+  int current = navigation_controller_.GetCurrentEntryIndex();
+  return current < 0 ? 0 : current;
+}
+
+int _Ewk_Back_Forward_List::GetForwardListLength() const {
+  int current = navigation_controller_.GetCurrentEntryIndex();
+  return navigation_controller_.GetEntryCount() - current - 1;
+}
+
+back_forward_list::Item* _Ewk_Back_Forward_List::GetItemAtIndex(int index) const {
+  index += navigation_controller_.GetCurrentEntryIndex();
+  int count = navigation_controller_.GetEntryCount();
+  if (index < 0 || index >= count) {
+    return NULL;
+  }
+  return FindOrCreateItem(index);
+}
+
+void _Ewk_Back_Forward_List::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<_Ewk_Back_Forward_List_Item>(new _Ewk_Back_Forward_List_Item(new_entry));
+}
+
+void _Ewk_Back_Forward_List::UpdateItemWithEntry(
+    const content::NavigationEntry* entry) {
+  if (entry) {
+    CacheMap::iterator it = cache_.find(entry);
+    if (it != cache_.end()) {
+      it->second->Update(entry);
+    }
+  }
+}
+
+void _Ewk_Back_Forward_List::ClearCache() {
+  indexes_.clear();
+  cache_.clear();
+}
+
+void _Ewk_Back_Forward_List::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;
+    }
+  }
 }
 
-_Ewk_Back_Forward_List_Item* chromium_glue::from(
-    tizen_webview::BackForwardListItem* item) {
-  return static_cast<_Ewk_Back_Forward_List_Item*>(item);
+_Ewk_Back_Forward_List_Item* _Ewk_Back_Forward_List::FindOrCreateItem(int index) const {
+  content::NavigationEntry* entry =
+      navigation_controller_.GetEntryAtIndex(index);
+
+  if (!entry) {
+    return NULL;
+  }
+
+  _Ewk_Back_Forward_List_Item* 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 _Ewk_Back_Forward_List_Item(entry);
+    cache_[entry] = scoped_refptr<_Ewk_Back_Forward_List_Item>(item);
+  }
+
+  InsertEntryToIndexes(index, entry);
+
+  return item;
+}
+
+void _Ewk_Back_Forward_List::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;
 }
index 647620a..713d4cd 100644 (file)
@@ -5,20 +5,85 @@
 #ifndef EWK_BACK_FORWARD_LIST_PRIVATE_H
 #define EWK_BACK_FORWARD_LIST_PRIVATE_H
 
-#include <tizen_webview/public/tw_back_forward_list_impl.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 "private/back_forward_list.h"
 
-struct _Ewk_Back_Forward_List : public tizen_webview::BackForwardList {
-};
+#include <map>
+
+class _Ewk_Back_Forward_List_Item :
+    public back_forward_list::Item,
+    public base::RefCounted<_Ewk_Back_Forward_List_Item> {
+ public:
+  _Ewk_Back_Forward_List_Item(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 override {
+    return url_;
+  }
+
+  const GURL& GetOriginalURL() const override {
+    return original_url_;
+  }
+
+  const std::string& GetTitle() const override {
+    return title_;
+  }
 
-struct _Ewk_Back_Forward_List_Item
-    : public tizen_webview::BackForwardListItem {
+ private:
+  GURL url_;
+  GURL original_url_;
+  std::string title_;
 };
 
-namespace chromium_glue {
+class _Ewk_Back_Forward_List :
+    public back_forward_list::List,
+    public content::NotificationObserver {
+ public:
+  typedef std::map<const content::NavigationEntry*,
+      scoped_refptr<_Ewk_Back_Forward_List_Item> > CacheMap;
 
-_Ewk_Back_Forward_List* from(tizen_webview::BackForwardList*);
-_Ewk_Back_Forward_List_Item* from(tizen_webview::BackForwardListItem*);
+  _Ewk_Back_Forward_List(content::NavigationController &controller);
+  ~_Ewk_Back_Forward_List() {}
 
-}
+  int GetCurrentIndex() const override;
+  int GetLength() const override;
+  int GetBackListLength() const override;
+  int GetForwardListLength() const override;
+  back_forward_list::Item* GetItemAtIndex(int index) const override;
+
+  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) override;
+
+ private:
+  _Ewk_Back_Forward_List_Item* 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 // EWK_BACK_FORWARD_LIST_PRIVATE_H
index 6741251..a7a7af0 100644 (file)
@@ -4,11 +4,46 @@
 
 #include "ewk_history_private.h"
 
-_Ewk_History* chromium_glue::from(tizen_webview::BackForwardHistory* list) {
-  return static_cast<_Ewk_History*>(list);
+_Ewk_History::_Ewk_History(
+    content::NavigationController &controller)
+    : current_index_(controller.GetCurrentEntryIndex()) {
+  int cnt = controller.GetEntryCount();
+  if (cnt) {
+    items_.resize(cnt, 0);
+    for (int i = 0; i < cnt; ++i) {
+      _Ewk_History_Item* item = new _Ewk_History_Item(
+          controller.GetEntryAtIndex(i));
+      items_[i] = item;
+    }
+  }
 }
 
-_Ewk_History_Item *chromium_glue::from(
-    tizen_webview::BackForwardHistoryItem* item) {
-  return static_cast<_Ewk_History_Item*>(item);
+_Ewk_History::~_Ewk_History() {
+  for (unsigned i = 0; i < items_.size(); ++i) {
+    delete items_[i];
+  }
+}
+
+int _Ewk_History::GetCurrentIndex() const {
+  return current_index_;
+}
+
+int _Ewk_History::GetLength() const {
+  return items_.size();
+}
+
+int _Ewk_History::GetBackListLength() const {
+  return current_index_ < 0 ? 0 : current_index_;
+}
+
+int _Ewk_History::GetForwardListLength() const {
+  return items_.size() - current_index_ - 1;
+}
+
+back_forward_list::Item* _Ewk_History::GetItemAtIndex(int index) const {
+  int actualIndex = index + current_index_;
+  if (actualIndex < 0 || actualIndex >= static_cast<int>(items_.size())) {
+    return 0;
+  }
+  return items_[actualIndex];
 }
index 259684f..a247597 100644 (file)
@@ -5,19 +5,57 @@
 #ifndef EWK_HISTORY_PRIVATE_H
 #define EWK_HISTORY_PRIVATE_H
 
-#include <tizen_webview/public/tw_back_forward_history.h>
-
-struct _Ewk_History : public tizen_webview::BackForwardHistory {
+#include "base/strings/utf_string_conversions.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
+#include "private/back_forward_list.h"
+
+class _Ewk_History_Item :
+    public back_forward_list::Item {
+ public:
+  _Ewk_History_Item(content::NavigationEntry* entry) {
+    if (entry) {
+      url_ = entry->GetURL();
+      original_url_ = entry->GetUserTypedURL();
+      title_ = base::UTF16ToUTF8(entry->GetTitle());
+    }
+  }
+
+  const GURL& GetURL() const override {
+    return url_;
+  }
+
+  const GURL& GetOriginalURL() const override {
+    return original_url_;
+  }
+
+  const std::string& GetTitle() const override {
+    return title_;
+  }
+
+ private:
+  GURL url_;
+  GURL original_url_;
+  std::string title_;
 };
 
-struct _Ewk_History_Item : public tizen_webview::BackForwardHistoryItem {
-};
 
-namespace chromium_glue {
+class _Ewk_History :
+    public back_forward_list::List {
+ public:
+  _Ewk_History(content::NavigationController &controller);
+  ~_Ewk_History();
 
-_Ewk_History* from(tizen_webview::BackForwardHistory*);
-_Ewk_History_Item* from(tizen_webview::BackForwardHistoryItem*);
+  int GetCurrentIndex() const override;
+  int GetLength() const override;
+  int GetBackListLength() const override;
+  int GetForwardListLength() const override;
+  back_forward_list::Item* GetItemAtIndex(int index) const override;
+
+ private:
+  const int current_index_;
+  std::vector<_Ewk_History_Item*> items_;
+};
 
-}
 
 #endif // EWK_HISTORY_PRIVATE_H
index 3546d95..f11d46d 100644 (file)
 Ewk_Back_Forward_List_Item* ewk_back_forward_list_current_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->GetCurrentItem()));
+  return static_cast<_Ewk_Back_Forward_List_Item *>(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()));
+  return static_cast<_Ewk_Back_Forward_List_Item *>(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()));
+  return static_cast<_Ewk_Back_Forward_List_Item *>(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)));
+  return static_cast<_Ewk_Back_Forward_List_Item *>(list->GetItemAtIndex(index));
 }
 
 unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List *list)
index 8c34fab..27eb4ac 100644 (file)
@@ -26,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(static_cast<tizen_webview::BackForwardHistoryItem *>(history->GetItemAtIndex(index)));
+  return static_cast<_Ewk_History_Item *>(history->GetItemAtIndex(index));
 }
 
 const char* ewk_history_item_uri_get(Ewk_History_Item* item)
index 4711abe..3053345 100644 (file)
@@ -644,7 +644,7 @@ Eina_Bool ewk_view_hit_test_request(Evas_Object* o, int x, int y, int hit_test_m
 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
 {
   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
-  return chromium_glue::from(impl->GetBackForwardHistory());
+  return impl->GetBackForwardHistory();
 }
 
 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* notification_list)
@@ -977,7 +977,7 @@ Eina_Bool ewk_view_split_scroll_overflow_enabled_set(Evas_Object* ewkView, const
 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
 {
   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, NULL);
-  return chromium_glue::from(impl->GetBackForwardList());
+  return impl->GetBackForwardList();
 }
 
 void ewk_view_notification_permission_callback_set(Evas_Object *o, Ewk_View_Notification_Permission_Callback callback, void *user_data)
diff --git a/tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_history.cc b/tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_history.cc
deleted file mode 100644 (file)
index 5968489..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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/ewk/efl_integration/tizen_webview/public/tw_back_forward_history.h b/tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_history.h
deleted file mode 100644 (file)
index a825f3b..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// 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 override {
-    return url_;
-  }
-
-  const GURL& GetOriginalURL() const override {
-    return original_url_;
-  }
-
-  const std::string& GetTitle() const override {
-    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 override;
-  int GetLength() const override;
-  int GetBackListLength() const override;
-  int GetForwardListLength() const override;
-  back_forward_list::Item* GetItemAtIndex(int index) const override;
-
- private:
-  const int current_index_;
-  std::vector<BackForwardHistoryItem*> items_;
-};
-
-}
-
-#endif // TW_BACK_FORWARD_HISTORY_H
diff --git a/tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_list_impl.cc b/tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_list_impl.cc
deleted file mode 100644 (file)
index 17d69f8..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-// 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/ewk/efl_integration/tizen_webview/public/tw_back_forward_list_impl.h b/tizen_src/ewk/efl_integration/tizen_webview/public/tw_back_forward_list_impl.h
deleted file mode 100644 (file)
index 8e77666..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-// 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 override {
-    return url_;
-  }
-
-  const GURL& GetOriginalURL() const override {
-    return original_url_;
-  }
-
-  const std::string& GetTitle() const override {
-    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 override;
-  int GetLength() const override;
-  int GetBackListLength() const override;
-  int GetForwardListLength() const override;
-  back_forward_list::Item* GetItemAtIndex(int index) const override;
-
-  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) override;
-
- 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 5d34dba..654683f 100644 (file)
@@ -10,6 +10,8 @@
 #include <base/memory/scoped_ptr.h>
 
 #include "content/browser/renderer_host/render_widget_host_view_efl.h"
+#include "private/ewk_back_forward_list_private.h"
+#include "private/ewk_history_private.h"
 #include <tizen_webview/public/tw_webview_delegate.h>
 
 namespace {
@@ -187,11 +189,11 @@ void WebView::BackForwardListClear() {
   return impl_->BackForwardListClear();
 }
 
-BackForwardList* WebView::GetBackForwardList() const {
+_Ewk_Back_Forward_List* WebView::GetBackForwardList() const {
   return impl_->GetBackForwardList();
 }
 
-BackForwardHistory* WebView::GetBackForwardHistory() const {
+_Ewk_History* WebView::GetBackForwardHistory() const {
   return impl_->GetBackForwardHistory();
 }
 
index a907dfb..c7947ed 100644 (file)
@@ -12,8 +12,6 @@
 
 #include "base/macros.h"
 #include "content/public/browser/navigation_controller.h"
-#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"
@@ -22,6 +20,8 @@
 #include "third_party/WebKit/public/web/WebViewModeEnums.h"
 
 // TODO: Remove this dependency
+class _Ewk_Back_Forward_List;
+class _Ewk_History;
 class Ewk_Settings;
 class WebContentDelegateEfl;
 struct SelectionStylePrams;
@@ -96,8 +96,8 @@ class WebView {
   bool CanGoBack();
   bool CanGoForward();
   void BackForwardListClear();
-  BackForwardList* GetBackForwardList() const;
-  BackForwardHistory* GetBackForwardHistory() const;
+  _Ewk_Back_Forward_List* GetBackForwardList() const;
+  _Ewk_History* GetBackForwardHistory() const;
 
   // ---- Contents
   const char* GetTitle();