[Tizen] Support incognito mode in WebView
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Tue, 27 Aug 2024 06:43:00 +0000 (15:43 +0900)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Tue, 27 Aug 2024 06:43:00 +0000 (15:43 +0900)
This reverts commit 5b3a22c187eddc01ec1a5b2a0ddb061981ac4075.

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-manager.cpp
dali-extension/web-engine-chromium/tizen-web-engine-manager.h

index d49c8b4..78c3a4c 100644 (file)
@@ -126,7 +126,7 @@ void TizenWebEngineChromium::Create(uint32_t width, uint32_t height, const std::
 
   mWidth  = width;
   mHeight = height;
-  InitWebView();
+  InitWebView(false);
   WebEngineManager::Get().Add(mWebView, this);
 }
 
@@ -142,19 +142,40 @@ void TizenWebEngineChromium::Create(uint32_t width, uint32_t height, uint32_t ar
     return;
   }
 
+  bool incognito = false;
+  for(uint32_t idx = 0; idx < argc; ++idx)
+  {
+    if(strstr(argv[idx], "--incognito"))
+    {
+      incognito = true;
+      break;
+    }
+  }
+
   mWidth  = width;
   mHeight = height;
-  InitWebView();
+  InitWebView(incognito);
   WebEngineManager::Get().Add(mWebView, this);
 }
 
-void TizenWebEngineChromium::InitWebView()
+void TizenWebEngineChromium::InitWebView(bool incognito)
 {
-  Ecore_Wl2_Window* win     = AnyCast<Ecore_Wl2_Window*>(Adaptor::Get().GetNativeWindowHandle());
-  Ewk_Context*      context = ewk_context_default_get();
+  Ewk_Context* context = nullptr;
+  if(incognito)
+  {
+    mWebView = ewk_view_add_in_incognito_mode(ecore_evas_get(WebEngineManager::Get().GetWindow()));
+    context  = ewk_view_context_get(mWebView);
+  }
+  else
+  {
+    context  = ewk_context_default_get();
+    mWebView = ewk_view_add(ecore_evas_get(WebEngineManager::Get().GetWindow()));
+  }
+  WebEngineManager::Get().SetContext(context);
   ewk_context_max_refresh_rate_set(context, 60);
-  mWebView = ewk_view_add(ecore_evas_get(WebEngineManager::Get().GetWindow()));
   ewk_view_offscreen_rendering_enabled_set(mWebView, true);
+
+  Ecore_Wl2_Window* win = AnyCast<Ecore_Wl2_Window*>(Adaptor::Get().GetNativeWindowHandle());
   ewk_view_ime_window_set(mWebView, win);
 
   Ewk_Settings* settings = ewk_view_settings_get(mWebView);
index 6f1dab0..3e6ac35 100644 (file)
@@ -606,7 +606,7 @@ private:
   static Eina_Bool OnGeolocationPermission(Evas_Object*, Ewk_Geolocation_Permission_Request* request, void* data);
 
   void UpdateImage(tbm_surface_h buffer);
-  void InitWebView();
+  void InitWebView(bool incognito);
   bool FeedMouseEvent(const TouchEvent& touch);
   bool FeedTouchEvent(const TouchEvent& touch);
 
index 693cd6f..bd0ad1d 100644 (file)
@@ -25,8 +25,6 @@
 #include <dali/devel-api/adaptor-framework/lifecycle-controller.h>
 #include <dali/integration-api/debug.h>
 
-#include <ewk_context.h>
-#include <ewk_context_internal.h>
 #include <ewk_main.h>
 
 #include <memory>
@@ -57,11 +55,6 @@ WebEngineManager::WebEngineManager()
   ewk_init();
   mWindow = ecore_evas_new("wayland_egl", 0, 0, 1, 1, 0);
 
-  Ewk_Context* context = ewk_context_default_get();
-  mWebEngineContext.reset(new TizenWebEngineContext(context));
-
-  Ewk_Cookie_Manager* manager = ewk_context_cookie_manager_get(context);
-  mWebEngineCookieManager.reset(new TizenWebEngineCookieManager(manager));
   Dali::LifecycleController::Get().TerminateSignal().Connect(mSlotDelegate, &WebEngineManager::OnTerminated);
 
   DALI_LOG_RELEASE_INFO("#WebEngineManager is created fully.\n");
@@ -92,6 +85,14 @@ Ecore_Evas* WebEngineManager::GetWindow()
   return mWindow;
 }
 
+void WebEngineManager::SetContext(Ewk_Context* context)
+{
+  mWebEngineContext.reset(new TizenWebEngineContext(context));
+
+  Ewk_Cookie_Manager* manager = ewk_context_cookie_manager_get(context);
+  mWebEngineCookieManager.reset(new TizenWebEngineCookieManager(manager));
+}
+
 Dali::WebEngineContext* WebEngineManager::GetContext()
 {
   return mWebEngineContext.get();
index 4348263..2e0e6eb 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_PLUGIN_TIZEN_WEB_ENGINE_MANAGER_H
 
 /*
- * Copyright (c) 2022 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.
@@ -25,6 +25,8 @@
 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-plugin.h>
 #include <dali/public-api/signals/slot-delegate.h>
 
+#include <ewk_context.h>
+
 #include <map>
 #include <memory>
 
@@ -51,6 +53,8 @@ public:
 
   Ecore_Evas* GetWindow();
 
+  void SetContext(Ewk_Context* context);
+
   Dali::WebEngineContext* GetContext();
 
   Dali::WebEngineCookieManager* GetCookieManager();