From: Piotr Tworek Date: Wed, 11 Mar 2015 12:02:20 +0000 (+0100) Subject: Make EWK use WebContentsViewDelegate for popup menu handling. X-Git-Tag: submit/tizen/20201118.160233~1091 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae37a498fd7c4b21751682637759da6be41ee71e;p=platform%2Fframework%2Fweb%2Fchromium-efl.git Make EWK use WebContentsViewDelegate for popup menu handling. Apps wishing to show custom popup menus should implement WebContentsViewDelegate::ShowPopupMenu function. This patch does it for EWK. Change-Id: Id587ac954c3d016c5a0717eca365610aec1e2a82 Signed-off-by: Piotr Tworek --- diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc index c4b3e0c6..45ce932 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.cc +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.cc @@ -9,6 +9,7 @@ #include "browser_main_parts_efl.h" #include "browser_context_efl.h" #include "web_contents_delegate_efl.h" +#include "web_contents_view_delegate_ewk.h" #include "devtools_manager_delegate_efl.h" #include "browser/editor_client_observer.h" #include "browser/geolocation/access_token_store_efl.h" @@ -425,4 +426,9 @@ void ContentBrowserClientEfl::SetNotificationCallbacks(Notification_Show_Callbac notification_callback_user_data_ = user_data; } +WebContentsViewDelegate* ContentBrowserClientEfl::GetWebContentsViewDelegate( + WebContents* web_contents) { + return new WebContentsViewDelegateEwk(WebViewFromWebContents(web_contents)); +} + } diff --git a/tizen_src/ewk/efl_integration/content_browser_client_efl.h b/tizen_src/ewk/efl_integration/content_browser_client_efl.h index 34e1909..20ed281 100644 --- a/tizen_src/ewk/efl_integration/content_browser_client_efl.h +++ b/tizen_src/ewk/efl_integration/content_browser_client_efl.h @@ -136,6 +136,9 @@ class ContentBrowserClientEfl: public ContentBrowserClient { return notification_controller_.get(); } + WebContentsViewDelegate* GetWebContentsViewDelegate( + WebContents* web_contents) override; + private: static void SetCertificatePemOnUIThread(int render_process_id, int render_view_id, std::string certificate); diff --git a/tizen_src/ewk/efl_integration/efl_integration.gypi b/tizen_src/ewk/efl_integration/efl_integration.gypi index 3cafbf5..da803c8 100644 --- a/tizen_src/ewk/efl_integration/efl_integration.gypi +++ b/tizen_src/ewk/efl_integration/efl_integration.gypi @@ -160,6 +160,8 @@ 'url_request_context_getter_efl.h', 'web_contents_delegate_efl.cc', 'web_contents_delegate_efl.h', + 'web_contents_view_delegate_ewk.cc', + 'web_contents_view_delegate_ewk.h', 'web_process_content_main_delegate_efl.cc', 'web_process_content_main_delegate_efl.h', diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index d67a0f2..f337a4a 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -1147,7 +1147,8 @@ void EWebView::InvokeLoadError(const tizen_webview::Error &error) { } } -void EWebView::ShowPopupMenu(const gfx::Rect& rect, blink::TextDirection textDirection, double pageScaleFactor, const std::vector& items, int data, int selectedIndex, bool multiple) { +void EWebView::ShowPopupMenu(const std::vector& items, + int selectedIndex, bool multiple) { #if defined(OS_TIZEN) Eina_List* popupItems = 0; const size_t size = items.size(); diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 7af2a6a..4a717b0 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -306,7 +306,8 @@ class EWebView { void Find(const char* text, tizen_webview::Find_Options); void InvokeAuthCallbackOnUI(_Ewk_Auth_Challenge* auth_challenge); void SetContentSecurityPolicy(const char* policy, tizen_webview::ContentSecurityPolicyType type); - void ShowPopupMenu(const gfx::Rect& rect, blink::TextDirection textDirection, double pageScaleFactor, const std::vector& items, int data, int selectedIndex, bool multiple); + void ShowPopupMenu(const std::vector& items, + int selectedIndex, bool multiple); Eina_Bool HidePopupMenu(); void UpdateFormNavigation(int formElementCount, int currentNodeIndex, bool prevState, bool nextState); diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index 94d34aa..3f4e4db 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -441,27 +441,6 @@ void WebContentsDelegateEfl::SetContentSecurityPolicy(const std::string& policy, } } -void WebContentsDelegateEfl::ShowPopupMenu(RenderFrameHost* render_frame_host, - const gfx::Rect& rect, - blink::TextDirection textDirection, - double pageScaleFactor, - const std::vector& items, - int data, - int selectedIndex, - bool multiple) { - web_view_->ShowPopupMenu(rect, - textDirection, - pageScaleFactor, - items, - data, - selectedIndex, - multiple); -} - -void WebContentsDelegateEfl::HidePopupMenu() { - web_view_->HidePopupMenu(); -} - void WebContentsDelegateEfl::UpdateFormNavigation(int formElementCount, int currentNodeIndex, bool prevState, bool nextState) { web_view_->UpdateFormNavigation(formElementCount, currentNodeIndex, diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h index ef626d0..7cb8238 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h @@ -131,15 +131,6 @@ class WebContentsDelegateEfl void OnFormSubmit(const GURL&); void OnUpdateSettings(const Ewk_Settings *settings); void SetContentSecurityPolicy(const std::string& policy, tizen_webview::ContentSecurityPolicyType header_type); - void ShowPopupMenu(RenderFrameHost* render_frame_host, - const gfx::Rect& rect, - blink::TextDirection textDirection, - double pageScaleFactor, - const std::vector& items, - int data, - int selectedIndex, - bool multiple); - void HidePopupMenu(); void UpdateFormNavigation(int formElementCount, int currentNodeIndex, bool prevState, bool nextState); diff --git a/tizen_src/ewk/efl_integration/web_contents_view_delegate_ewk.cc b/tizen_src/ewk/efl_integration/web_contents_view_delegate_ewk.cc new file mode 100644 index 0000000..82edc02 --- /dev/null +++ b/tizen_src/ewk/efl_integration/web_contents_view_delegate_ewk.cc @@ -0,0 +1,27 @@ +// Copyright 2015 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 "web_contents_view_delegate_ewk.h" + +#include "eweb_view.h" + +WebContentsViewDelegateEwk::WebContentsViewDelegateEwk(EWebView* wv) + : web_view_(wv) { +} + +void WebContentsViewDelegateEwk::ShowPopupMenu( + content::RenderFrameHost* render_frame_host, + const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector& items, + bool right_aligned, + bool allow_multiple_selection) { + web_view_->ShowPopupMenu(items, selected_item, allow_multiple_selection); +} + +void WebContentsViewDelegateEwk::HidePopupMenu() { + web_view_->HidePopupMenu(); +} diff --git a/tizen_src/ewk/efl_integration/web_contents_view_delegate_ewk.h b/tizen_src/ewk/efl_integration/web_contents_view_delegate_ewk.h new file mode 100644 index 0000000..cef09e8 --- /dev/null +++ b/tizen_src/ewk/efl_integration/web_contents_view_delegate_ewk.h @@ -0,0 +1,38 @@ +// Copyright 2015 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 WEB_CONTENTS_VIEW_DELEGATE_EFL +#define WEB_CONTENTS_VIEW_DELEGATE_EFL + +#include "content/public/browser/web_contents_view_delegate.h" + +#include "content/public/common/menu_item.h" + +class EWebView; + +namespace content { +class RenderFrameHost; +} + +class WebContentsViewDelegateEwk : public content::WebContentsViewDelegate { + public: + WebContentsViewDelegateEwk(EWebView*); + + void ShowPopupMenu( + content::RenderFrameHost* render_frame_host, + const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector& items, + bool right_aligned, + bool allow_multiple_selection) override; + void HidePopupMenu() override; + + private: + EWebView* web_view_; +}; + +#endif // WEB_CONTENTS_VIEW_DELEGATE_EFL +