Make EWK use WebContentsViewDelegate for popup menu handling.
authorPiotr Tworek <p.tworek@samsung.com>
Wed, 11 Mar 2015 12:02:20 +0000 (13:02 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
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 <p.tworek@samsung.com>
tizen_src/ewk/efl_integration/content_browser_client_efl.cc
tizen_src/ewk/efl_integration/content_browser_client_efl.h
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/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.h
tizen_src/ewk/efl_integration/web_contents_view_delegate_ewk.cc [new file with mode: 0644]
tizen_src/ewk/efl_integration/web_contents_view_delegate_ewk.h [new file with mode: 0644]

index c4b3e0c..45ce932 100644 (file)
@@ -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));
+}
+
 }
index 34e1909..20ed281 100644 (file)
@@ -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);
index 3cafbf5..da803c8 100644 (file)
       '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',
 
index d67a0f2..f337a4a 100644 (file)
@@ -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<content::MenuItem>& items, int data, int selectedIndex, bool multiple) {
+void EWebView::ShowPopupMenu(const std::vector<content::MenuItem>& items,
+    int selectedIndex, bool multiple) {
 #if defined(OS_TIZEN)
   Eina_List* popupItems = 0;
   const size_t size = items.size();
index 7af2a6a..4a717b0 100644 (file)
@@ -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<content::MenuItem>& items, int data, int selectedIndex, bool multiple);
+  void ShowPopupMenu(const std::vector<content::MenuItem>& items,
+                     int selectedIndex, bool multiple);
   Eina_Bool HidePopupMenu();
   void UpdateFormNavigation(int formElementCount, int currentNodeIndex,
       bool prevState, bool nextState);
index 94d34aa..3f4e4db 100644 (file)
@@ -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<MenuItem>& 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,
index ef626d0..7cb8238 100644 (file)
@@ -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<MenuItem>& 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 (file)
index 0000000..82edc02
--- /dev/null
@@ -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<content::MenuItem>& 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 (file)
index 0000000..cef09e8
--- /dev/null
@@ -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<content::MenuItem>& items,
+      bool right_aligned,
+      bool allow_multiple_selection) override;
+  void HidePopupMenu() override;
+
+ private:
+  EWebView* web_view_;
+};
+
+#endif // WEB_CONTENTS_VIEW_DELEGATE_EFL
+