[M120 Migration][XWalkExtension] Add ewk interface to load XWalk extensions 31/305531/3
authorliwei90727 <wei90727.li@samsung.com>
Sun, 4 Feb 2024 14:04:55 +0000 (22:04 +0800)
committerSangYong Park <sy302.park@samsung.com>
Mon, 5 Feb 2024 05:54:29 +0000 (05:54 +0000)
This interface set a path located xwalk extension json profile file.

 - ewk_context_set_xwalk_extension_profile(context, path)
 - i.e.,
   ewk_context_set_xwalk_extension_profile(
      ctx, "/usr/lib/tizen-extensions-crosswalk-ewk/");

Reference Patch:
https://review.tizen.org/gerrit/292805/

Change-Id: I2ddf3e6bdb2ebaf60bcbb360aa6b2a89e0d51b16
Signed-off-by: liwei90727 <wei90727.li@samsung.com>
tizen_src/ewk/efl_integration/content_main_delegate_efl.cc
tizen_src/ewk/efl_integration/content_main_delegate_efl.h
tizen_src/ewk/efl_integration/eweb_context.cc
tizen_src/ewk/efl_integration/eweb_context.h
tizen_src/ewk/efl_integration/private/ewk_context_private.cc
tizen_src/ewk/efl_integration/private/ewk_context_private.h
tizen_src/ewk/efl_integration/public/ewk_context.cc

index 44751f5..88d3441 100644 (file)
@@ -18,7 +18,7 @@
 #include "renderer/content_renderer_client_efl.h"
 #include "ui/base/resource/resource_bundle.h"
 
-#if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
+#if BUILDFLAG(IS_TIZEN)
 #include "components/xwalk_extensions/browser/xwalk_extension_manager.h"
 #endif
 
@@ -102,17 +102,13 @@ void ContentMainDelegateEfl::PreSandboxStartupBrowser() {
   // needed for gpu thread
   content::RegisterGpuMainThreadFactory(CreateInProcessGpuThread);
 
-#if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP)
-  // switches::kXWalkExtensionPath SHOULD be set before MainDelegate init.
+#if BUILDFLAG(IS_TIZEN)
   auto extension_path =
       base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
           switches::kXWalkExtensionPath);
   if (!extension_path.empty()) {
-    auto* extension_manager = wrt::XWalkExtensionManager::GetInstance();
-    extension_manager->LoadExtensionsByPath(extension_path);
-    extension_manager->PreloadExtensions();
-    extension_manager->SetDelegate(
-        std::make_unique<XWalkExtensionBrowserEfl>());
+    // initialize by switch
+    InitializeXWalkExtensions(extension_path);
   }
 #endif
 }
@@ -153,6 +149,20 @@ ContentBrowserClient* ContentMainDelegateEfl::GetContentBrowserClient() const {
   return browser_client_.get();
 }
 
+#if BUILDFLAG(IS_TIZEN)
+void ContentMainDelegateEfl::InitializeXWalkExtensions(
+    const std::string& extension_path) {
+  auto* extension_manager = wrt::XWalkExtensionManager::GetInstance();
+  if (extension_manager->HasDelegate())
+    return;
+
+  extension_manager->LoadExtensionsByPath(extension_path);
+  extension_manager->PreloadExtensions();
+  extension_manager->SetDelegate(std::make_unique<XWalkExtensionBrowserEfl>());
+}
+#endif
+/* LCOV_EXCL_STOP */
+
 #if BUILDFLAG(IS_TIZEN_TV)
 void ContentMainDelegateEfl::ProcessExiting(const std::string& process_type) {
   if (!enableInspector_)
index f7697ea..9ca655d 100644 (file)
@@ -33,6 +33,9 @@ class ContentMainDelegateEfl
 
   ContentBrowserClient* GetContentBrowserClient() const;
 
+#if BUILDFLAG(IS_TIZEN)
+  void InitializeXWalkExtensions(const std::string& extension_path);
+#endif
 #if BUILDFLAG(IS_TIZEN_TV)
   void ProcessExiting(const std::string& process_type) override;
   void SetInspectorStatus(bool enable);
index 9a36bc6..5cbfee1 100644 (file)
@@ -63,6 +63,7 @@
 #include "content/public/common/content_switches.h"
 #include "content/public/common/zygote/zygote_handle.h"
 #include "content_browser_client_efl.h"
+#include "content_main_delegate_efl.h"
 #endif
 
 #if BUILDFLAG(IS_TIZEN_TV)
@@ -1056,3 +1057,13 @@ void EWebContext::SetMaxRefreshRate(int max_refresh_rate) {
                                  base::NumberToString(max_refresh_rate));
 #endif
 }
+
+void EWebContext::SetXWalkExtensionProfile(const std::string& extension_path) {
+#if BUILDFLAG(IS_TIZEN)
+  auto& command_line = *base::CommandLine::ForCurrentProcess();
+  command_line.AppendSwitchASCII(switches::kXWalkExtensionPath, extension_path);
+  EwkGlobalData::GetInstance()
+      ->GetContentMainDelegateEfl()
+      .InitializeXWalkExtensions(extension_path);
+#endif
+}
index eb910a2..448ed84 100644 (file)
@@ -213,6 +213,7 @@ class EWebContext {
 
   void EnableAppControl(bool enabled);
   void SetMaxRefreshRate(int max_refresh_rate);
+  void SetXWalkExtensionProfile(const std::string& extension_path);
 
  private:
   EWebContext(bool incognito, const std::string& injectedBundlePath);
index 18d3269..368f769 100644 (file)
@@ -362,3 +362,7 @@ void Ewk_Context::SetTimeZoneOffset(double time_zone_offset,
 void Ewk_Context::SetMaxRefreshRate(int max_refresh_rate) {
   impl->SetMaxRefreshRate(max_refresh_rate);
 }
+
+void Ewk_Context::SetXWalkExtensionProfile(const std::string& extension_path) {
+  impl->SetXWalkExtensionProfile(extension_path);
+}
index cfe7fbb..d1da005 100644 (file)
@@ -171,6 +171,7 @@ struct Ewk_Context : public base::RefCounted<Ewk_Context> {
 
   void EnableAppControl(bool enabled);
   void SetMaxRefreshRate(int max_refresh_rate);
+  void SetXWalkExtensionProfile(const std::string& extension_path);
 
  private:
   EWebContext* impl;
index e48652a..5222929 100644 (file)
@@ -970,6 +970,13 @@ void ewk_context_intercept_request_cancel_callback_set(Ewk_Context* ewk_context,
   LOG_EWK_API_MOCKUP();
 }
 
+void ewk_context_set_xwalk_extension_profile(Ewk_Context* ewk_context,
+                                             const char* extension_path) {
+  EINA_SAFETY_ON_NULL_RETURN(ewk_context);
+  LOG(INFO) << "extension_path : " << extension_path;
+  ewk_context->SetXWalkExtensionProfile(extension_path);
+}
+
 Eina_Bool ewk_context_background_music_get(Ewk_Context* context)
 {
   EINA_SAFETY_ON_NULL_RETURN_VAL(context, EINA_FALSE);