[Tizen] Merge some patches from devel/master. 06/299806/1
authorhuayong.xu <huayong.xu@samsung.com>
Tue, 10 Oct 2023 09:55:17 +0000 (17:55 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Tue, 10 Oct 2023 09:55:17 +0000 (17:55 +0800)
The following patches are merged:
https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-extension/+/294022/
https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-extension/+/295532/

Change-Id: I27280af6085482566887efda69e650b9821451e0

dali-extension/web-engine-chromium/tizen-web-engine-chromium.cpp
dali-extension/web-engine-chromium/tizen-web-engine-chromium.h
dali-extension/web-engine-chromium/tizen-web-engine-context.cpp
dali-extension/web-engine-chromium/tizen-web-engine-cookie-manager.cpp

index 0539e22..84fc27d 100755 (executable)
@@ -126,12 +126,15 @@ void TizenWebEngineChromium::Create(uint32_t width, uint32_t height, const std::
 
   mWidth  = width;
   mHeight = height;
-  InitWebView(0, nullptr);
+  InitWebView();
   WebEngineManager::Get().Add(mWebView, this);
 }
 
 void TizenWebEngineChromium::Create(uint32_t width, uint32_t height, uint32_t argc, char** argv)
 {
+  // This API must be called at first.
+  ewk_set_arguments(argc, argv);
+
   // Check if web engine is available and make sure that web engine is initialized.
   if(!WebEngineManager::IsAvailable())
   {
@@ -141,17 +144,12 @@ void TizenWebEngineChromium::Create(uint32_t width, uint32_t height, uint32_t ar
 
   mWidth  = width;
   mHeight = height;
-  InitWebView(argc, argv);
+  InitWebView();
   WebEngineManager::Get().Add(mWebView, this);
 }
 
-void TizenWebEngineChromium::InitWebView(uint32_t argc, char** argv)
+void TizenWebEngineChromium::InitWebView()
 {
-  if(argc > 0)
-  {
-    ewk_set_arguments(argc, argv);
-  }
-
   Ecore_Wl2_Window* win     = AnyCast<Ecore_Wl2_Window*>(Adaptor::Get().GetNativeWindowHandle());
   Ewk_Context*      context = ewk_context_default_get();
   ewk_context_max_refresh_rate_set(context, 60);
@@ -187,8 +185,6 @@ void TizenWebEngineChromium::InitWebView(uint32_t argc, char** argv)
   evas_object_smart_callback_add(mWebView, "contextmenu,show", &TizenWebEngineChromium::OnContextMenuShown, this);
   evas_object_smart_callback_add(mWebView, "contextmenu,hide", &TizenWebEngineChromium::OnContextMenuHidden, this);
 
-  ewk_view_authentication_callback_set(mWebView, &TizenWebEngineChromium::OnAuthenticationChallenged, this);
-
   evas_object_resize(mWebView, mWidth, mHeight);
   evas_object_show(mWebView);
 }
@@ -381,7 +377,14 @@ void TizenWebEngineChromium::AddJavaScriptMessageHandler(const std::string& expo
 void TizenWebEngineChromium::RegisterJavaScriptAlertCallback(JavaScriptAlertCallback callback)
 {
   mJavaScriptAlertCallback = callback;
-  ewk_view_javascript_alert_callback_set(mWebView, &TizenWebEngineChromium::OnJavaScriptAlert, this);
+  if (mJavaScriptAlertCallback)
+  {
+    ewk_view_javascript_alert_callback_set(mWebView, &TizenWebEngineChromium::OnJavaScriptAlert, this);
+  }
+  else
+  {
+    ewk_view_javascript_alert_callback_set(mWebView, nullptr, nullptr);
+  }
 }
 
 void TizenWebEngineChromium::JavaScriptAlertReply()
@@ -392,7 +395,14 @@ void TizenWebEngineChromium::JavaScriptAlertReply()
 void TizenWebEngineChromium::RegisterJavaScriptConfirmCallback(JavaScriptConfirmCallback callback)
 {
   mJavaScriptConfirmCallback = callback;
-  ewk_view_javascript_confirm_callback_set(mWebView, &TizenWebEngineChromium::OnJavaScriptConfirm, this);
+  if (mJavaScriptConfirmCallback)
+  {
+    ewk_view_javascript_confirm_callback_set(mWebView, &TizenWebEngineChromium::OnJavaScriptConfirm, this);
+  }
+  else
+  {
+    ewk_view_javascript_confirm_callback_set(mWebView, nullptr, nullptr);
+  }
 }
 
 void TizenWebEngineChromium::JavaScriptConfirmReply(bool confirmed)
@@ -403,7 +413,14 @@ void TizenWebEngineChromium::JavaScriptConfirmReply(bool confirmed)
 void TizenWebEngineChromium::RegisterJavaScriptPromptCallback(JavaScriptPromptCallback callback)
 {
   mJavaScriptPromptCallback = callback;
-  ewk_view_javascript_prompt_callback_set(mWebView, &TizenWebEngineChromium::OnJavaScriptPrompt, this);
+  if (mJavaScriptPromptCallback)
+  {
+    ewk_view_javascript_prompt_callback_set(mWebView, &TizenWebEngineChromium::OnJavaScriptPrompt, this);
+  }
+  else
+  {
+    ewk_view_javascript_prompt_callback_set(mWebView, nullptr, nullptr);
+  }
 }
 
 void TizenWebEngineChromium::JavaScriptPromptReply(const std::string& result)
@@ -867,6 +884,14 @@ void TizenWebEngineChromium::RegisterSslCertificateChangedCallback(WebEngineCert
 void TizenWebEngineChromium::RegisterHttpAuthHandlerCallback(WebEngineHttpAuthHandlerCallback callback)
 {
   mHttpAuthHandlerCallback = callback;
+  if (mHttpAuthHandlerCallback)
+  {
+    ewk_view_authentication_callback_set(mWebView, &TizenWebEngineChromium::OnAuthenticationChallenged, this);
+  }
+  else
+  {
+    ewk_view_authentication_callback_set(mWebView, nullptr, nullptr);
+  }
 }
 
 void TizenWebEngineChromium::RegisterContextMenuShownCallback(WebEngineContextMenuShownCallback callback)
index 0b0e81d..6b57f8b 100755 (executable)
@@ -578,7 +578,7 @@ private:
   static Eina_Bool OnGeolocationPermission(Evas_Object*, Ewk_Geolocation_Permission_Request* request, void* data);
 
   void UpdateImage(tbm_surface_h buffer);
-  void InitWebView(uint32_t argc, char** argv);
+  void InitWebView();
   bool FeedMouseEvent(const TouchEvent& touch);
   bool FeedTouchEvent(const TouchEvent& touch);
 
index 8a8c60b..0bc6525 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -160,19 +160,33 @@ void TizenWebEngineContext::GetFormPasswordList(Dali::WebEngineContext::WebEngin
 void TizenWebEngineContext::RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback)
 {
   mWebDownloadStartedCallback = callback;
-  ewk_context_did_start_download_callback_set(mEwkContext, &TizenWebEngineContext::OnDownloadStarted, this);
+  if (mWebDownloadStartedCallback)
+  {
+    ewk_context_did_start_download_callback_set(mEwkContext, &TizenWebEngineContext::OnDownloadStarted, this);
+  }
+  else
+  {
+    ewk_context_did_start_download_callback_set(mEwkContext, nullptr, nullptr);
+  }
 }
 
 void TizenWebEngineContext::RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback)
 {
   mWebMimeOverriddenCallback = callback;
-  ewk_context_mime_override_callback_set(mEwkContext, &TizenWebEngineContext::OnMimeOverridden, this);
+  if (mWebMimeOverriddenCallback)
+  {
+    ewk_context_mime_override_callback_set(mEwkContext, &TizenWebEngineContext::OnMimeOverridden, this);
+  }
+  else
+  {
+    ewk_context_mime_override_callback_set(mEwkContext, nullptr, nullptr);
+  }
 }
 
 void TizenWebEngineContext::RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback)
 {
   mWebRequestInterceptedCallback = callback;
-  if (callback)
+  if (mWebRequestInterceptedCallback)
   {
     ewk_context_intercept_request_callback_set(mEwkContext, &TizenWebEngineContext::OnRequestIntercepted, this);
   }
index 165d5a5..73c40ae 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ TizenWebEngineCookieManager::TizenWebEngineCookieManager(Ewk_Cookie_Manager* man
 
 TizenWebEngineCookieManager::~TizenWebEngineCookieManager()
 {
+  ewk_cookie_manager_changes_watch(mEwkCookieManager, nullptr, nullptr);
 }
 
 void TizenWebEngineCookieManager::SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy policy)
@@ -58,13 +59,23 @@ void TizenWebEngineCookieManager::ClearCookies()
 void TizenWebEngineCookieManager::ChangesWatch(Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback callback)
 {
   mWebChangesWatchCallback = callback;
-  ewk_cookie_manager_changes_watch(mEwkCookieManager, &TizenWebEngineCookieManager::OnChangesWatch, this);
+  if (mWebChangesWatchCallback)
+  {
+    ewk_cookie_manager_changes_watch(mEwkCookieManager, &TizenWebEngineCookieManager::OnChangesWatch, this);
+  }
+  else
+  {
+    ewk_cookie_manager_changes_watch(mEwkCookieManager, nullptr, nullptr);
+  }
 }
 
 void TizenWebEngineCookieManager::OnChangesWatch(void *data)
 {
   TizenWebEngineCookieManager* pThis = static_cast<TizenWebEngineCookieManager*>(data);
-  pThis->mWebChangesWatchCallback();
+  if (pThis->mWebChangesWatchCallback)
+  {
+    pThis->mWebChangesWatchCallback();
+  }
 }
 
 } // namespace Plugin