1.This CL implement api ewk_context_register_url_schemes_as_cors_enabled.
With this CL, WebEngine can parse dvb url host as CORS.
2.Remove WRT dependency of injected bundle, only HbbTV uses it.
3.Fix the loss of IPC message caused by multithreading.
This patch includes :
1) Added protection for NULL message in IPC.
There was no exception handling for the NULL message
in low memory situation.
2) Fix the issue the deleted message is used again.
When multiple render process exit ,the message is deleted
after it send to one render process.
Copy the message before it is sent to render process.
References:
https://review.tizen.org/gerrit/#/c/251270/
https://review.tizen.org/gerrit/#/c/250990
https://review.tizen.org/gerrit/#/c/255829
Change-Id: Iaf0084a385649fda71d2c0856398b0c26458c919
Signed-off-by: fr.fang <fr.fang@samsung.com>
}
bool ChannelMojo::Send(Message* message) {
- DVLOG(2) << "sending message @" << message << " on channel @" << this
- << " with type " << message->type();
-#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
- Logging::GetInstance()->OnSendMessage(message);
-#endif
-
std::unique_ptr<Message> scoped_message = base::WrapUnique(message);
if (!message_reader_)
return false;
DCHECK(!*handles);
MojoResult result = MOJO_RESULT_OK;
+#if BUILDFLAG(IS_TIZEN_TV)
+ if (!message)
+ return MOJO_RESULT_INVALID_ARGUMENT;
+#endif
if (!message->HasAttachments())
return result;
// renderer whether the script content has changed rather than relying on a
// response time match from the network cache.
static void RegisterURLSchemeAsCodeCacheWithHashing(const WebString&);
+#if BUILDFLAG(IS_TIZEN_TV)
+ // Registers a non-HTTP URL scheme which can be sent CORS requests.
+ BLINK_EXPORT static void RegisterURLSchemeAsCORSEnabled(const WebString&);
+#endif
private:
WebSecurityPolicy() = delete;
const WebString& scheme) {
SchemeRegistry::RegisterURLSchemeAsCodeCacheWithHashing(scheme);
}
-
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebSecurityPolicy::RegisterURLSchemeAsCORSEnabled(
+ const WebString& scheme) {
+ SchemeRegistry::RegisterURLSchemeAsCORSEnabled(scheme);
+}
+#endif
} // namespace blink
return GetURLSchemesRegistry().service_worker_schemes.Contains(scheme);
}
+#if BUILDFLAG(IS_TIZEN_TV)
+void SchemeRegistry::RegisterURLSchemeAsCORSEnabled(const String& scheme) {
+ DCHECK_EQ(scheme, scheme.LowerASCII());
+ GetMutableURLSchemesRegistry().cors_enabled_schemes.insert(scheme);
+}
+#endif
+
void SchemeRegistry::RegisterURLSchemeAsSupportingFetchAPI(
const String& scheme) {
DCHECK_EQ(scheme, scheme.LowerASCII());
const String& scheme);
static bool ShouldTreatURLSchemeAsCorsEnabled(const String& scheme);
+#if BUILDFLAG(IS_TIZEN_TV)
+ static void RegisterURLSchemeAsCORSEnabled(const String& scheme);
+#endif
// Serialize the registered schemes in a comma-separated list.
static String ListOfCorsEnabledURLSchemes();
sources += [
"common/application_type.cc",
"common/application_type.h",
+ "wrt/hbbtv_dynamicplugin.cc",
+ "wrt/hbbtv_dynamicplugin.h",
+ "wrt/hbbtv_widget.cc",
+ "wrt/hbbtv_widget.h",
+ "wrt/hbbtv_widget_host.cc",
+ "wrt/hbbtv_widget_host.h",
]
}
#if BUILDFLAG(IS_TIZEN_TV)
// Save ApplicationType in command line.
const char kApplicationType[] = "application-type";
+// CORS enabled URL schemes
+const char kCORSEnabledURLSchemes[] = "cors-enabled-url-schemes";
#endif
// Widget Info
#if BUILDFLAG(IS_TIZEN_TV)
// Save ApplicationType in command line.
CONTENT_EXPORT extern const char kApplicationType[];
+// CORS enabled url schemes
+CONTENT_EXPORT extern const char kCORSEnabledURLSchemes[];
#endif
CONTENT_EXPORT extern const char kTizenAppId[];
CONTENT_EXPORT extern const char kTizenAppVersion[];
bool /* enable */)
IPC_MESSAGE_ROUTED0(EwkHostMsg_DidNotAllowScript)
+
+#if BUILDFLAG(IS_TIZEN_TV)
+IPC_MESSAGE_CONTROL1(HbbtvMsg_RegisterURLSchemesAsCORSEnabled,
+ std::string /* scheme */)
+
+#endif
#include "content/browser/speech/tizen_speech_recognition_manager_delegate.h"
#endif
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "wrt/hbbtv_widget_host.h"
+#endif
+
using web_contents_utils::WebContentsFromFrameID;
using web_contents_utils::WebContentsFromViewID;
using web_contents_utils::WebViewFromWebContents;
command_line->AppendSwitchASCII(
switches::kApplicationType,
base::NumberToString(static_cast<int>(application_type)));
+
+ const std::string& cors_enabled_url_schemes =
+ HbbtvWidgetHost::Get().GetCORSEnabledURLSchemes();
+ if (!cors_enabled_url_schemes.empty()) {
+ command_line->AppendSwitchASCII(switches::kCORSEnabledURLSchemes,
+ cors_enabled_url_schemes);
+ }
#endif
const std::string& injectedBundlePath = context->GetInjectedBundlePath();
command_line->AppendSwitchASCII(switches::kTizenAppId, tizen_app_id);
command_line->AppendSwitchASCII(switches::kTizenAppVersion,
context->GetTizenAppVersion());
-
- double scale = context->GetWidgetScale();
- command_line->AppendSwitchASCII(switches::kWidgetScale,
- base::NumberToString(scale));
-
- const std::string& widget_theme = context->GetWidgetTheme();
- command_line->AppendSwitchASCII(switches::kWidgetTheme, widget_theme);
-
- const std::string& widget_encoded_bundle = context->GetWidgetEncodedBundle();
- command_line->AppendSwitchASCII(switches::kWidgetEncodedBundle,
- widget_encoded_bundle);
}
void DispatchPopupBlockedOnUIThread(int render_process_id,
#include "ewk_global_data.h"
#include "private/ewk_favicon_database_private.h"
#include "private/ewk_security_origin_private.h"
-#include "wrt/dynamicplugin.h"
#include "wrt/wrt_widget_host.h"
#if BUILDFLAG(IS_TIZEN)
#if BUILDFLAG(IS_TIZEN_TV)
#include "common/application_type.h"
+#include "wrt/hbbtv_dynamicplugin.h"
+#include "wrt/hbbtv_widget_host.h"
#endif
using content::BrowserThread;
// because it is handled in crosswalk side in single process mode.
content::GetGenericZygote()->DropProcessPrivileges(tizen_app_id_);
}
-#if !defined(EWK_BRINGUP) // FIXME: m108 bringup
- // Set DynamicPlugin to convert file scheme(file://) for Tizen HbbTV.
+#if BUILDFLAG(IS_TIZEN_TV)
+ // Set DynamicPlugin to convert file scheme(file://) for HbbTV
// Important: WRT doesn't use 'injected bundle' anymore
- if (!tizen_app_id_.empty() && !injected_bundle_path_.empty()) {
- DynamicPlugin* plugin = &DynamicPlugin::Get(V8Widget::Type::WRT);
+ if (application_type_ == EWK_APPLICATION_TYPE_HBBTV &&
+ !injected_bundle_path_.empty()) {
+ auto* plugin = &HbbtvDynamicPlugin::Get();
plugin->Init(injected_bundle_path_);
}
-#endif // EWK_BRINGUP
+#endif // IS_TIZEN_TV
#endif // IS_TIZEN
}
break;
}
}
+
+void EWebContext::RegisterURLSchemesAsCORSEnabled(
+ const Eina_List* schemes_list) {
+ std::string schemes;
+ const Eina_List* it;
+ const void* scheme;
+ EINA_LIST_FOREACH(schemes_list, it, scheme) {
+ schemes += static_cast<const char*>(scheme);
+ schemes += ",";
+ }
+
+ HbbtvWidgetHost::Get().RegisterURLSchemesAsCORSEnabled(schemes);
+}
#endif
void EWebContext::SetMaxRefreshRate(int max_refresh_rate) {
#if BUILDFLAG(IS_TIZEN_TV)
void SetApplicationType(const Ewk_Application_Type application_type);
Ewk_Application_Type GetApplicationType() const { return application_type_; }
+ void RegisterURLSchemesAsCORSEnabled(const Eina_List* schemes_list);
#endif
void EnableAppControl(bool enabled);
Ewk_Application_Type Ewk_Context::GetApplicationType() const {
return impl->GetApplicationType();
}
+
+void Ewk_Context::RegisterURLSchemesAsCORSEnabled(
+ const Eina_List* schemes_list) {
+ impl->RegisterURLSchemesAsCORSEnabled(schemes_list);
+}
#endif
void Ewk_Context::SetMaxRefreshRate(int max_refresh_rate) {
// Application Type
void SetApplicationType(const Ewk_Application_Type application_type);
Ewk_Application_Type GetApplicationType() const;
+
+ // Registers url scheme as CORS enabled for HBBTV
+ void RegisterURLSchemesAsCORSEnabled(const Eina_List* schemes_list);
#endif
void EnableAppControl(bool enabled);
void ewk_context_register_url_schemes_as_cors_enabled(Ewk_Context* context, const Eina_List* schemes)
{
- LOG_EWK_API_MOCKUP();
+#if BUILDFLAG(IS_TIZEN_TV)
+ EINA_SAFETY_ON_NULL_RETURN(context);
+ EINA_SAFETY_ON_NULL_RETURN(schemes);
+ context->RegisterURLSchemesAsCORSEnabled(schemes);
+#else
+ LOG_EWK_API_MOCKUP("Only for Tizen TV");
+#endif
}
void ewk_context_register_jsplugin_mime_types(Ewk_Context* context, const Eina_List* mime_types)
if (command_line.HasSwitch(switches::kInjectedBundlePath)) {
V8Widget::Type type = V8Widget::Type::WRT;
+#if BUILDFLAG(IS_TIZEN_TV)
+ if (content::IsHbbTV())
+ type = V8Widget::Type::HBBTV;
+#endif
widget_.reset(V8Widget::CreateWidget(type, command_line));
if (widget_->GetObserver())
thread->AddObserver(widget_->GetObserver());
#include "base/logging.h"
#include "common/content_switches_efl.h"
#include "wrt/wrt_dynamicplugin.h"
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "wrt/hbbtv_dynamicplugin.h"
+#endif
namespace {
const char* const kStartSessionFunction = "DynamicPluginStartSession";
}
DynamicPlugin& DynamicPlugin::Get(V8Widget::Type type) {
+#if BUILDFLAG(IS_TIZEN_TV)
+ if (type == V8Widget::Type::HBBTV)
+ return HbbtvDynamicPlugin::Get();
+#endif
+ DCHECK_EQ(type, V8Widget::Type::WRT);
return WrtDynamicPlugin::Get();
}
virtual bool InitRenderer(const std::string& injected_bundle_path);
// Interface for WebApp URL Conversion
- virtual void SetWidgetInfo(const std::string& tizen_app_id) = 0;
+ virtual void SetWidgetInfo(const std::string& tizen_app_id) {};
virtual bool CanHandleParseUrl(const std::string& scheme) const = 0;
virtual void ParseURL(std::string* old_url,
std::string* new_url,
--- /dev/null
+// Copyright 2023 Samsung Electronics. All rights resemicPlugin::ParseURL
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "wrt/hbbtv_dynamicplugin.h"
+
+namespace {
+const char* const kHbbtvUrlParsingFunction = "DynamicHbbTVUrlParsing";
+const char* const kHbbtvGetFileDecryptedDataBuffer =
+ "DynamicHbbTVGetFileDecryptedDataBuffer";
+} // namespace
+
+HbbtvDynamicPlugin::HbbtvDynamicPlugin()
+ : DynamicPlugin(),
+ parse_hbbtv_url_(nullptr),
+ get_file_decrypted_data_buffer_(nullptr) {}
+
+bool HbbtvDynamicPlugin::Init(const std::string& injected_bundle_path) {
+ if (!DynamicPlugin::Init(injected_bundle_path))
+ return false;
+ parse_hbbtv_url_ =
+ reinterpret_cast<HbbtvParseUrlFun>(GetFunction(kHbbtvUrlParsingFunction));
+ get_file_decrypted_data_buffer_ =
+ reinterpret_cast<HbbtvGetFileDecryptedDataBufferFun>(
+ GetFunction(kHbbtvGetFileDecryptedDataBuffer));
+ return parse_hbbtv_url_ && get_file_decrypted_data_buffer_;
+}
+
+void HbbtvDynamicPlugin::ParseURL(std::string* old_url,
+ std::string* new_url,
+ const char* tizen_app_id,
+ bool* is_decrypted_file) {
+ if (!parse_hbbtv_url_)
+ return;
+
+ parse_hbbtv_url_(old_url, new_url, tizen_app_id, is_decrypted_file);
+}
+
+HbbtvDynamicPlugin::~HbbtvDynamicPlugin() {}
+
+HbbtvDynamicPlugin& HbbtvDynamicPlugin::Get() {
+ static HbbtvDynamicPlugin dynamic_plugin;
+ return dynamic_plugin;
+}
--- /dev/null
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EWK_EFL_INTEGRATION_WRT_HBBTV_DYNAMICPLUGIN_H_
+#define EWK_EFL_INTEGRATION_WRT_HBBTV_DYNAMICPLUGIN_H_
+
+#include <string>
+#include <vector>
+#include "wrt/dynamicplugin.h"
+
+typedef void (*HbbtvParseUrlFun)(std::string* old_url,
+ std::string* new_url,
+ const char* tizen_app_id,
+ bool* is_decrypted_file);
+typedef bool (*HbbtvGetFileDecryptedDataBufferFun)(const std::string* url,
+ std::vector<char>* data);
+
+class HbbtvDynamicPlugin : public DynamicPlugin {
+ public:
+ bool Init(const std::string& injected_bundle_path) override;
+ bool CanHandleParseUrl(const std::string& scheme) const override {
+ return true;
+ }
+ void ParseURL(std::string* old_url,
+ std::string* new_url,
+ const char* tizen_app_id,
+ bool* is_decrypted_file = nullptr) override;
+
+ static HbbtvDynamicPlugin& Get();
+ ~HbbtvDynamicPlugin() override;
+
+ private:
+ HbbtvDynamicPlugin();
+
+ HbbtvDynamicPlugin(const HbbtvDynamicPlugin&) = delete;
+ HbbtvDynamicPlugin& operator=(const HbbtvDynamicPlugin&) = delete;
+
+ HbbtvParseUrlFun parse_hbbtv_url_;
+ HbbtvGetFileDecryptedDataBufferFun get_file_decrypted_data_buffer_;
+};
+
+#endif // EWK_EFL_INTEGRATION_WRT_WRT_DYNAMICPLUGIN_H_
--- /dev/null
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "hbbtv_widget.h"
+
+#include "command_line_efl.h"
+#include "common/content_switches_efl.h"
+#include "common/render_messages_ewk.h"
+#include "content/public/renderer/render_thread.h"
+#include "content/renderer/render_thread_impl.h"
+#include "third_party/blink/public/web/web_security_policy.h"
+#include "wrt/hbbtv_dynamicplugin.h"
+
+class HbbtvRenderThreadObserver : public content::RenderThreadObserver {
+ public:
+ explicit HbbtvRenderThreadObserver(HbbtvWidget* hbbtv_widget)
+ : hbbtv_widget_(hbbtv_widget) {}
+
+ bool OnControlMessageReceived(const IPC::Message& message) override {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(HbbtvRenderThreadObserver, message)
+ IPC_MESSAGE_FORWARD(HbbtvMsg_RegisterURLSchemesAsCORSEnabled, hbbtv_widget_,
+ HbbtvWidget::RegisterURLSchemesAsCORSEnabled)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+ }
+
+ private:
+ HbbtvWidget* hbbtv_widget_;
+};
+
+HbbtvWidget::HbbtvWidget(const base::CommandLine& command_line)
+ : V8Widget(V8Widget::Type::HBBTV) {
+ DCHECK(content::RenderThread::Get())
+ << "HbbtvWidget must be constructed on the render thread";
+
+ id_ = command_line.GetSwitchValueASCII(switches::kTizenAppId);
+ if (id_.empty())
+ return;
+ observer_.reset(new HbbtvRenderThreadObserver(this));
+
+ std::string injected_bundle_path =
+ command_line.GetSwitchValueASCII(switches::kInjectedBundlePath);
+ CHECK(!injected_bundle_path.empty());
+ HbbtvDynamicPlugin::Get().InitRenderer(injected_bundle_path);
+ SetPlugin(&HbbtvDynamicPlugin::Get());
+
+ if (command_line.HasSwitch(switches::kCORSEnabledURLSchemes)) {
+ std::string cors_enabled_url_schemes =
+ command_line.GetSwitchValueASCII(switches::kCORSEnabledURLSchemes);
+ RegisterURLSchemesAsCORSEnabled(cors_enabled_url_schemes);
+ }
+}
+
+HbbtvWidget::~HbbtvWidget() {}
+
+content::RenderThreadObserver* HbbtvWidget::GetObserver() {
+ return observer_.get();
+}
+
+void HbbtvWidget::RegisterURLSchemesAsCORSEnabled(std::string schemes) {
+ LOG(INFO) << "schemes = " << schemes;
+ if (schemes_ == schemes)
+ return;
+
+ schemes_ = schemes;
+ std::stringstream stream(schemes);
+ std::string scheme;
+ while (std::getline(stream, scheme, ',')) {
+ blink::WebSecurityPolicy::RegisterURLSchemeAsCORSEnabled(
+ blink::WebString::FromUTF8(scheme));
+ }
+}
--- /dev/null
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EWK_EFL_INTEGRATION_WRT_HBBTV_WIDGET_H_
+#define EWK_EFL_INTEGRATION_WRT_HBBTV_WIDGET_H_
+
+#include <string>
+
+#include "content/public/renderer/render_thread_observer.h"
+#include "url/gurl.h"
+#include "wrt/v8widget.h"
+
+class HbbtvRenderThreadObserver;
+
+// Have to be created on the RenderThread.
+class HbbtvWidget : public V8Widget {
+ public:
+ HbbtvWidget(const base::CommandLine& command_line);
+ ~HbbtvWidget() override;
+
+ content::RenderThreadObserver* GetObserver() override;
+ void RegisterURLSchemesAsCORSEnabled(std::string scheme);
+
+ private:
+ std::string schemes_;
+ std::unique_ptr<HbbtvRenderThreadObserver> observer_;
+};
+
+#endif // EWK_EFL_INTEGRATION_WRT_HBBTV_WIDGET_H_
--- /dev/null
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "hbbtv_widget_host.h"
+
+#include "base/lazy_instance.h"
+#include "common/render_messages_ewk.h"
+#include "content/public/browser/render_process_host.h"
+
+using content::RenderProcessHost;
+
+HbbtvWidgetHost::HbbtvWidgetHost() {}
+
+HbbtvWidgetHost::~HbbtvWidgetHost() {}
+
+class HbbtvWidgetHostGetter {
+ public:
+ HbbtvWidgetHost& Host() { return host_; }
+
+ private:
+ HbbtvWidgetHost host_;
+};
+
+void SendToAllRenderers(IPC::Message* message) {
+ content::RenderProcessHost::iterator it =
+ content::RenderProcessHost::AllHostsIterator();
+ while (!it.IsAtEnd()) {
+ it.GetCurrentValue()->Send(new IPC::Message(*message));
+ it.Advance();
+ }
+ delete message;
+}
+
+base::LazyInstance<HbbtvWidgetHostGetter>::Leaky g_hbbtv_widget_host_getter =
+ LAZY_INSTANCE_INITIALIZER;
+
+HbbtvWidgetHost& HbbtvWidgetHost::Get() {
+ return g_hbbtv_widget_host_getter.Get().Host();
+}
+
+void HbbtvWidgetHost::RegisterURLSchemesAsCORSEnabled(
+ const std::string& schemes) {
+ if (cors_enabled_url_schemes_ == schemes)
+ return;
+
+ cors_enabled_url_schemes_ = schemes;
+ LOG(INFO) << "schemes = " << schemes;
+ SendToAllRenderers(
+ new HbbtvMsg_RegisterURLSchemesAsCORSEnabled(cors_enabled_url_schemes_));
+}
+
+const std::string& HbbtvWidgetHost::GetCORSEnabledURLSchemes() {
+ return cors_enabled_url_schemes_;
+}
--- /dev/null
+// Copyright 2023 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EWK_EFL_INTEGRATION_WRT_HBBTV_WIDGET_HOST
+#define EWK_EFL_INTEGRATION_WRT_HBBTV_WIDGET_HOST
+
+#include <string>
+
+class HbbtvWidgetHostGetter;
+
+class HbbtvWidgetHost {
+ public:
+ static HbbtvWidgetHost& Get();
+ ~HbbtvWidgetHost();
+
+ void RegisterURLSchemesAsCORSEnabled(const std::string& schemes);
+ const std::string& GetCORSEnabledURLSchemes();
+
+ private:
+ HbbtvWidgetHost();
+
+ std::string cors_enabled_url_schemes_;
+ friend class HbbtvWidgetHostGetter;
+};
+
+#endif // EWK_EFL_INTEGRATION_WRT_HBBTV_WIDGET_HOST
#include "base/notreached.h"
#include "wrt/dynamicplugin.h"
#include "wrt/wrtwidget.h"
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "wrt/hbbtv_widget.h"
+#endif
// static
V8Widget* V8Widget::CreateWidget(Type type,
const base::CommandLine& command_line) {
+#if BUILDFLAG(IS_TIZEN_TV)
+ if (type == Type::HBBTV)
+ return new HbbtvWidget(command_line);
+#endif
return new WrtWidget(command_line);
}
content::RenderProcessHost::iterator it =
content::RenderProcessHost::AllHostsIterator();
while (!it.IsAtEnd()) {
- if (it.GetCurrentValue()->Send(message))
+ if (it.GetCurrentValue()->Send(new IPC::Message(*message)))
result = true;
it.Advance();
}
+ delete message;
return result;
}