Added an option to select the web engine type in the WebView constructor 39/318339/2
authordongsug.song <dongsug.song@samsung.com>
Thu, 19 Sep 2024 07:08:39 +0000 (16:08 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Fri, 27 Sep 2024 05:07:12 +0000 (14:07 +0900)
- Previously, the web engine was fixed and selected for all DALi/NUI APPs in dali.sh, but now it can be chosen in the constructor.

Change-Id: I481e5ee48553c29141ecf3ef78ce7cd30f743267

dali/devel-api/adaptor-framework/web-engine/web-engine.cpp
dali/devel-api/adaptor-framework/web-engine/web-engine.h
dali/internal/web-engine/common/web-engine-impl.cpp
dali/internal/web-engine/common/web-engine-impl.h

index 3549b50..fd7a286 100755 (executable)
@@ -52,7 +52,14 @@ WebEngine::~WebEngine()
 
 WebEngine WebEngine::New()
 {
-  Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
+  Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New(-1);
+
+  return WebEngine(engine.Get());
+}
+
+WebEngine WebEngine::New(int32_t type)
+{
+  Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New(type);
 
   return WebEngine(engine.Get());
 }
index 8f8a8fb..b0cfca6 100755 (executable)
@@ -65,6 +65,12 @@ public:
   static WebEngine New();
 
   /**
+   * @brief Create a new instance of a WebEngine with type (0: Chromium, 1: LWE, otherwise: depend on system environment).
+   * @param[in] type The WebEngine type (0: Chromium, 1: LWE, otherwise: depend on system environment).
+   */
+  static WebEngine New(int type);
+
+  /**
    * @brief Get context of WebEngine.
    */
   static Dali::WebEngineContext* GetContext();
index 7940642..83a8e44 100644 (file)
@@ -48,9 +48,17 @@ namespace Adaptor
 {
 namespace // unnamed namespace
 {
+static constexpr int32_t USE_ENVIRONMENT_VALUE = -1;
+static constexpr int32_t USE_CHROMIUM_WEB_ENGINE = 0;
+static constexpr int32_t USE_LIGHT_WEIGHT_WEB_ENGINE = 1;
+static constexpr int32_t DEFAULT_WEB_ENGINE_PLUGIN_TYPE = USE_ENVIRONMENT_VALUE;
+static int32_t webEnginePluginType = DEFAULT_WEB_ENGINE_PLUGIN_TYPE;
+
 constexpr char const* const kPluginFullNamePrefix  = "libdali2-web-engine-";
 constexpr char const* const kPluginFullNamePostfix = "-plugin.so";
 constexpr char const* const kPluginFullNameDefault = "libdali2-web-engine-plugin.so";
+constexpr char const* const kPluginFullNameChromium = "libdali2-web-engine-chromium-plugin.so";
+constexpr char const* const kPluginFullNameLwe = "libdali2-web-engine-lwe-plugin.so";
 
 std::string MakePluginName(const char* environmentName)
 {
@@ -143,14 +151,26 @@ private:
     mGetWebEngineCookieManagerPtr{nullptr}
   {
     std::string pluginName;
-    const char* name = EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_WEB_ENGINE_NAME);
-    if(name)
+
+    if(webEnginePluginType == USE_CHROMIUM_WEB_ENGINE)
+    {
+      pluginName = kPluginFullNameChromium;
+    }
+    else if(webEnginePluginType == USE_LIGHT_WEIGHT_WEB_ENGINE)
     {
-      pluginName = MakePluginName(name);
+      pluginName = kPluginFullNameLwe;
     }
     else
     {
-      pluginName = std::string(kPluginFullNameDefault);
+      const char* name = EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_WEB_ENGINE_NAME);
+      if(name)
+      {
+        pluginName = MakePluginName(name);
+      }
+      else
+      {
+        pluginName = std::string(kPluginFullNameDefault);
+      }
     }
 
     mHandle = dlopen(pluginName.c_str(), RTLD_LAZY);
@@ -212,9 +232,9 @@ public:
 
 } // unnamed namespace
 
-WebEnginePtr WebEngine::New()
+WebEnginePtr WebEngine::New(int32_t type)
 {
-  WebEngine* instance = new WebEngine();
+  WebEngine* instance = new WebEngine(type);
   if(!instance->Initialize())
   {
     delete instance;
@@ -254,9 +274,10 @@ Dali::WebEngineCookieManager* WebEngine::GetCookieManager()
   return nullptr;
 }
 
-WebEngine::WebEngine()
+WebEngine::WebEngine(int32_t type)
 : mPlugin(nullptr)
 {
+  webEnginePluginType = type;
 }
 
 WebEngine::~WebEngine()
index 3e18f8d..8a0e706 100755 (executable)
@@ -49,11 +49,11 @@ class WebEngine : public Dali::BaseObject
 {
 public:
   /**
-   * @brief Create a new WebEngine handle
-   *
+   * @brief Create a new WebEngine handle with type (0: Chromium, 1: LWE, otherwise: depend on system environment).
+   * @param[in] type The WebEngine type (0: Chromium, 1: LWE, otherwise: depend on system environment).
    * @return WebEngine pointer
    */
-  static WebEnginePtr New();
+  static WebEnginePtr New(int32_t type);
 
   /**
    * @brief Get context of web engine
@@ -594,9 +594,9 @@ public:
 
 private:
   /**
-   * @brief Constructor.
+   * @brief Constructor with WebEngine type (0: Chromium, 1: LWE, otherwise: depend on system environment).
    */
-  WebEngine();
+  WebEngine(int32_t type);
 
   /**
    * @brief Destructor.