'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',
#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"
#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));
}
}
-tizen_webview::BackForwardList* EWebView::GetBackForwardList() const {
+_Ewk_Back_Forward_List* EWebView::GetBackForwardList() const {
return back_forward_list_.get();
}
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) {
}
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_);
#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"
#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"
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);
#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_;
// 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 {
} // namespace back_forward_list
-} // namespace tizen_webview
-
-#endif // TW_BACK_FORWARD_LIST_H
+#endif // BACK_FORWARD_LIST_H
#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;
}
#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
#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];
}
#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
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)
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)
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)
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)
+++ /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 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
+++ /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 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
#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 {
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();
}
#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"
#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;
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();