[M108 Migration][VD] Provide ewk_settings_clipboard_enabled_set api 54/288654/5
authorshurong.chen <shurong.chen@samsung.com>
Tue, 21 Feb 2023 03:07:53 +0000 (11:07 +0800)
committerBot Blink <blinkbot@samsung.com>
Mon, 27 Feb 2023 05:31:13 +0000 (05:31 +0000)
The patch is for the requirement:
Support ewk setting api for handle ctrl+x/c/v(clipboard).
When clipboard enabled, text input can paste from clipboard.

This patch is migrated from M94 Aura:
https://review.tizen.org/gerrit/#/c/282689/

Change-Id: I2de1e97720968c27d5271e63c2afba3935ec30e9
Signed-off-by: shurong.chen <shurong.chen@samsung.com>
tizen_src/chromium_impl/ui/base/clipboard/clipboard_helper_efl_wayland.cc
tizen_src/ewk/efl_integration/context_menu_controller_efl.cc
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/private/ewk_settings_private.cc
tizen_src/ewk/efl_integration/private/ewk_settings_private.h
tizen_src/ewk/efl_integration/public/ewk_settings.cc

index 2599142..ed21a61 100644 (file)
@@ -202,11 +202,7 @@ bool ClipboardHelperEfl::RetrieveClipboardItem(
 }
 
 bool ClipboardHelperEfl::CanPasteFromClipboardApp() const {
-#if BUILDFLAG(IS_TIZEN_TV)
-  return false;
-#else
   return CbhmNumberOfItems() > 0;
-#endif
 }
 
 void ClipboardHelperEfl::RefreshClipboard() {
index b85d8ac..0590549 100644 (file)
@@ -253,7 +253,7 @@ void ContextMenuControllerEfl::GetProposedContextMenu() {
   }
 #endif
 
-  if (params_.is_editable &&
+  if (params_.is_editable && webview_->GetSettings()->getClipboardEnabled() &&
       ClipboardHelperEfl::GetInstance()->CanPasteFromClipboardApp()) {
     AddItemToProposedList(EWK_CONTEXT_MENU_ITEM_TYPE_ACTION, EWK_CONTEXT_MENU_ITEM_TAG_CLIPBOARD,
         std::string(dgettext("WebKit", "IDS_WEBVIEW_OPT_CLIPBOARD")));
index 40f93c3..b57d167 100644 (file)
@@ -408,8 +408,9 @@ EWebView::~EWebView() {
 
   evas_object_event_callback_del(native_view_, EVAS_CALLBACK_RESIZE,
                                  EWebView::NativeViewResize);
-#if defined(USE_WAYLAND) && !BUILDFLAG(IS_TIZEN_TV)
-  ClipboardHelperEfl::GetInstance()->MaybeInvalidateActiveWebview(this);
+#if defined(USE_WAYLAND)
+  if (GetSettings()->getClipboardEnabled())
+    ClipboardHelperEfl::GetInstance()->MaybeInvalidateActiveWebview(this);
 #endif
 
   std::map<int64_t, WebViewAsyncRequestHitTestDataCallback*>::iterator
@@ -1686,21 +1687,24 @@ void EWebView::OnCopyFromBackingStore(bool success, const SkBitmap& bitmap) {}
 
 void EWebView::OnFocusIn() {
   SmartCallback<EWebViewCallbacks::FocusIn>().call();
-#if defined(USE_WAYLAND) && !BUILDFLAG(IS_TIZEN_TV)
+#if defined(USE_WAYLAND)
   if (!rwhva() || !rwhva()->offscreen_helper())
     return;
-  ClipboardHelperEfl::GetInstance()->OnWebviewFocusIn(
-      this, rwhva()->offscreen_helper()->content_image_elm_host(),
-      rwhva()->offscreen_helper()->IsFocusedNodeContentEditable(),
-      base::BindRepeating(&EWebView::ExecuteEditCommand,
-                          base::Unretained(this)));
+  if (GetSettings()->getClipboardEnabled()) {
+    ClipboardHelperEfl::GetInstance()->OnWebviewFocusIn(
+        this, rwhva()->offscreen_helper()->content_image_elm_host(),
+        rwhva()->offscreen_helper()->IsFocusedNodeContentEditable(),
+        base::BindRepeating(&EWebView::ExecuteEditCommand,
+                            base::Unretained(this)));
+  }
 #endif
 }
 
 void EWebView::OnFocusOut() {
   SmartCallback<EWebViewCallbacks::FocusOut>().call();
-#if defined(USE_WAYLAND) && !BUILDFLAG(IS_TIZEN_TV)
-  ClipboardHelperEfl::GetInstance()->MaybeInvalidateActiveWebview(this);
+#if defined(USE_WAYLAND)
+  if (GetSettings()->getClipboardEnabled())
+    ClipboardHelperEfl::GetInstance()->MaybeInvalidateActiveWebview(this);
 #endif
 }
 
index 607544f..a36de09 100644 (file)
@@ -5,6 +5,7 @@
 #include "ewk_settings_private.h"
 
 #include "net/http/http_stream_factory.h"
+#include "tizen/system_info.h"
 
 Ewk_Settings::Ewk_Settings(Evas_Object* evas_object,
                            const WebPreferences& preferences)
@@ -29,3 +30,10 @@ void Ewk_Settings::setEdgeEffectEnabled(bool enable) {
   content::EdgeEffect::EnableGlobally(enable);
 #endif
 }
+
+bool Ewk_Settings::getClipboardEnabled() const {
+  if (IsTvProfile())
+    return m_clipboardEnabled;
+  else
+    return true;
+}
index f1fa82b..497ef14 100644 (file)
@@ -92,6 +92,8 @@ class Ewk_Settings {
     bool getURLBarHideEnabled() const { return m_URLBarHide; }
     void setTouchFocusEnabled(bool enable) { m_touchFocusEnabled = enable; }
     bool touchFocusEnabled() const { return m_touchFocusEnabled; }
+    void setClipboardEnabled(bool enable) { m_clipboardEnabled = enable; }
+    bool getClipboardEnabled() const;
 
   private:
    WebPreferences m_preferences;
@@ -126,6 +128,7 @@ class Ewk_Settings {
    bool m_allowRestrictedURL = true;
    bool m_URLBarHide = false;
    bool m_touchFocusEnabled = true;
+   bool m_clipboardEnabled = false;
 };
 
 #endif // ewk_settings_private_h
index d406e3f..2891773 100644 (file)
@@ -865,13 +865,23 @@ Eina_Bool ewk_settings_drag_drop_enabled_get(const Ewk_Settings* settings)
 
 void ewk_settings_clipboard_enabled_set(Ewk_Settings* settings, Eina_Bool enabled)
 {
-  LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  EINA_SAFETY_ON_NULL_RETURN(settings);
+  settings->setClipboardEnabled(!!enabled);
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV");
+#endif
 }
 
 Eina_Bool ewk_settings_clipboard_enabled_get(const Ewk_Settings* settings)
 {
-  LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+  EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EINA_FALSE);
+  return settings->getClipboardEnabled();
+#else
+  LOG_EWK_API_MOCKUP("Only for Tizen TV");
   return EINA_FALSE;
+#endif
 }
 
 Eina_Bool ewk_settings_javascript_can_access_clipboard_set(Ewk_Settings* settings, Eina_Bool enable)