From a8982eb904a434b37f04099492960962d3c2423e Mon Sep 17 00:00:00 2001 From: Yi Shen Date: Tue, 27 May 2014 14:02:29 -0700 Subject: [PATCH] Add Tizen-platform implementation of of RenderMessageFilter Change-Id: If70df236256c5e96504a86361733864d77054352 --- .../render_message_filter_efl.cc | 77 +++++++++++++++++++ .../renderer_host/render_message_filter_efl.h | 57 ++++++++++++++ tizen_src/impl/chromium-efl.gyp | 2 + 3 files changed, 136 insertions(+) create mode 100644 tizen_src/impl/browser/renderer_host/render_message_filter_efl.cc create mode 100644 tizen_src/impl/browser/renderer_host/render_message_filter_efl.h diff --git a/tizen_src/impl/browser/renderer_host/render_message_filter_efl.cc b/tizen_src/impl/browser/renderer_host/render_message_filter_efl.cc new file mode 100644 index 000000000000..c78dae8b5e4b --- /dev/null +++ b/tizen_src/impl/browser/renderer_host/render_message_filter_efl.cc @@ -0,0 +1,77 @@ +/* + Copyright (C) 2014 Samsung Electronics + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "browser/renderer_host/render_message_filter_efl.h" + +#include "common/web_contents_utils.h" +#include "common/render_messages_efl.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "net/url_request/url_request_context_getter.h" +#include "web_contents_delegate_efl.h" + +using web_contents_utils::WebContentsFromViewID; +using content::BrowserThread; + +RenderMessageFilterEfl::RenderMessageFilterEfl(int render_process_id) + : BrowserMessageFilter(ChromeMsgStart) + , render_process_id_(render_process_id) { +} + +RenderMessageFilterEfl::~RenderMessageFilterEfl() { } + +void RenderMessageFilterEfl::OverrideThreadForMessage(const IPC::Message& message, + content::BrowserThread::ID* thread) +{ + if(message.type() == EwkHostMsg_DecideNavigationPolicy::ID) + *thread = content::BrowserThread::UI; +} + +bool RenderMessageFilterEfl::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(RenderMessageFilterEfl, message) + IPC_MESSAGE_HANDLER(EwkHostMsg_DecideNavigationPolicy, OnDecideNavigationPolicy) + IPC_MESSAGE_HANDLER(EwkViewHostMsg_HitTestReply, OnReceivedHitTestData) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void RenderMessageFilterEfl::OnDecideNavigationPolicy(NavigationPolicyParams params, bool* handled) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + if (content::WebContents* web_contents = + WebContentsFromViewID(render_process_id_, params.render_view_id)) { + content::WebContentsDelegateEfl* delegate = + static_cast(web_contents->GetDelegate()); + // delegate replies directly + delegate->web_view()->InvokePolicyNavigationCallback(web_contents->GetRenderViewHost(), params, handled); + } +} + +void RenderMessageFilterEfl::OnReceivedHitTestData(int render_view, + const Ewk_Hit_Test& hit_test_data, + const NodeAttributesMap& node_attributes) { + if (content::WebContents* web_contents = WebContentsFromViewID(render_process_id_, render_view)) { + content::WebContentsDelegateEfl* delegate = + static_cast(web_contents->GetDelegate()); + delegate->web_view()->UpdateHitTestData(hit_test_data, node_attributes); + } +} diff --git a/tizen_src/impl/browser/renderer_host/render_message_filter_efl.h b/tizen_src/impl/browser/renderer_host/render_message_filter_efl.h new file mode 100644 index 000000000000..b10ba3e9dde8 --- /dev/null +++ b/tizen_src/impl/browser/renderer_host/render_message_filter_efl.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2014 Samsung Electronics + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RENDER_MESSAGE_FILTER_EFL_H +#define RENDER_MESSAGE_FILTER_EFL_H + +#include "API/ewk_hit_test_private.h" +#include "base/compiler_specific.h" +#include "content/public/browser/browser_message_filter.h" +#include "public/ewk_hit_test.h" +#include "third_party/WebKit/public/web/WebNavigationPolicy.h" +#include "third_party/WebKit/public/web/WebNavigationType.h" +#include "url/gurl.h" + +struct NavigationPolicyParams; + +namespace net { +class URLRequestContextGetter; +} + +namespace content { +class BrowserContext; +class BrowserThread; +} + +class RenderMessageFilterEfl : public content::BrowserMessageFilter { + public: + RenderMessageFilterEfl(int); + ~RenderMessageFilterEfl(); + virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE; + virtual void OverrideThreadForMessage(const IPC::Message&, + content::BrowserThread::ID*) OVERRIDE; + + private: + void OnDecideNavigationPolicy(NavigationPolicyParams, bool*); + void OnReceivedHitTestData(int, const Ewk_Hit_Test&, const NodeAttributesMap&); + + int render_process_id_; +}; + +#endif diff --git a/tizen_src/impl/chromium-efl.gyp b/tizen_src/impl/chromium-efl.gyp index 9b0a4668d851..6e36cbc129f5 100644 --- a/tizen_src/impl/chromium-efl.gyp +++ b/tizen_src/impl/chromium-efl.gyp @@ -61,6 +61,8 @@ #'browser/renderer_host/backing_store_efl.cc', #'browser/renderer_host/backing_store_efl.h', 'browser/renderer_host/native_web_keyboard_event_efl.cc', + 'browser/renderer_host/render_message_filter_efl.cc', + 'browser/renderer_host/render_message_filter_efl.h', 'browser/renderer_host/web_cache_manager_efl.cc', 'browser/renderer_host/web_cache_manager_efl.h', 'browser/vibration/vibration_message_filter.cc', -- 2.34.1