preload_handle_[lib_path] = handle;
}
+void XWalkExtensionManager::LoadExtensionsByJsonPath(
+ const std::string& json_path) {
+ if (is_loaded_by_json_path_)
+ return;
+
+ std::set<std::string> files;
+ ParseMetadata(json_path, &files, XWALK_EXTENSION_PATH);
+ is_loaded_by_json_path_ = true;
+}
+
void XWalkExtensionManager::LoadUIAppExtensions() {
if (is_loaded_for_web_app_)
return;
void ClearPreloadHandle(const std::string& lib_path);
void GetRuntimeVariable(const char* key, char* value, size_t value_len);
+ void LoadExtensionsByJsonPath(const std::string& json_path);
void LoadUIAppExtensions();
void LoadServiceAppExtensions();
void LoadUserExtensions(const std::string& app_path);
virtual std::string HandleRuntimeMessageInternal(
const std::string& type, const std::string& value);
+ bool is_loaded_by_json_path_ = false;
bool is_loaded_for_service_app_ = false;
bool is_loaded_for_web_app_ = false;
"browser/webdata/web_data_service.h",
"browser/webdata/web_data_service_factory.cc",
"browser/webdata/web_data_service_factory.h",
+ "browser/xwalk_extension_browser_efl.cc",
+ "browser/xwalk_extension_browser_efl.h",
"common/content_client_efl.cc",
"common/content_client_efl.h",
"common/content_switches_efl.cc",
--- /dev/null
+// Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tizen_src/ewk/efl_integration/browser/xwalk_extension_browser_efl.h"
+
+#include "base/logging.h"
+
+namespace content {
+
+std::string XWalkExtensionBrowserEfl::HandleRuntimeMessageInternal(
+ const std::string& type, const std::string& value) {
+ LOG(INFO) << "type : " << type;
+ // TODO(dh81.song)
+ // According to xwalk extensions, this might handle internal messages.
+ return std::string();
+}
+
+} // namespace content
\ No newline at end of file
--- /dev/null
+// Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BROWSER_XWALK_EXTENSION_BROWSER_EFL_H_
+#define BROWSER_XWALK_EXTENSION_BROWSER_EFL_H_
+
+#include "tizen_src/chromium_impl/components/xwalk_extensions/common/xwalk_extension_browser_delegate.h"
+
+namespace content {
+
+class XWalkExtensionBrowserEfl : public wrt::XWalkExtensionBrowserDelegate {
+ public:
+ XWalkExtensionBrowserEfl() {}
+ ~XWalkExtensionBrowserEfl() override {}
+
+ private:
+ // XWalkExtensionBrowserDelegate
+ std::string HandleRuntimeMessageInternal(
+ const std::string& type, const std::string& value) override;
+};
+
+} // namespace content
+
+#endif // BROWSER_XWALK_EXTENSION_BROWSER_EFL_H_
\ No newline at end of file
const char kEwkEnableMobileFeaturesForDesktop[] =
"ewk-enable-mobile-features-for-desktop";
+const char kXWalkExtensionJsonPath[] = "xwalk-extension-json-path";
#if defined(TIZEN_PEPPER_EXTENSIONS)
const char kEnableTrustedPepperPlugins[] = "enable-trusted-pepper-plugins";
CONTENT_EXPORT extern const char kWidgetScale[];
CONTENT_EXPORT extern const char kWidgetTheme[];
CONTENT_EXPORT extern const char kWidgetEncodedBundle[];
+CONTENT_EXPORT extern const char kXWalkExtensionJsonPath[];
// Turns on a bunch of settings (mostly on blink::WebView) for which there is no
// command line switches. This allows desktop "ubrowser --mobile" to have
#include "components/error_page/common/localized_error.h"
#include "components/navigation_interception/intercept_navigation_throttle.h"
#include "components/password_manager/content/browser/content_password_manager_driver_factory.h"
+#include "components/xwalk_extensions/browser/xwalk_extension_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_process_host.h"
return result;
}
+void ContentBrowserClientEfl::ExposeInterfacesToRenderer(
+ service_manager::BinderRegistry* registry,
+ blink::AssociatedInterfaceRegistry* associated_registry,
+ content::RenderProcessHost* render_process_host) {
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kXWalkExtensionJsonPath)) {
+ return;
+ }
+ registry->AddInterface(
+ base::BindRepeating(&wrt::XWalkExtensionManager::Bind),
+ content::GetUIThreadTaskRunner({}));
+}
+
#if BUILDFLAG(IS_TIZEN_TV)
base::OnceClosure ContentBrowserClientEfl::SelectClientCertificate(
WebContents* web_contents,
ResourceContext* context,
int render_process_id,
int render_frame_id);
+ void ExposeInterfacesToRenderer(
+ service_manager::BinderRegistry* registry,
+ blink::AssociatedInterfaceRegistry* associated_registry,
+ RenderProcessHost* render_process_host) override;
void OverrideWebkitPrefs(WebContents* web_contents,
blink::web_pref::WebPreferences* prefs);
void RenderProcessWillLaunch(RenderProcessHost* host) override;
#include "content_main_delegate_efl.h"
#include "base/path_service.h"
+#include "browser/xwalk_extension_browser_efl.h"
#include "command_line_efl.h"
+#include "common/content_switches_efl.h"
+#include "components/xwalk_extensions/browser/xwalk_extension_manager.h"
#include "content/browser/gpu/gpu_main_thread_factory.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/common/locale_efl.h"
// needed for gpu thread
content::RegisterGpuMainThreadFactory(CreateInProcessGpuThread);
+
+ // switches::kXWalkExtensionJsonPath SHOULD be set before MainDelegate init.
+ auto json_path =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kXWalkExtensionJsonPath);
+ if (!json_path.empty()) {
+ auto* extension_manager = wrt::XWalkExtensionManager::GetInstance();
+ extension_manager->LoadExtensionsByJsonPath(json_path);
+ extension_manager->PreloadExtensions();
+ extension_manager->SetDelegate(
+ std::make_unique<XWalkExtensionBrowserEfl>());
+ }
}
void ContentMainDelegateEfl::PreSandboxStartup() {
#include "common/content_switches_efl.h"
#include "common/render_messages_ewk.h"
#include "components/visitedlink/renderer/visitedlink_reader.h"
+#include "components/xwalk_extensions/renderer/xwalk_extension_renderer_controller.h"
#include "content/common/locale_efl.h"
#include "content/common/paths_efl.h"
#include "content/public/common/content_switches.h"
static const float minimum_page_scale_for_mobile = 0.25f;
static const float maximum_page_scale_for_mobile = 5.f;
-#if defined(TIZEN_PEPPER_EXTENSIONS)
namespace {
+bool ShouldRegisterXWalkExtension(int world_id) {
+ return world_id == 0 && base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kXWalkExtensionJsonPath);
+}
+
+#if defined(TIZEN_PEPPER_EXTENSIONS)
bool CreateTrustedPepperPlugin(content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
blink::WebPlugin** plugin) {
return false;
}
+#endif // defined(TIZEN_PEPPER_EXTENSIONS)
} // namespace
-#endif // defined(TIZEN_PEPPER_EXTENSIONS)
/* LCOV_EXCL_START */
ContentRendererClientEfl::ContentRendererClientEfl() {}
if (!command_line.HasSwitch(switches::kSingleProcess))
LocaleEfl::Initialize();
+
+ if (command_line.HasSwitch(switches::kXWalkExtensionJsonPath)) {
+ wrt::XWalkExtensionRendererController::GetInstance().SetPrivilegeChecker(
+ base::BindRepeating([]() -> bool {
+ // TODO(dh81.song)
+ // necessary to decide whether allow webapis for external URLs
+ return true;
+ }));
+ }
}
void ContentRendererClientEfl::RenderFrameCreated(content::RenderFrame* render_frame) {
content::RenderFrame* render_frame,
v8::Handle<v8::Context> context,
int world_id) {
+ if (ShouldRegisterXWalkExtension(world_id))
+ wrt::XWalkExtensionRendererController::DidCreateScriptContext(context);
+
if (!widget_)
return;
blink::WebFrame* frame,
v8::Handle<v8::Context> context,
int world_id) {
+ if (ShouldRegisterXWalkExtension(world_id))
+ wrt::XWalkExtensionRendererController::WillReleaseScriptContext(context);
+
if (widget_)
widget_->StopSession(context);
}
return GetFocusedElement(focused_frame);
}
-bool shouldRegisterXWalkExtension(int world_id) {
+bool ShouldRegisterXWalkExtension(int world_id) {
return (world_id == 0);
}
electron::ElectronRenderFrameObserver::DidCreateScriptContext(
context, world_id);
- if (shouldRegisterXWalkExtension(world_id))
+ if (ShouldRegisterXWalkExtension(world_id))
XWalkExtensionRendererController::DidCreateScriptContext(context);
}
electron::ElectronRenderFrameObserver::WillReleaseScriptContext(
context, world_id);
- if (shouldRegisterXWalkExtension(world_id))
+ if (ShouldRegisterXWalkExtension(world_id))
XWalkExtensionRendererController::WillReleaseScriptContext(context);
}