#if defined(OS_TIZEN)
LOG (ERROR) << "Set Injected bundle path to engine";
- command_line->AppendSwitchASCII("injected-bundle-path","/usr/lib/libxwalk_injected_bundle.so");
- std::vector<std::string> cmdAgrs = atom::AtomCommandLine::argv();
- std::string app_id = cmdAgrs[1];
+ command_line->AppendSwitchASCII(
+ "injected-bundle-path","/usr/lib/libxwalk_injected_bundle.so");
+ std::string app_id = common::CommandLine::ForCurrentProcess()->
+ GetAppIdFromCommandLine("/usr/bin/wrt");
command_line->AppendSwitchASCII("widget-id",app_id);
#endif
//}
}
-} // namespace runtime
\ No newline at end of file
+} // namespace runtime
void PWRT::Log(const std::string& message) {
std::string output = "[JS LOG] " + message;
- dlog_print(DLOG_INFO, "WRT", output.c_str());
+ dlog_print(DLOG_ERROR, "WRT", output.c_str());
}
// static
#include "atom/browser/api/atom_api_web_contents.h"
+#include <Eina.h>
#include <set>
#include <string>
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "ui/display/screen.h"
+#if defined(USE_EFL)
+#include "tizen/extensions/common/xwalk_extension_server.h"
+#endif
+
#if !defined(OS_MACOSX) && !defined(USE_EFL)
#include "ui/aura/window.h"
#endif
int32_t line_no,
const base::string16& source_id) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) {
- return false;
+ LOG(ERROR) << "Console Message : " << message << ", source:" << source_id << " (" << line_no << ")";
+ return true;
} else {
Emit("console-message", level, message, line_no, source_id);
return true;
Emit("devtools-closed");
}
+void WebContents::OnWrtPluginMessage(const Wrt_Message_Data& data) {
+ Wrt_Message_Data tmp = data;
+ HandleWrtPluginMessage(&tmp);
+}
+
+void WebContents::OnWrtPluginSyncMessage(const Wrt_Message_Data& data,
+ IPC::Message* reply) {
+ Wrt_Message_Data tmp = data;
+ HandleWrtPluginMessage(&tmp);
+ EwkHostMsg_WrtSyncMessage::WriteReplyParams(reply, tmp.value);
+ Send(reply);
+}
+
+void WebContents::HandleWrtPluginMessage(Wrt_Message_Data* msg) {
+ Eina_Stringshare* msg_type = msg->GetType();
+
+#define TYPE_BEGIN(x) (!strncmp(msg_type, x, strlen(x)))
+#define TYPE_IS(x) (!strcmp(msg_type, x))
+
+ if (TYPE_BEGIN("xwalk://")) {
+ auto extension_server = extensions::XWalkExtensionServer::GetInstance();
+ extension_server->HandleIPCMessage(msg);
+ } else {
+ // implement in future
+ }
+}
+
bool WebContents::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
OnSetTemporaryZoomLevel)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_GetZoomLevel,
OnGetZoomLevel)
-
+ IPC_MESSAGE_HANDLER(EwkHostMsg_WrtMessage, OnWrtPluginMessage)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(EwkHostMsg_WrtSyncMessage, OnWrtPluginSyncMessage)
// FIXME: Disable OnCursorChange due to stach_chk_fail crash.
// IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
// handled = false)
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/favicon_url.h"
#include "native_mate/handle.h"
+#include "tizen/common/wrt_message_data.h"
#include "ui/gfx/image/image.h"
namespace blink {
v8::Local<v8::Value> Debugger(v8::Isolate* isolate);
WebContentsZoomController* GetZoomController() { return zoom_controller_; }
-
+ void OnWrtPluginMessage(const Wrt_Message_Data& data);
+ void OnWrtPluginSyncMessage(const Wrt_Message_Data& data,
+ IPC::Message* reply);
+ void HandleWrtPluginMessage(Wrt_Message_Data* msg);
protected:
WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
static const char* const kCommonSwitchNames[] = {
switches::kStandardSchemes,
switches::kEnableSandbox,
- switches::kSecureSchemes
+ switches::kSecureSchemes,
+ switches::kInjectedBundlePath,
+ switches::kTizenAppId,
+ switches::kWidgetScale,
+ switches::kWidgetTheme,
+ switches::kWidgetEncodedBundle
};
command_line->CopySwitchesFrom(
*base::CommandLine::ForCurrentProcess(),
#include "base/values.h"
#include "content/public/common/common_param_traits.h"
#include "ipc/ipc_message_macros.h"
+#include "tizen/common/wrt_message_data.h"
#include "ui/gfx/ipc/gfx_param_traits.h"
// The message starter should be declared in ipc/ipc_message_start.h. Since
IPC_STRUCT_TRAITS_MEMBER(bounds)
IPC_STRUCT_TRAITS_END()
+IPC_STRUCT_TRAITS_BEGIN(Wrt_Message_Data)
+ IPC_STRUCT_TRAITS_MEMBER(type)
+ IPC_STRUCT_TRAITS_MEMBER(value)
+ IPC_STRUCT_TRAITS_MEMBER(id)
+ IPC_STRUCT_TRAITS_MEMBER(reference_id)
+IPC_STRUCT_TRAITS_END()
+
IPC_MESSAGE_ROUTED2(AtomViewHostMsg_Message,
base::string16 /* channel */,
base::ListValue /* arguments */)
// Sent by renderer to get the zoom level.
IPC_SYNC_MESSAGE_ROUTED0_1(AtomViewHostMsg_GetZoomLevel, double /* result */)
+
+IPC_MESSAGE_ROUTED1(EwkHostMsg_WrtMessage,
+ Wrt_Message_Data /* data */)
+
+IPC_MESSAGE_CONTROL1(WrtMsg_SendWrtMessage,
+ Wrt_Message_Data /* data */)
+
+IPC_MESSAGE_CONTROL2(WrtMsg_ParseUrl,
+ int, // result: request_id
+ GURL) // result: url
+
+IPC_MESSAGE_CONTROL2(WrtMsg_ParseUrlResponse,
+ int, // result: request_id
+ GURL) // result: url
+
+IPC_SYNC_MESSAGE_ROUTED1_1(EwkHostMsg_WrtSyncMessage,
+ Wrt_Message_Data /* data */,
+ std::string /*result*/)
// Widevine CDM version.
const char kWidevineCdmVersion[] = "widevine-cdm-version";
+const char kInjectedBundlePath[] = "injected-bundle-path";
+// Widget Info
+const char kTizenAppId[] = "widget-id";
+const char kWidgetScale[] = "widget-scale";
+const char kWidgetTheme[] = "widget-theme";
+const char kWidgetEncodedBundle[] = "widget-encoded-bundle";
+
} // namespace switches
} // namespace atom
extern const char kWidevineCdmPath[];
extern const char kWidevineCdmVersion[];
+extern const char kInjectedBundlePath[];
+extern const char kTizenAppId[];
+extern const char kWidgetScale[];
+extern const char kWidgetTheme[];
+extern const char kWidgetEncodedBundle[];
} // namespace switches
} // namespace atom
#if defined(USE_EFL)
#include "atom/common/atom_command_line.h"
+#include "base/strings/string_number_conversions.h"
+#include "content/common/wrt/wrt_url_parse.h"
+#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/render_view.h"
+#include "third_party/WebKit/public/web/WebView.h"
#endif
#include "atom_natives.h" // NOLINT: This file is generated with js2c
} // namespace
+class WrtUrlParseImpl : public content::WrtUrlParseBase {
+ public:
+ WrtUrlParseImpl(WrtWidget* wrt_widget) : wrt_widget_(wrt_widget) {}
+ GURL parseUrl(const GURL& old_url) const override {
+ if (!wrt_widget_->IsWidgetInfoSet())
+ return old_url;
+ GURL new_url;
+ bool is_decrypted_file = false;
+ wrt_widget_->ParseUrl(old_url, new_url, is_decrypted_file);
+ return new_url;
+ }
+
+ private:
+ WrtWidget* wrt_widget_;
+};
+
AtomRendererClient::AtomRendererClient()
: node_integration_initialized_(false),
node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)),
base::CommandLine::StringVector argv = command_line->argv();
const char** c_argv = StringVectorToArgArray(argv);
atom::AtomCommandLine::Init(argv.size(), c_argv);
+ std::string tizen_app_id = command_line->GetSwitchValueASCII(
+ "widget-id");
+
+ WrtWidget* wrt_widget = new WrtWidget;
+ if (wrt_widget == nullptr) {
+ return;
+ }
+ widget_.reset(wrt_widget);
+ content::RenderThread* thread = content::RenderThread::Get();
+ thread->AddObserver(wrt_widget->GetObserver());
+ wrt_url_parser_.reset(new WrtUrlParseImpl(wrt_widget));
+ std::string theme = command_line->GetSwitchValueASCII("widget-theme");
+ std::string encoded_bundle = command_line->GetSwitchValueASCII("widget-encoded-bundle");
+ std::string scale = command_line->GetSwitchValueASCII("widget-scale");
+ double scale_factor = 0;
+ base::StringToDouble(scale, &scale_factor);
+ wrt_widget->SetWidgetInfo(tizen_app_id, scale_factor, theme,
+ encoded_bundle);
#endif
OverrideNodeArrayBuffer();
RendererClientBase::RenderThreadStarted();
// Give the node loop a run to make sure everything is ready.
node_bindings_->RunMessageLoop();
}
+#if defined(USE_EFL)
+ if (widget_) {
+ const content::RenderView* render_view = render_frame->GetRenderView();
+ widget_->StartSession(context, render_view->GetRoutingID(),
+ render_frame->GetWebFrame()->document().baseURL().string().utf8().c_str());
+ }
+#endif
}
void AtomRendererClient::WillReleaseScriptContext(
// Destroy the node environment.
node::FreeEnvironment(env);
atom_bindings_->EnvironmentDestroyed(env);
+#if defined(USE_EFL)
+ if (widget_)
+ widget_->StopSession(context);
+#endif
}
bool AtomRendererClient::ShouldFork(blink::WebLocalFrame* frame,
#include <vector>
#include "atom/renderer/renderer_client_base.h"
+#include "tizen/wrt/wrtwidget.h"
namespace atom {
class AtomBindings;
class NodeBindings;
+class WrtUrlParseImpl;
class AtomRendererClient : public RendererClientBase {
public:
MANUAL_ENABLE_IFRAME,
DISABLE,
};
-
+ std::unique_ptr<V8Widget> widget_;
+ std::unique_ptr<WrtUrlParseImpl> wrt_url_parser_;
// content::ContentRendererClient:
void RenderThreadStarted() override;
void RenderFrameCreated(content::RenderFrame*) override;
install -p -m 644 %{_out}/lib/libxwalk_extension_shared.so %{buildroot}%{_libdir}
# xwalk_injected_bundle
install -p -m 755 %{_out}/lib/libxwalk_injected_bundle.so %{buildroot}%{_libdir}
-
+# wrt chromium shared
+install -p -m 644 %{_out}/lib/libchromium_wrt_shared.so %{buildroot}%{_libdir}
%post
# Owner account can't write /opt/usr/home/owner/data/org.tizen.electron-efl
# which is created in 'install'. So we should copy resources in 'post'.
%attr(644,root,root) %{_libdir}/libwrt_common.so
%attr(644,root,root) %{_libdir}/libxwalk_extension_shared.so
%attr(644,root,root) %{_libdir}/libxwalk_injected_bundle.so
+%attr(644,root,root) %{_libdir}/libchromium_wrt_shared.so
'-L./lib',
],
},
-}
\ No newline at end of file
+}
'resource_manager.cc',
'platform_info.h',
'platform_info.cc',
+ 'wrt_message_data.h',
+ 'wrt_message_data.cc',
],
'cflags': [
'-fvisibility=default',
'capi-system-info',
'cynara-client',
'dlog',
+ 'elementary',
'uuid',
'libwebappenc',
'manifest-parser',
--- /dev/null
+#include "wrt_message_data.h"
+
+Wrt_Message_Data::Wrt_Message_Data() {}
+
+Wrt_Message_Data::~Wrt_Message_Data() {}
+
+Eina_Stringshare* Wrt_Message_Data::GetType() const {
+ return eina_stringshare_add(type.c_str());
+}
+
+void Wrt_Message_Data::SetType(const char* val) {
+ type = val;
+}
+
+Eina_Stringshare* Wrt_Message_Data::GetValue() const {
+ return eina_stringshare_add(value.c_str());
+}
+
+void Wrt_Message_Data::SetValue(const char* val) {
+ value = val;
+}
+
+Eina_Stringshare* Wrt_Message_Data::GetId() const {
+ return eina_stringshare_add(id.c_str());
+}
+
+void Wrt_Message_Data::SetId(const char* val) {
+ id = val;
+}
+
+Eina_Stringshare* Wrt_Message_Data::GetReferenceId() const {
+ return eina_stringshare_add(reference_id.c_str());
+}
+
+void Wrt_Message_Data::SetReferenceId(const char* val) {
+ reference_id = val;
+}
+
--- /dev/null
+#ifndef WRT_MESSAGE_DATA_H
+#define WRT_MESSAGE_DATA_H
+
+#include <string>
+#include <Eina.h>
+
+struct Wrt_Message_Data {
+ std::string type;
+ std::string value;
+ std::string id;
+ std::string reference_id;
+
+ Wrt_Message_Data();
+ ~Wrt_Message_Data();
+ const Eina_Stringshare* GetType() const;
+ void SetType(const char* val);
+ const Eina_Stringshare* GetValue() const;
+ void SetValue(const char* val);
+ const Eina_Stringshare* GetId() const;
+ void SetId(const char* val);
+ const Eina_Stringshare* GetReferenceId() const;
+ void SetReferenceId(const char* val);
+};
+
+#endif // WRT_MESSAGE_DATA_H
+
const char kMethodPostMessage[] = "xwalk://PostMessage";
const char kMethodGetAPIScript[] = "xwalk://GetAPIScript";
const char kMethodPostMessageToJS[] = "xwalk://PostMessageToJS";
-
+const char kMethodLoadUserExtensions[] = "xwalk://LoadUserExtensions";
} // namespace extensions
extern const char kMethodPostMessage[];
extern const char kMethodGetAPIScript[];
extern const char kMethodPostMessageToJS[];
+extern const char kMethodLoadUserExtensions[];
} // namespace extensions
#include "extensions/common/xwalk_extension_instance.h"
+#include "common/logger.h"
#include "extensions/common/xwalk_extension_adapter.h"
#include "extensions/public/XW_Extension_SyncMessage.h"
#include <string>
+#include "atom/common/api/api_messages.h"
#include "common/logger.h"
#include "common/profiler.h"
#include "common/string_utils.h"
+#include "content/public/browser/render_process_host.h"
#include "extensions/common/constants.h"
#include "extensions/common/xwalk_extension_manager.h"
+#include "wrt/wrt_widget_host.h"
namespace extensions {
XWalkExtensionServer::~XWalkExtensionServer() {
}
-void XWalkExtensionServer::SetupIPC(Ewk_Context* ewk_context) {
- ewk_context_ = ewk_context;
-}
-
void XWalkExtensionServer::Preload() {
manager_.PreloadExtensions();
}
std::string XWalkExtensionServer::CreateInstance(
const std::string& extension_name) {
std::string instance_id;
-
auto extensions = manager_.extensions();
auto it = extensions.find(extension_name);
if (it != extensions.end()) {
instance_id = common::utils::GenerateUUID();
instance->SetPostMessageCallback(
[this, instance_id](const std::string& msg) {
- Ewk_IPC_Wrt_Message_Data* ans = ewk_ipc_wrt_message_data_new();
- ewk_ipc_wrt_message_data_type_set(ans, kMethodPostMessageToJS);
- ewk_ipc_wrt_message_data_id_set(ans, instance_id.c_str());
- ewk_ipc_wrt_message_data_value_set(ans, msg.c_str());
- if (!ewk_ipc_wrt_message_send(ewk_context_, ans)) {
- LOGGER(ERROR) << "Failed to send response";
- }
- ewk_ipc_wrt_message_data_del(ans);
+ Wrt_Message_Data* ans = new Wrt_Message_Data();
+ ans->SetType(kMethodPostMessageToJS);
+ ans->SetId(instance_id.c_str());
+ ans->SetValue(msg.c_str());
+ WrtWidgetHost::Get()->SendWrtMessage(*ans);
+ delete ans;
});
instances_[instance_id] = instance;
} else {
LOGGER(ERROR) << "No such extension '" << extension_name << "'";
}
+ LOGGER(ERROR) << instance_id;
return instance_id;
}
-void XWalkExtensionServer::HandleIPCMessage(Ewk_IPC_Wrt_Message_Data* data) {
+void XWalkExtensionServer::HandleIPCMessage(Wrt_Message_Data* data) {
if (!data) {
LOGGER(ERROR) << "Invalid parameter. data is NULL.";
return;
}
-
- if (!ewk_context_) {
- LOGGER(WARN) << "IPC is not ready yet.";
- return;
- }
-
- Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(data);
+ Eina_Stringshare* msg_type = data->GetType();
#define TYPE_IS(x) (!strcmp(msg_type, x))
if (TYPE_IS(kMethodGetExtensions)) {
#undef TYPE_IS
}
-void XWalkExtensionServer::HandleGetExtensions(Ewk_IPC_Wrt_Message_Data* data) {
+void XWalkExtensionServer::HandleGetExtensions(Wrt_Message_Data* data) {
Json::Value reply = GetExtensions();
Json::FastWriter writer;
std::string reply_str = writer.write(reply);
- ewk_ipc_wrt_message_data_value_set(data, reply_str.c_str());
+ data->SetValue(reply_str.c_str());
}
void XWalkExtensionServer::HandleCreateInstance(
- Ewk_IPC_Wrt_Message_Data* data) {
- Eina_Stringshare* extension_name = ewk_ipc_wrt_message_data_value_get(data);
+ Wrt_Message_Data* data) {
+ Eina_Stringshare* extension_name = data->GetValue();
std::string instance_id = CreateInstance(extension_name);
- ewk_ipc_wrt_message_data_value_set(data, instance_id.c_str());
+ data->SetValue(instance_id.c_str());
eina_stringshare_del(extension_name);
}
void XWalkExtensionServer::HandleDestroyInstance(
- Ewk_IPC_Wrt_Message_Data* data) {
- Eina_Stringshare* instance_id = ewk_ipc_wrt_message_data_id_get(data);
+ Wrt_Message_Data* data) {
+ Eina_Stringshare* instance_id = data->GetId();
auto it = instances_.find(instance_id);
if (it != instances_.end()) {
}
void XWalkExtensionServer::HandlePostMessageToNative(
- Ewk_IPC_Wrt_Message_Data* data) {
- Eina_Stringshare* instance_id = ewk_ipc_wrt_message_data_id_get(data);
+ Wrt_Message_Data* data) {
+ Eina_Stringshare* instance_id = data->GetId();
auto it = instances_.find(instance_id);
if (it != instances_.end()) {
- Eina_Stringshare* msg = ewk_ipc_wrt_message_data_value_get(data);
+ Eina_Stringshare* msg = data->GetValue();
XWalkExtensionInstance* instance = it->second;
instance->HandleMessage(msg);
eina_stringshare_del(msg);
}
void XWalkExtensionServer::HandleSendSyncMessageToNative(
- Ewk_IPC_Wrt_Message_Data* data) {
- Eina_Stringshare* instance_id = ewk_ipc_wrt_message_data_id_get(data);
+ Wrt_Message_Data* data) {
+ Eina_Stringshare* instance_id = data->GetId();
auto it = instances_.find(instance_id);
if (it != instances_.end()) {
- Eina_Stringshare* msg = ewk_ipc_wrt_message_data_value_get(data);
+ Eina_Stringshare* msg = data->GetValue();
XWalkExtensionInstance* instance = it->second;
std::string reply;
instance->SetSendSyncReplyCallback([&reply](const std::string& msg) {
reply = msg;
});
instance->HandleSyncMessage(msg);
- ewk_ipc_wrt_message_data_value_set(data, reply.c_str());
+ data->SetValue(reply.c_str());
eina_stringshare_del(msg);
} else {
LOGGER(ERROR) << "No such instance '" << instance_id << "'";
}
void XWalkExtensionServer::HandleGetAPIScript(
- Ewk_IPC_Wrt_Message_Data* data) {
- Eina_Stringshare* extension_name = ewk_ipc_wrt_message_data_value_get(data);
+ Wrt_Message_Data* data) {
+ Eina_Stringshare* extension_name = data->GetValue();
std::string api = GetAPIScript(extension_name);
- ewk_ipc_wrt_message_data_value_set(data, api.c_str());
+ data->SetValue(api.c_str());
eina_stringshare_del(extension_name);
}
#ifndef XWALK_EXTENSIONS_XWALK_EXTENSION_SERVER_H_
#define XWALK_EXTENSIONS_XWALK_EXTENSION_SERVER_H_
-#include <EWebKit.h>
-#include <EWebKit_internal.h>
#include <json/json.h>
#include <string>
#include <map>
-
+#include "common/wrt_message_data.h"
#include "extensions/common/xwalk_extension_manager.h"
#include "extensions/common/xwalk_extension_instance.h"
public:
static XWalkExtensionServer* GetInstance();
- void SetupIPC(Ewk_Context* ewk_context);
void Preload();
Json::Value GetExtensions();
std::string GetAPIScript(const std::string& extension_name);
std::string CreateInstance(const std::string& extension_name);
- void HandleIPCMessage(Ewk_IPC_Wrt_Message_Data* data);
+ void HandleIPCMessage(Wrt_Message_Data* data);
void Shutdown();
void LoadUserExtensions(const std::string app_path);
XWalkExtensionServer();
virtual ~XWalkExtensionServer();
- void HandleGetExtensions(Ewk_IPC_Wrt_Message_Data* data);
- void HandleCreateInstance(Ewk_IPC_Wrt_Message_Data* data);
- void HandleDestroyInstance(Ewk_IPC_Wrt_Message_Data* data);
- void HandlePostMessageToNative(Ewk_IPC_Wrt_Message_Data* data);
- void HandleSendSyncMessageToNative(Ewk_IPC_Wrt_Message_Data* data);
- void HandleGetAPIScript(Ewk_IPC_Wrt_Message_Data* data);
+ void HandleGetExtensions(Wrt_Message_Data* data);
+ void HandleCreateInstance(Wrt_Message_Data* data);
+ void HandleDestroyInstance(Wrt_Message_Data* data);
+ void HandlePostMessageToNative(Wrt_Message_Data* data);
+ void HandleSendSyncMessageToNative(Wrt_Message_Data* data);
+ void HandleGetAPIScript(Wrt_Message_Data* data);
typedef std::map<std::string, XWalkExtensionInstance*> InstanceMap;
- Ewk_Context* ewk_context_;
-
XWalkExtensionManager manager_;
InstanceMap instances_;
'elementary',
],
},
+ 'include_dirs': [
+ '.',
+ '../..',
+ '<(libchromiumcontent_src_dir)',
+ '<(SHARED_INTERMEDIATE_DIR)',
+ '<(libchromiumcontent_src_dir)/gen',
+ '<(libchromiumcontent_src_dir)/third_party/skia/include/config',
+ '<(libchromiumcontent_src_dir)/third_party/skia/include/core',
+ ],
'direct_dependent_settings': {
# 'libraries': [
# '-lxwalk_extension_shared',
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <Eina.h>
#include "extensions/renderer/runtime_ipc_client.h"
#include "extensions/renderer/xwalk_extension_renderer_controller.h"
+#include "atom/common/api/api_messages.h"
#include "common/logger.h"
#include "common/profiler.h"
#include "common/string_utils.h"
+#include "content/public/renderer/render_view.h"
namespace extensions {
return;
}
- Ewk_IPC_Wrt_Message_Data* msg = ewk_ipc_wrt_message_data_new();
- ewk_ipc_wrt_message_data_type_set(msg, type.c_str());
- ewk_ipc_wrt_message_data_id_set(msg, id.c_str());
- ewk_ipc_wrt_message_data_reference_id_set(msg, ref_id.c_str());
- ewk_ipc_wrt_message_data_value_set(msg, value.c_str());
-
- if (!ewk_ipc_plugins_message_send(routing_id, msg)) {
- LOGGER(ERROR) << "Failed to send message to runtime using ewk_ipc.";
- }
-
- ewk_ipc_wrt_message_data_del(msg);
+ Wrt_Message_Data* msg = new Wrt_Message_Data();
+ msg->SetType(type.c_str());
+ msg->SetId(id.c_str());
+ msg->SetValue(value.c_str());
+ msg->SetReferenceId(ref_id.c_str());
+ content::RenderView* render_view =
+ content::RenderView::FromRoutingID(routing_id);
+ render_view->Send(
+ new EwkHostMsg_WrtMessage(render_view->GetRoutingID(), *msg));
+ delete msg;
}
std::string RuntimeIPCClient::SendSyncMessage(v8::Handle<v8::Context> context,
return std::string();
}
- Ewk_IPC_Wrt_Message_Data* msg = ewk_ipc_wrt_message_data_new();
- ewk_ipc_wrt_message_data_type_set(msg, type.c_str());
- ewk_ipc_wrt_message_data_id_set(msg, id.c_str());
- ewk_ipc_wrt_message_data_reference_id_set(msg, ref_id.c_str());
- ewk_ipc_wrt_message_data_value_set(msg, value.c_str());
-
- if (!ewk_ipc_plugins_sync_message_send(routing_id, msg)) {
- LOGGER(ERROR) << "Failed to send message to runtime using ewk_ipc.";
- ewk_ipc_wrt_message_data_del(msg);
- return std::string();
- }
-
- Eina_Stringshare* msg_value = ewk_ipc_wrt_message_data_value_get(msg);
+ Wrt_Message_Data* msg = new Wrt_Message_Data();
+ msg->SetType(type.c_str());
+ msg->SetId(id.c_str());
+ msg->SetValue(value.c_str());
+ msg->SetReferenceId(ref_id.c_str());
+ content::RenderView* render_view =
+ content::RenderView::FromRoutingID(routing_id);
+ render_view->Send(
+ new EwkHostMsg_WrtSyncMessage(render_view->GetRoutingID(), *msg, &msg->value));
+ Eina_Stringshare* msg_value = msg->GetValue();
std::string result(msg_value);
eina_stringshare_del(msg_value);
- ewk_ipc_wrt_message_data_del(msg);
+ delete msg;
return result;
}
std::string msg_id = common::utils::GenerateUUID();
- Ewk_IPC_Wrt_Message_Data* msg = ewk_ipc_wrt_message_data_new();
- ewk_ipc_wrt_message_data_id_set(msg, msg_id.c_str());
- ewk_ipc_wrt_message_data_type_set(msg, type.c_str());
- ewk_ipc_wrt_message_data_value_set(msg, value.c_str());
-
- if (!ewk_ipc_plugins_message_send(routing_id, msg)) {
- LOGGER(ERROR) << "Failed to send message to runtime using ewk_ipc.";
- ewk_ipc_wrt_message_data_del(msg);
- return;
- }
-
+ Wrt_Message_Data* msg = new Wrt_Message_Data();
+ msg->SetType(type.c_str());
+ msg->SetId(msg_id.c_str());
+ msg->SetValue(value.c_str());
+ content::RenderView* render_view =
+ content::RenderView::FromRoutingID(routing_id);
+ render_view->Send(
+ new EwkHostMsg_WrtMessage(render_view->GetRoutingID(), *msg));
callbacks_[msg_id] = callback;
- ewk_ipc_wrt_message_data_del(msg);
+ delete msg;
}
void RuntimeIPCClient::HandleMessageFromRuntime(
- const Ewk_IPC_Wrt_Message_Data* msg) {
+ const Wrt_Message_Data* msg) {
if (msg == NULL) {
LOGGER(ERROR) << "received message is NULL";
return;
}
- Eina_Stringshare* msg_refid = ewk_ipc_wrt_message_data_reference_id_get(msg);
+ Eina_Stringshare* msg_refid = msg->GetReferenceId();
if (msg_refid == NULL || !strcmp(msg_refid, "")) {
if (msg_refid) eina_stringshare_del(msg_refid);
return;
}
- Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(msg);
- Eina_Stringshare* msg_value = ewk_ipc_wrt_message_data_value_get(msg);
+ Eina_Stringshare* msg_type = msg->GetType();
+ Eina_Stringshare* msg_value = msg->GetValue();
ReplyCallback func = it->second;
if (func) {
#define XWALK_EXTENSIONS_RENDERER_RUNTIME_IPC_CLIENT_H_
#include <v8/v8.h>
-#include <EWebKit.h>
-#include <EWebKit_internal.h>
#include <functional>
#include <map>
#include <string>
+#include "common/wrt_message_data.h"
namespace extensions {
const std::string& type, const std::string& value,
ReplyCallback callback);
- void HandleMessageFromRuntime(const Ewk_IPC_Wrt_Message_Data* msg);
+ void HandleMessageFromRuntime(const Wrt_Message_Data* msg);
int GetRoutingId(v8::Handle<v8::Context> context);
#include "extensions/renderer/xwalk_extension_client.h"
#include <Ecore.h>
+#include <json/json.h>
#include <unistd.h>
#include <v8/v8.h>
-#include <json/json.h>
#include <string>
+#include "base/command_line.h"
#include "common/logger.h"
#include "common/profiler.h"
#include "common/string_utils.h"
+#include "content/public/common/content_switches.h"
#include "extensions/common/constants.h"
#include "extensions/common/xwalk_extension_server.h"
#include "extensions/renderer/runtime_ipc_client.h"
extension_apis_.clear();
}
-void XWalkExtensionClient::Initialize() {
+void XWalkExtensionClient::Initialize(v8::Handle<v8::Context> context) {
SCOPE_PROFILE();
if (!extension_apis_.empty()) {
return;
}
-
- XWalkExtensionServer* server = XWalkExtensionServer::GetInstance();
- Json::Value reply = server->GetExtensions();
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ Json::Value reply;
+ if (command_line->HasSwitch(switches::kSingleProcess)) {
+ XWalkExtensionServer* server = XWalkExtensionServer::GetInstance();
+ reply = server->GetExtensions();
+ } else {
+ RuntimeIPCClient* ipc = RuntimeIPCClient::GetInstance();
+ std::string extension_info =ipc->SendSyncMessage(context, kMethodGetExtensions, "", "");
+ Json::Reader reader;
+ reader.parse(extension_info, reply, false);
+ }
for (auto it = reply.begin(); it != reply.end(); ++it) {
ExtensionCodePoints* codepoint = new ExtensionCodePoints;
Json::Value entry_points = (*it)["entry_points"];
std::string XWalkExtensionClient::CreateInstance(
v8::Handle<v8::Context> context,
const std::string& extension_name, InstanceHandler* handler) {
- void* ret = ecore_main_loop_thread_safe_call_sync(
- CreateInstanceInMainloop,
- static_cast<void*>(const_cast<char*>(extension_name.data())));
- std::string* sp = static_cast<std::string*>(ret);
- std::string instance_id = *sp;
- delete sp;
-
+ std::string instance_id;
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kSingleProcess)) {
+ void* ret = ecore_main_loop_thread_safe_call_sync(
+ CreateInstanceInMainloop,
+ static_cast<void*>(const_cast<char*>(extension_name.data())));
+ std::string* sp = static_cast<std::string*>(ret);
+ instance_id = *sp;
+ delete sp;
+ } else {
+ RuntimeIPCClient* ipc = RuntimeIPCClient::GetInstance();
+ instance_id =ipc->SendSyncMessage(
+ context, kMethodCreateInstance, "", extension_name.data());
+ }
handlers_[instance_id] = handler;
return instance_id;
}
std::string XWalkExtensionClient::GetAPIScript(
v8::Handle<v8::Context> context,
const std::string& extension_name) {
- XWalkExtensionServer* server = XWalkExtensionServer::GetInstance();
- return server->GetAPIScript(extension_name);
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kSingleProcess)) {
+ XWalkExtensionServer* server = XWalkExtensionServer::GetInstance();
+ return server->GetAPIScript(extension_name);
+ } else {
+ RuntimeIPCClient* ipc = RuntimeIPCClient::GetInstance();
+ std::string reply = ipc->SendSyncMessage(
+ context, kMethodGetAPIScript, "", extension_name.data());
+ return reply;
+ }
}
void XWalkExtensionClient::OnReceivedIPCMessage(
XWalkExtensionClient();
virtual ~XWalkExtensionClient();
- void Initialize();
+ void Initialize(v8::Handle<v8::Context> context);
std::string CreateInstance(v8::Handle<v8::Context> context,
const std::string& extension_name,
"objecttools",
std::unique_ptr<XWalkNativeModule>(new ObjectToolsModule));
- extensions_client_->Initialize();
+ extensions_client_->Initialize(context);
CreateExtensionModules(extensions_client_.get(), module_system);
module_system->Initialize();
}
void XWalkExtensionRendererController::OnReceivedIPCMessage(
- const Ewk_IPC_Wrt_Message_Data* data) {
+ const Wrt_Message_Data* data) {
- Eina_Stringshare* type = ewk_ipc_wrt_message_data_type_get(data);
+ Eina_Stringshare* type = data->GetType();
#define TYPE_BEGIN(x) (!strncmp(type, x, strlen(x)))
if (TYPE_BEGIN("xwalk://")) {
- Eina_Stringshare* id = ewk_ipc_wrt_message_data_id_get(data);
- Eina_Stringshare* msg = ewk_ipc_wrt_message_data_value_get(data);
+ Eina_Stringshare* id = data->GetId();
+ Eina_Stringshare* msg = data->GetValue();
extensions_client_->OnReceivedIPCMessage(id, msg);
eina_stringshare_del(id);
eina_stringshare_del(msg);
}
void XWalkExtensionRendererController::InitializeExtensionClient() {
- extensions_client_->Initialize();
+// extensions_client_->Initialize();
}
void XWalkExtensionRendererController::LoadUserExtensions(
#ifndef XWALK_EXTENSIONS_RENDERER_XWALK_EXTENSION_RENDERER_CONTROLLER_H_
#define XWALK_EXTENSIONS_RENDERER_XWALK_EXTENSION_RENDERER_CONTROLLER_H_
-#include <EWebKit.h>
-#include <EWebKit_internal.h>
#include <v8/v8.h>
#include <memory>
#include <string>
+#include "common/wrt_message_data.h"
namespace extensions {
void DidCreateScriptContext(v8::Handle<v8::Context> context);
void WillReleaseScriptContext(v8::Handle<v8::Context> context);
- void OnReceivedIPCMessage(const Ewk_IPC_Wrt_Message_Data* data);
+ void OnReceivedIPCMessage(const Wrt_Message_Data* data);
void InitializeExtensionClient();
void LoadUserExtensions(const std::string app_path);
*/
#include <Ecore.h>
-#include <EWebKit.h>
-#include <EWebKit_internal.h>
#include <unistd.h>
#include <v8.h>
#include <dlfcn.h>
#include "common/profiler.h"
#include "common/resource_manager.h"
#include "common/string_utils.h"
+#include "common/wrt_message_data.h"
#include "extensions/renderer/runtime_ipc_client.h"
#include "extensions/renderer/widget_module.h"
#include "extensions/renderer/xwalk_extension_renderer_controller.h"
// LOGGER(DEBUG) << "InjectedBundle::DynamicDatabaseAttach !!";
}
-extern "C" void DynamicOnIPCMessage(const Ewk_IPC_Wrt_Message_Data& data) {
+extern "C" void DynamicOnIPCMessage(const Wrt_Message_Data& data) {
SCOPE_PROFILE();
extensions::XWalkExtensionRendererController& controller =
extensions::XWalkExtensionRendererController::GetInstance();
--- /dev/null
+{
+ 'includes':[
+ '../build/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'chromium_wrt_shared',
+ 'type': 'shared_library',
+ 'sources': [
+ "dynamicplugin.cc",
+ "dynamicplugin.h",
+ "v8widget.cc",
+ "v8widget.h",
+ "wrtwidget.cc",
+ "wrtwidget.h",
+ "wrt_dynamicplugin.cc",
+ "wrt_dynamicplugin.h",
+ "wrt_file_protocol_handler.cc",
+ "wrt_file_protocol_handler.h",
+ "wrt_widget_host.cc",
+ "wrt_widget_host.h",
+ ],
+ 'cflags': [
+ '-fvisibility=default',
+ ],
+ 'variables': {
+ 'packages': [
+ 'chromium-efl',
+ 'elementary',
+ ],
+ },
+ 'include_dirs': [
+ '.',
+ '../',
+ '../..',
+ '../tizen',
+ '<(libchromiumcontent_src_dir)',
+ '<(SHARED_INTERMEDIATE_DIR)',
+ '<(libchromiumcontent_src_dir)/gen',
+ '<(libchromiumcontent_src_dir)/third_party/skia/include/config',
+ '<(libchromiumcontent_src_dir)/third_party/skia/include/core',
+ ],
+ 'direct_dependent_settings': {
+# 'libraries': [
+# '-lchromium_wrt_shared',
+# ],
+ 'variables': {
+ 'packages': [
+ 'jsoncpp',
+ ],
+ },
+ },
+ }, # end of target 'xwalk_extension_static'
+ ], # end of targets
+}
--- /dev/null
+// Copyright 2014 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 "dynamicplugin.h"
+
+#include <dlfcn.h>
+
+#include "base/command_line.h"
+#include "base/logging.h"
+
+namespace {
+const char* const VERSION_FUNCTION = "DynamicPluginVersion";
+const char* const START_SESSION_FUNCTION = "DynamicPluginStartSession";
+const char* const STOP_SESSION_FUNCTION = "DynamicPluginStopSession";
+}
+
+DynamicPlugin::DynamicPlugin()
+ : m_handle_(0),
+ m_version_(0),
+ m_versionFunction_(0),
+ m_startSession_(0),
+ m_stopSession_(0) {
+ const base::CommandLine& commandLine =
+ *base::CommandLine::ForCurrentProcess();
+ std::string injectedBundlePath =
+ commandLine.GetSwitchValueASCII("injected-bundle-path");
+ if (injectedBundlePath.empty()) {
+ return;
+ }
+ m_handle_ = dlopen(injectedBundlePath.c_str(), RTLD_LAZY);
+ if (!m_handle_) {
+ LOG(ERROR) << "No handle to " << injectedBundlePath.c_str() << " "
+ << dlerror() << "\n";
+ return;
+ }
+
+ *reinterpret_cast<void**>(&m_versionFunction_) =
+ dlsym(m_handle_, VERSION_FUNCTION);
+ if (!m_versionFunction_) {
+ LOG(ERROR) << "No " << VERSION_FUNCTION << " symbol found!\n";
+ } else {
+ m_version_ = m_versionFunction_();
+ if (m_version_ != 0 && m_version_ != 1) {
+ LOG(ERROR) << "Unknown plugin version: " << m_version_ << "!\n";
+ return;
+ }
+ }
+
+ *reinterpret_cast<void**>(&m_startSession_) =
+ dlsym(m_handle_, START_SESSION_FUNCTION);
+ if (!m_startSession_) {
+ LOG(ERROR) << "No " << START_SESSION_FUNCTION << " symbol found!\n";
+ }
+ *reinterpret_cast<void**>(&m_stopSession_) =
+ dlsym(m_handle_, STOP_SESSION_FUNCTION);
+ if (!m_stopSession_) {
+ LOG(ERROR) << "No " << STOP_SESSION_FUNCTION << " symbol found!\n";
+ }
+}
+
+void DynamicPlugin::startSession(const char* sessionId,
+ v8::Handle<v8::Context> context,
+ int routingHandle,
+ const void* sessionBlob) {
+ if (!m_startSession_)
+ return;
+
+ m_startSession_(sessionId, context, routingHandle, sessionBlob);
+}
+
+void DynamicPlugin::stopSession(const char* sessionId,
+ v8::Handle<v8::Context> context) {
+ if (!m_stopSession_)
+ return;
+
+ m_stopSession_(sessionId, context);
+}
+
+DynamicPlugin::~DynamicPlugin() {
+ if (m_handle_)
+ dlclose(m_handle_);
+}
+
+DynamicPlugin& DynamicPlugin::instance() {
+ static DynamicPlugin dynamicPlugin;
+ return dynamicPlugin;
+}
+
--- /dev/null
+// Copyright 2014, 2016 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 WRT_DYNAMICPLUGIN_H_
+#define WRT_DYNAMICPLUGIN_H_
+
+#include <string>
+#include "base/macros.h"
+#include "v8/include/v8.h"
+
+typedef unsigned int (*versionFunction)(void);
+
+typedef void (*startSessionFunction)(const char* sessionId,
+ v8::Handle<v8::Context> context,
+ int routingHandle,
+ const void* sessionBlob);
+
+typedef void (*stopSessionFunction)(const char* sessionId,
+ v8::Handle<v8::Context> context);
+
+class DynamicPlugin {
+ public:
+ void startSession(const char* sessionId,
+ v8::Handle<v8::Context> context,
+ int routingHandle,
+ const void* sessionBlob);
+ void stopSession(const char* sessionId, v8::Handle<v8::Context> context);
+
+ virtual ~DynamicPlugin();
+
+ static DynamicPlugin& instance();
+
+ protected:
+ DynamicPlugin();
+ DynamicPlugin(const DynamicPlugin&);
+ DynamicPlugin& operator=(const DynamicPlugin&);
+
+ void* m_handle_;
+ unsigned int m_version_;
+ versionFunction m_versionFunction_;
+ startSessionFunction m_startSession_;
+ stopSessionFunction m_stopSession_;
+};
+
+#endif // WRT_DYNAMICPLUGIN_H_
--- /dev/null
+// Copyright 2014, 2015 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 "v8widget.h"
+
+#include "base/logging.h"
+#include "dynamicplugin.h"
+#if defined(OS_TIZEN_TV_PRODUCT)
+#include "wrt/hbbtv_dynamicplugin.h"
+#endif
+#include "wrt_dynamicplugin.h"
+
+V8Widget::V8Widget(Type type) : type_(type) {}
+
+V8Widget::~V8Widget() {}
+
+void V8Widget::SetId(const std::string& id) {
+ id_ = id;
+}
+
+V8Widget::Type V8Widget::GetType() const {
+ return type_;
+}
+
+bool V8Widget::ParseUrl(const GURL& url,
+ GURL& new_url,
+ bool& is_decrypted_file) {
+ if (!id_.empty()) {
+ std::string old_url = url.possibly_invalid_spec();
+ std::string s_new_url;
+ if (type_ == V8Widget::Type::WRT)
+ WrtDynamicPlugin::instance().parseURL(&old_url, &s_new_url, id_.c_str(),
+ &is_decrypted_file);
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ if (type_ == V8Widget::Type::HBBTV)
+ HbbTVDynamicPlugin::instance().parseURL(&old_url, &s_new_url, id_.c_str(),
+ &is_decrypted_file);
+#endif
+
+ if (!s_new_url.empty()) {
+ new_url = GURL(s_new_url);
+ return true;
+ }
+ }
+ return false;
+}
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+bool V8Widget::GetFileDecryptedDataBuffer(const GURL& url,
+ std::vector<char>* data) {
+ if (!id_.empty()) {
+ std::string str_url = url.possibly_invalid_spec();
+ if (type_ == V8Widget::Type::WRT)
+ return WrtDynamicPlugin::instance().getFileDecryptedDataBuffer(&str_url,
+ data);
+
+ if (type_ == V8Widget::Type::HBBTV)
+ return HbbTVDynamicPlugin::instance().getFileDecryptedDataBuffer(&str_url,
+ data);
+ }
+ return false;
+}
+#endif
+
+void V8Widget::StopSession(v8::Handle<v8::Context> context) {
+ if (!id_.empty() && !context.IsEmpty()) {
+ if (type_ == V8Widget::Type::WRT)
+ WrtDynamicPlugin::instance().stopSession(id_.c_str(), context);
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ if (type_ == V8Widget::Type::HBBTV)
+ HbbTVDynamicPlugin::instance().stopSession(id_.c_str(), context);
+#endif
+ }
+}
+
+void V8Widget::StartSession(v8::Handle<v8::Context> context,
+ int routingHandle,
+ const void* sessionBlob) {
+ if (!id_.empty() && !context.IsEmpty()) {
+ if (type_ == V8Widget::Type::WRT)
+ NOTREACHED();
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ if (type_ == V8Widget::Type::HBBTV)
+ HbbTVDynamicPlugin::instance().startSession(id_.c_str(), context,
+ routingHandle, sessionBlob);
+#endif
+ }
+}
--- /dev/null
+// Copyright 2014, 2015 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 WRT_V8WIDGET_H_
+#define WRT_V8WIDGET_H_
+
+#include <string>
+
+#include "content/public/renderer/render_thread_observer.h"
+#include "url/gurl.h"
+#include "v8/include/v8.h"
+
+// Have to be created on the RenderThread.
+class V8Widget {
+ public:
+ enum class Type { HBBTV, WRT };
+
+ explicit V8Widget(Type type);
+ virtual ~V8Widget() = 0;
+
+ void SetId(const std::string& id);
+ Type GetType() const;
+
+ virtual void StartSession(v8::Handle<v8::Context>,
+ int routingHandle,
+ const void* sessionBlob);
+
+ virtual void StopSession(v8::Handle<v8::Context>);
+
+ bool ParseUrl(const GURL& url, GURL& new_url, bool& is_decrypted_file);
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ bool GetFileDecryptedDataBuffer(const GURL& url, std::vector<char>* data);
+#endif
+ protected:
+ std::string id_;
+ Type type_;
+};
+
+#endif // WRT_V8WIDGET_H_
--- /dev/null
+// Copyright 2014 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 "wrt_dynamicplugin.h"
+
+#include <dlfcn.h>
+
+#include "base/command_line.h"
+#include "base/logging.h"
+
+namespace {
+const char* const URL_PARSING_FUNCTION = "DynamicUrlParsing";
+const char* const SET_WIDGET_INFO_FUNCTION = "DynamicSetWidgetInfo";
+const char* const DATABASE_ATTACH_FUNCTION = "DynamicDatabaseAttach";
+#if defined(OS_TIZEN_TV_PRODUCT)
+const char* const TVURL_PARSING_FUNCTION = "DynamicTVUrlParsing";
+const char* const GET_FILEDECRYPTED_DATABUFFER =
+ "DynamicGetFileDecryptedDataBuffer";
+#endif
+
+typedef void (*startSessionFun_v0)(const char* tizen_app_id,
+ v8::Handle<v8::Context> context,
+ int routingHandle,
+ double scaleFactor,
+ const char* encodedBundle,
+ const char* theme,
+ const char* baseURL);
+} // namespace
+
+WrtDynamicPlugin::WrtDynamicPlugin()
+ : DynamicPlugin(),
+ m_parseURL_(0),
+ m_setWidgetInfo_(0),
+ m_databaseAttach_(0),
+#if defined(OS_TIZEN_TV_PRODUCT)
+ m_getFileDecryptedDataBuffer_(0),
+ m_parseTVURL_(0),
+#endif
+ m_onIPCMessage_(0) {
+ *reinterpret_cast<void**>(&m_parseURL_) =
+ dlsym(m_handle_, URL_PARSING_FUNCTION);
+ if (!m_parseURL_) {
+ LOG(ERROR) << "No " << URL_PARSING_FUNCTION << " symbol found!\n";
+ }
+ *reinterpret_cast<void**>(&m_setWidgetInfo_) =
+ dlsym(m_handle_, SET_WIDGET_INFO_FUNCTION);
+ if (!m_setWidgetInfo_) {
+ LOG(ERROR) << "No " << SET_WIDGET_INFO_FUNCTION << " symbol found!";
+ }
+ *reinterpret_cast<void**>(&m_databaseAttach_) =
+ dlsym(m_handle_, DATABASE_ATTACH_FUNCTION);
+ if (!m_databaseAttach_) {
+ LOG(ERROR) << "No " << DATABASE_ATTACH_FUNCTION << " symbol found!\n";
+ return;
+ }
+ *reinterpret_cast<void**>(&m_onIPCMessage_) =
+ dlsym(m_handle_, "DynamicOnIPCMessage");
+ if (!m_onIPCMessage_) {
+ LOG(ERROR) << "No DynamicOnIPCMessage symbol found!\n";
+ }
+ m_databaseAttach_(1);
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ *reinterpret_cast<void**>(&m_parseTVURL_) =
+ dlsym(m_handle_, TVURL_PARSING_FUNCTION);
+ if (!m_parseTVURL_) {
+ LOG(ERROR) << "No " << TVURL_PARSING_FUNCTION << " symbol found!\n";
+ }
+ *reinterpret_cast<void**>(&m_getFileDecryptedDataBuffer_) =
+ dlsym(m_handle_, GET_FILEDECRYPTED_DATABUFFER);
+ if (!m_getFileDecryptedDataBuffer_) {
+ LOG(ERROR) << "No " << GET_FILEDECRYPTED_DATABUFFER << " symbol found!\n";
+ }
+#endif
+}
+
+void WrtDynamicPlugin::startSession(const char* tizen_app_id,
+ v8::Handle<v8::Context> context,
+ int routingHandle,
+ double scaleFactor,
+ const char* encodedBundle,
+ const char* theme,
+ const char* baseURL) {
+ if (!m_startSession_ || !m_databaseAttach_)
+ return;
+ switch (m_version_) {
+ case 0: {
+ auto startSession_v0 =
+ reinterpret_cast<startSessionFun_v0>(m_startSession_);
+ startSession_v0(tizen_app_id, context, routingHandle, scaleFactor,
+ encodedBundle, theme, baseURL);
+ break;
+ }
+ case 1: {
+ DynamicPlugin::startSession(tizen_app_id, context, routingHandle,
+ baseURL);
+ break;
+ }
+ default:
+ return;
+ }
+}
+
+void WrtDynamicPlugin::stopSession(const char* tizen_app_id,
+ v8::Handle<v8::Context> context) {
+ if (!m_stopSession_ || !m_databaseAttach_)
+ return;
+ DynamicPlugin::stopSession(tizen_app_id, context);
+}
+
+void WrtDynamicPlugin::parseURL(std::string* old_url,
+ std::string* new_url,
+ const char* tizen_app_id,
+ bool* is_decrypted_file) {
+#if defined(OS_TIZEN_TV_PRODUCT)
+ if (!m_databaseAttach_)
+ return;
+ if (m_parseTVURL_) {
+ m_parseTVURL_(old_url, new_url, tizen_app_id, is_decrypted_file);
+ return;
+ }
+ if (m_parseURL_) {
+ m_parseURL_(old_url, new_url, tizen_app_id);
+ *is_decrypted_file = false;
+ }
+#else
+ if (!m_parseURL_ || !m_databaseAttach_)
+ return;
+ m_parseURL_(old_url, new_url, tizen_app_id);
+#endif
+}
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+bool WrtDynamicPlugin::getFileDecryptedDataBuffer(const std::string* url,
+ std::vector<char>* data) {
+ if (!m_getFileDecryptedDataBuffer_)
+ return false;
+ return m_getFileDecryptedDataBuffer_(url, data);
+}
+#endif
+
+void WrtDynamicPlugin::setWidgetInfo(const std::string& tizen_app_id) {
+ if (!m_setWidgetInfo_)
+ return;
+ m_setWidgetInfo_(tizen_app_id.c_str());
+}
+
+WrtDynamicPlugin::~WrtDynamicPlugin() {
+ if (m_databaseAttach_)
+ m_databaseAttach_(0);
+}
+
+WrtDynamicPlugin& WrtDynamicPlugin::instance() {
+ static WrtDynamicPlugin dynamicPlugin;
+ return dynamicPlugin;
+}
+
+void WrtDynamicPlugin::messageReceived(const Wrt_Message_Data& data) {
+ if (!m_onIPCMessage_)
+ return;
+
+ m_onIPCMessage_(data);
+}
--- /dev/null
+// Copyright 2014 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 WRT_WRT_DYNAMICPLUGIN_H_
+#define WRT_WRT_DYNAMICPLUGIN_H_
+
+#include <string>
+#include <vector>
+#include "dynamicplugin.h"
+#include "v8/include/v8.h"
+#include "common/wrt_message_data.h"
+
+typedef void (*onIPCMessageFun)(const Wrt_Message_Data& data);
+#if defined(OS_TIZEN_TV_PRODUCT)
+typedef void (*TVParseUrlFun)(std::string* old_url,
+ std::string* new_url,
+ const char* tizen_app_id,
+ bool* is_decrypted_file);
+typedef bool (*getFileDecryptedDataBufferFun)(const std::string* url,
+ std::vector<char>* data);
+#endif
+typedef void (*parseUrlFun)(std::string* old_url,
+ std::string* new_url,
+ const char* tizen_app_id);
+typedef void (*setWidgetInfoFun)(const char* tizen_app_id);
+typedef void (*databaseAttachFun)(int databaseAttach);
+
+class WrtDynamicPlugin : public DynamicPlugin {
+ public:
+ void startSession(const char* tizen_app_id,
+ v8::Handle<v8::Context> context,
+ int routingHandle,
+ double scaleFactor,
+ const char* encodedBundle,
+ const char* theme,
+ const char* baseURL);
+ void stopSession(const char* tizen_app_id, v8::Handle<v8::Context> context);
+
+ void parseURL(std::string* old_url,
+ std::string* new_url,
+ const char* tizen_app_id,
+ bool* is_decrypted_file);
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ bool getFileDecryptedDataBuffer(const std::string* url,
+ std::vector<char>* data);
+#endif
+
+ void setWidgetInfo(const std::string& tizen_app_id);
+ void messageReceived(const Wrt_Message_Data& data);
+
+ static WrtDynamicPlugin& instance();
+ ~WrtDynamicPlugin() override;
+
+ private:
+ WrtDynamicPlugin();
+
+ parseUrlFun m_parseURL_;
+ setWidgetInfoFun m_setWidgetInfo_;
+ databaseAttachFun m_databaseAttach_;
+#if defined(OS_TIZEN_TV_PRODUCT)
+ getFileDecryptedDataBufferFun m_getFileDecryptedDataBuffer_;
+ TVParseUrlFun m_parseTVURL_;
+#endif
+ onIPCMessageFun m_onIPCMessage_;
+
+ DISALLOW_COPY_AND_ASSIGN(WrtDynamicPlugin);
+};
+
+#endif // WRT_WRT_DYNAMICPLUGIN_H_
--- /dev/null
+// Copyright (c) 2014,2015 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 "wrt_file_protocol_handler.h"
+
+#include "base/command_line.h"
+//#include "common/content_switches_efl.h"
+#include "content/public/common/content_client.h"
+#include "content/public/renderer/content_renderer_client.h"
+#include "net/base/filename_util.h"
+#include "net/url_request/url_request_data_job.h"
+#include "net/url_request/url_request_error_job.h"
+#include "net/url_request/url_request_file_dir_job.h"
+#include "net/url_request/url_request_file_job.h"
+#include "net/url_request/url_request_simple_job.h"
+#include "wrt_dynamicplugin.h"
+
+namespace net {
+
+class WrtURLRequestDataJob : public URLRequestSimpleJob {
+ public:
+ /* LCOV_EXCL_START */
+ WrtURLRequestDataJob(URLRequest* request,
+ NetworkDelegate* network_delegate,
+ const GURL& data_url)
+ : URLRequestSimpleJob(request, network_delegate) {
+ data_url_ = data_url;
+ }
+ /* LCOV_EXCL_STOP */
+
+ int GetData(std::string* mime_type,
+ std::string* charset,
+ std::string* data,
+ const CompletionCallback& callback) const override;
+
+ private:
+ ~WrtURLRequestDataJob() override {} // LCOV_EXCL_LINE
+ GURL data_url_;
+};
+
+/* LCOV_EXCL_START */
+int WrtURLRequestDataJob::GetData(std::string* mime_type,
+ std::string* charset,
+ std::string* data,
+ const CompletionCallback& callback) const {
+ if (!data_url_.is_valid())
+ return ERR_INVALID_URL;
+
+ return URLRequestDataJob::BuildResponse(data_url_, mime_type, charset, data,
+ nullptr);
+}
+
+bool WrtFileProtocolHandler::GetWrtParsedUrl(const GURL& url,
+ GURL& parsed_url) const {
+ static std::string tizen_app_id =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ "widget-id");
+ if (!tizen_app_id.empty()) {
+ bool is_decrypted_file;
+ std::string url_str = url.possibly_invalid_spec();
+ std::string parsed_url_str;
+ WrtDynamicPlugin::instance().parseURL(
+ &url_str, &parsed_url_str, tizen_app_id.c_str(), &is_decrypted_file);
+ if (!parsed_url_str.empty()) {
+ parsed_url = GURL(parsed_url_str);
+ return true;
+ }
+ }
+ return false;
+}
+/* LCOV_EXCL_STOP */
+
+URLRequestJob* WrtFileProtocolHandler::MaybeCreateJob(
+ URLRequest* request,
+ NetworkDelegate* network_delegate) const {
+ GURL parsed_url;
+ if (GetWrtParsedUrl(request->url(), parsed_url)) {
+ // Data URI scheme for WRT encryption content
+ if (parsed_url.SchemeIs(url::kDataScheme))
+ return new WrtURLRequestDataJob(request, network_delegate, parsed_url);
+ } else
+ parsed_url = request->url();
+
+ base::FilePath file_path;
+ const bool is_file = FileURLToFilePath(parsed_url, &file_path);
+
+ // Check file access permissions.
+ if (!network_delegate ||
+ !network_delegate->CanAccessFile(*request, file_path)) {
+ return new URLRequestErrorJob(request, network_delegate, ERR_ACCESS_DENIED);
+ }
+
+ // We need to decide whether to create URLRequestFileJob for file access or
+ // URLRequestFileDirJob for directory access. To avoid accessing the
+ // filesystem, we only look at the path string here.
+ // The code in the URLRequestFileJob::Start() method discovers that a path,
+ // which doesn't end with a slash, should really be treated as a directory,
+ // and it then redirects to the URLRequestFileDirJob.
+ if (is_file && file_path.EndsWithSeparator() && file_path.IsAbsolute()) {
+ return new URLRequestFileDirJob(request, network_delegate, file_path);
+ }
+
+ // Use a regular file request job for all non-directories (including invalid
+ // file names).
+ return new URLRequestFileJob(request, network_delegate, file_path,
+ file_task_runner_);
+}
+
+} // namespace
--- /dev/null
+// Copyright (c) 2014,2015 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 WRT_FILE_PROTOCOL_HANDLER
+#define WRT_FILE_PROTOCOL_HANDLER
+
+#include "base/memory/ref_counted.h"
+#include "net/url_request/url_request_job_factory.h"
+
+class GURL;
+
+namespace base {
+class TaskRunner;
+}
+
+namespace net {
+
+class NetworkDelegate;
+class URLRequestJob;
+
+class WrtFileProtocolHandler
+ : public URLRequestJobFactory::ProtocolHandler {
+ public:
+ explicit WrtFileProtocolHandler(
+ const scoped_refptr<base::TaskRunner>& file_task_runner)
+ : file_task_runner_(file_task_runner) {}
+ ~WrtFileProtocolHandler() override {}
+ URLRequestJob* MaybeCreateJob(
+ URLRequest* request,
+ NetworkDelegate* network_delegate) const override;
+ /* LCOV_EXCL_START */
+ bool IsSafeRedirectTarget(const GURL& location) const override {
+ return false;
+ }
+ /* LCOV_EXCL_STOP */
+
+ private:
+ bool GetWrtParsedUrl(const GURL& url, GURL& parsed_url) const;
+ const scoped_refptr<base::TaskRunner> file_task_runner_;
+ DISALLOW_COPY_AND_ASSIGN(WrtFileProtocolHandler);
+};
+
+} // namespace net
+
+#endif // WRT_FILE_PROTOCOL_HANDLER
--- /dev/null
+// Copyright (c) 2014,2015 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 "wrt_widget_host.h"
+
+#include "base/lazy_instance.h"
+//#include "common/render_messages_ewk.h"
+#include "atom/common/api/api_messages.h"
+#include "content/public/browser/browser_message_filter.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/resource_request_info.h"
+//#include "ipc/ipc_message_macros.h"
+//#include "ipc_message_start_ewk.h"
+#include "net/url_request/url_request.h"
+#include "url/gurl.h"
+
+namespace {
+// TODO(z.kostrzewa) I would prefer not make it a singleton, check out
+// if it can't be a member of ContentMainDelegateEfl (but keep the static
+// getter, maybe?).
+base::LazyInstance<std::unique_ptr<WrtWidgetHost> > g_wrt_widget_host =
+ LAZY_INSTANCE_INITIALIZER;
+
+bool SendToAllRenderers(IPC::Message* message) {
+ bool result = false;
+ content::RenderProcessHost::iterator it =
+ content::RenderProcessHost::AllHostsIterator();
+ while (!it.IsAtEnd()) {
+ if (it.GetCurrentValue()->Send(new IPC::Message(*message)))
+ result = true;
+ it.Advance();
+ }
+ delete message;
+ return result;
+}
+
+bool SendToRenderer(int renderer_id, IPC::Message* message) {
+ return content::RenderProcessHost::FromID(renderer_id)->Send(message);
+}
+}
+
+class WrtWidgetHostMessageFilter : public content::BrowserMessageFilter {
+ public:
+ explicit WrtWidgetHostMessageFilter(WrtWidgetHost* wrt_widget_host);
+
+ private:
+ ~WrtWidgetHostMessageFilter() override {}
+ bool OnMessageReceived(const IPC::Message& message) override;
+
+ WrtWidgetHost* wrt_widget_host_;
+};
+
+WrtWidgetHostMessageFilter::WrtWidgetHostMessageFilter(
+ WrtWidgetHost* wrt_widget_host)
+ : content::BrowserMessageFilter(ShellMsgStart),
+ wrt_widget_host_(wrt_widget_host) {
+}
+
+bool WrtWidgetHostMessageFilter::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(WrtWidgetHostMessageFilter, message)
+ IPC_MESSAGE_FORWARD(WrtMsg_ParseUrlResponse, wrt_widget_host_, WrtWidgetHost::OnUrlRetrieved)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+WrtWidgetHost* WrtWidgetHost::Get() {
+ // TODO(z.kostrzewa) LazyInstance is thread-safe but creating
+ // WrtWidgetHost is not - make it thread-safe.
+ if (!g_wrt_widget_host.Get().get())
+ g_wrt_widget_host.Get().reset(new WrtWidgetHost);
+ return g_wrt_widget_host.Get().get();
+}
+
+WrtWidgetHost::WrtWidgetHost()
+ : message_filter_(new WrtWidgetHostMessageFilter(this)) {
+}
+
+WrtWidgetHost::~WrtWidgetHost() {}
+
+void WrtWidgetHost::GetUrlForRequest(
+ net::URLRequest* request,
+ base::Callback<void(const GURL&)> callback) {
+ // TODO(z.kostrzewa) Check on which thread(s) callbacks_ is touched
+ // and provide synchronization if required (either via a lock or
+ // by assuring that it is referenced only on one thread)
+ int callback_id = callback_id_generator_.GetNext();
+ callbacks_[callback_id] = callback;
+
+ int renderer_id, frame_id;
+ if (content::ResourceRequestInfo::GetRenderFrameForRequest(request, &renderer_id,
+ &frame_id))
+ if (SendToRenderer(renderer_id, new WrtMsg_ParseUrl(callback_id, request->url())))
+ return;
+
+ callbacks_.erase(callback_id);
+ callback.Run(GURL());
+}
+
+void WrtWidgetHost::SendWrtMessage(
+ const Wrt_Message_Data& message) {
+ SendToAllRenderers(new WrtMsg_SendWrtMessage(message));
+}
+
+// It's only used by the wrt_file_protocol_handler which is not going to be used in the future
+// Candidate for deletion.
+bool WrtWidgetHost::InWrt() const {
+ return false;
+}
+
+// It's only used by the wrt_file_protocol_handler which is not going to be used in the future
+// Candidate for deletion.
+std::string WrtWidgetHost::TizenAppId() const {
+#if defined(OS_TIZEN_TV_PRODUCT)
+ return tizen_app_id_;
+#else
+ return std::string();
+#endif
+}
+
+void WrtWidgetHost::OnUrlRetrieved(int callback_id, const GURL& url) {
+ callbacks_type::iterator it = callbacks_.find(callback_id);
+ if (callbacks_.end() == it)
+ return;
+
+ callbacks_type::mapped_type callback = it->second;
+ callbacks_.erase(callback_id);
+ callback.Run(url);
+}
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+void WrtWidgetHost::SetTizenAppId(const std::string& tizen_app_id) {
+ tizen_app_id_ = tizen_app_id;
+}
+
+bool WrtWidgetHost::ShouldAllowRequest(const net::URLRequest& request) {
+ if (tizen_app_id_.empty() || !check_accessiable_path_callback_)
+ return true;
+
+ return check_accessiable_path_callback_->TriggerCallback(request.url().spec(),
+ tizen_app_id_);
+}
+
+bool EwkCheckAccessiablePathCallback::TriggerCallback(
+ const std::string& url_spec,
+ const std::string& tizen_app_id) const {
+ if (!callback_)
+ return true;
+
+ Eina_Bool result =
+ (*callback_)(tizen_app_id.c_str(), url_spec.c_str(), user_data_);
+ return result == EINA_TRUE;
+}
+
+void WrtWidgetHost::SetCheckAccessiablePathCallback(
+ Ewk_Context_Check_Accessible_Path_Callback callback,
+ void* user_data) {
+ check_accessiable_path_callback_.reset(
+ new EwkCheckAccessiablePathCallback(callback, user_data));
+}
+#endif
+
--- /dev/null
+// Copyright (c) 2014,2015 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 WRT_HOST_H
+#define WRT_HOST_H
+
+#include <map>
+#include <string>
+
+#include "base/atomic_sequence_num.h"
+#include "base/callback.h"
+#include "content/public/browser/browser_message_filter.h"
+#include "common/wrt_message_data.h"
+#if defined(OS_TIZEN_TV_PRODUCT)
+#include "public/ewk_context_product.h"
+#endif
+
+namespace net {
+class URLRequest;
+}
+
+class GURL;
+
+class WrtWidgetHostMessageFilter;
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+class EwkCheckAccessiablePathCallback {
+ public:
+ EwkCheckAccessiablePathCallback(
+ Ewk_Context_Check_Accessible_Path_Callback callback,
+ void* user_data)
+ : callback_(callback), user_data_(user_data) {}
+ bool TriggerCallback(const std::string& url_spec,
+ const std::string& tizen_app_id) const;
+
+ private:
+ Ewk_Context_Check_Accessible_Path_Callback callback_;
+ void* user_data_;
+};
+#endif
+
+class WrtWidgetHost {
+ public:
+ static WrtWidgetHost* Get();
+
+ ~WrtWidgetHost();
+
+ void GetUrlForRequest(net::URLRequest* request,
+ base::Callback<void(const GURL&)> callback);
+
+ void SendWrtMessage(const Wrt_Message_Data& message);
+
+ bool InWrt() const;
+
+ std::string TizenAppId() const;
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ void SetTizenAppId(const std::string& tizen_app_id);
+ bool ShouldAllowRequest(const net::URLRequest& request);
+
+ void SetCheckAccessiablePathCallback(
+ Ewk_Context_Check_Accessible_Path_Callback callback,
+ void* user_data);
+#endif
+
+ private:
+ friend class WrtWidgetHostMessageFilter;
+
+ typedef std::map<int, base::Callback<void(const GURL&)> > callbacks_type;
+
+ WrtWidgetHost();
+
+ void OnUrlRetrieved(int callback_id, const GURL& url);
+
+ scoped_refptr<WrtWidgetHostMessageFilter> message_filter_;
+ base::AtomicSequenceNumber callback_id_generator_;
+ callbacks_type callbacks_;
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+ std::string tizen_app_id_;
+ std::unique_ptr<EwkCheckAccessiablePathCallback> check_accessiable_path_callback_;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(WrtWidgetHost);
+};
+
+
+#endif
--- /dev/null
+// Copyright 2014, 2015 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 "wrtwidget.h"
+
+//#include "common/render_messages_ewk.h"
+#include "atom/common/api/api_messages.h"
+#include "content/public/renderer/render_thread.h"
+#include "ipc/ipc_sync_channel.h"
+#include "wrt_dynamicplugin.h"
+
+// TODO(z.kostrzewa)
+// Why it can't be implemented as IPC::ChannelProxy::MessageFilter (?)
+// Tried that and it seems that Observer starts receiving messages earlier than
+// MessageFilter what is crucial for message that sets widget handle
+class WrtRenderThreadObserver : public content::RenderThreadObserver {
+ public:
+ explicit WrtRenderThreadObserver(WrtWidget* wrt_widget)
+ : wrt_widget_(wrt_widget),
+ channel_(content::RenderThread::Get()->GetChannel())
+ { }
+
+ bool OnControlMessageReceived(const IPC::Message& message) override {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(WrtRenderThreadObserver, message)
+ IPC_MESSAGE_FORWARD(WrtMsg_SendWrtMessage, wrt_widget_, WrtWidget::MessageReceived)
+ IPC_MESSAGE_HANDLER(WrtMsg_ParseUrl, ParseUrl)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+ }
+
+ private:
+ void ParseUrl(int request_id, const GURL& url) {
+ GURL response;
+ bool is_decrypted_file = false;
+ wrt_widget_->ParseUrl(url, response, is_decrypted_file);
+ Send(new WrtMsg_ParseUrlResponse(request_id, response));
+ }
+
+ void Send(IPC::Message* message) {
+ if (channel_)
+ channel_->Send(message);
+ else
+ delete message;
+ }
+
+ WrtWidget* wrt_widget_;
+ IPC::SyncChannel* channel_;
+};
+
+WrtWidget::WrtWidget()
+ : V8Widget(V8Widget::Type::WRT),
+ scale_(0),
+ observer_(new WrtRenderThreadObserver(this)) {
+ DCHECK(content::RenderThread::Get())
+ << "WrtWidget must be constructed on the render thread";
+}
+
+WrtWidget::~WrtWidget() {
+ delete observer_;
+}
+
+content::RenderThreadObserver* WrtWidget::GetObserver() {
+ return observer_;
+}
+
+void WrtWidget::SetWidgetInfo(const std::string& tizen_app_id,
+ double scaleFactor,
+ const std::string& theme,
+ const std::string& encodedBundle) {
+ id_ = tizen_app_id;
+ scale_ = scaleFactor;
+ theme_ = theme;
+ encodedBundle_ = encodedBundle;
+ WrtDynamicPlugin::instance().setWidgetInfo(id_);
+}
+
+bool WrtWidget::IsWidgetInfoSet() const {
+ return !id_.empty();
+}
+
+void WrtWidget::StartSession(v8::Handle<v8::Context> context,
+ int routingHandle,
+ const void* sessionBlob) {
+ if (!id_.empty() && !context.IsEmpty()) {
+ WrtDynamicPlugin::instance().startSession(
+ id_.c_str(), context, routingHandle, scale_, encodedBundle_.c_str(),
+ theme_.c_str(), reinterpret_cast<const char*>(sessionBlob));
+ }
+}
+
+void WrtWidget::MessageReceived(const Wrt_Message_Data& data) {
+ if (!id_.empty())
+ WrtDynamicPlugin::instance().messageReceived(data);
+}
--- /dev/null
+// Copyright 2014, 2015 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 WRT_WRTWIDGET_H_
+#define WRT_WRTWIDGET_H_
+
+#include <string>
+
+#include "content/public/renderer/render_thread_observer.h"
+#include "url/gurl.h"
+#include "v8widget.h"
+#include "common/wrt_message_data.h"
+
+class WrtRenderThreadObserver;
+
+// Have to be created on the RenderThread.
+class WrtWidget : public V8Widget {
+ public:
+ WrtWidget();
+ ~WrtWidget() override;
+
+ content::RenderThreadObserver* GetObserver();
+
+ void SetWidgetInfo(const std::string& tizen_app_id,
+ double scaleFactor,
+ const std::string& theme,
+ const std::string& encodedBundle);
+
+ bool IsWidgetInfoSet() const;
+
+ void MessageReceived(const Wrt_Message_Data& data);
+
+ void StartSession(v8::Handle<v8::Context>,
+ int routingHandle,
+ const void* sessionBlob) override;
+
+ private:
+ double scale_;
+ std::string encodedBundle_;
+ std::string theme_;
+ WrtRenderThreadObserver* observer_;
+};
+
+#endif // WRT_WRTWIDGET_H_
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file.
+#if defined(OS_TIZEN)
+#include <dlfcn.h>
+#endif
+
#include "browser/browser_context.h"
#include "browser/media/media_device_id_salt.h"
namespace brightray {
namespace {
+#if defined(OS_TIZEN)
+const char* const kDynamicPreloading = "DynamicPreloading";
+typedef void (*DynamicPreloading)(void);
+#endif
// Convert string to lower case and escape it.
std::string MakePartitionName(const std::string& input) {
MakePartitionName(partition)));
content::BrowserContext::Initialize(this, path_);
-
browser_context_map_[PartitionKey(partition, in_memory)] = GetWeakPtr();
-#if defined(OS_TIZEN)
+
auto command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch("injected-bundle-path")) {
std::string injected_bundle_path = command_line->GetSwitchValueASCII("injected-bundle-path");
+#if defined(OS_TIZEN)
+ if (command_line->HasSwitch(switches::kSingleProcess)) {
+ // Preload injected bundle on here for process pool,
+ // because the zygote process doesn't exist in single process mode.
+ // The loaded handle must be closed on termination.
+ injected_bundle_handle_ =
+ dlopen(injected_bundle_path.c_str(), RTLD_LAZY);
+ if (!injected_bundle_handle_) {
+ LOG(ERROR) << "No handle to " << injected_bundle_path.c_str()
+ << " error " << dlerror();
+ return;
+ }
+
+ DynamicPreloading dp = reinterpret_cast<DynamicPreloading>(
+ dlsym(injected_bundle_handle_, kDynamicPreloading));
+ if (dp) {
+ dp();
+ } else {
+ LOG(ERROR) << "Fail to load symbol '"
+ << kDynamicPreloading
+ << "', error " << dlerror();
+ }
+ } else {
+#endif
+ //content::ZygoteHandle *handle = content::GetGenericZygote();
+ //*handle->LoadInjectedBundlePath(injected_bundle_path);
(*content::GetGenericZygote())->
LoadInjectedBundlePath(injected_bundle_path);
- }
+#if defined(OS_TIZEN)
+ }
#endif
+ }
}
BrowserContext::~BrowserContext() {
base::FilePath path_;
bool in_memory_;
+#if defined(OS_TIZEN)
+ void* injected_bundle_handle_;
+#endif
+
DevToolsNetworkControllerHandle network_controller_handle_;
std::unique_ptr<ResourceContext> resource_context_;
#include "base/trace_event/trace_log.h"
#include "build/build_config.h"
-#if defined(USE_EFL)
+#if 0//defined(USE_EFL)
#include "base/trace_event/ttrace.h"
#endif
'<(DEPTH)/tizen/loader/loader.gyp:wrt-loader',
'<(DEPTH)/tizen/extensions/extensions.gyp:xwalk_extension_shared',
'<(DEPTH)/tizen/renderer/injected_bundle.gyp:xwalk_injected_bundle',
+ '<(DEPTH)/tizen/wrt/chromium_wrt.gyp:chromium_wrt_shared',
'<(DEPTH)/efl/build/system.gyp:ecore',
'<(DEPTH)/efl/build/system.gyp:launchpad',
'<(DEPTH)/efl/build/system.gyp:capi-appfw-application',
],
'include_dirs': [
'.',
+ 'tizen',
'chromium_src',
'vendor/brightray',
'vendor/native_mate',