1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "wrt/wrt_dynamicplugin.h"
9 #include "base/command_line.h"
10 #include "base/logging.h"
11 #include "common/content_switches_efl.h"
15 const char* const SET_WIDGET_INFO_FUNCTION = "DynamicSetWidgetInfo";
16 const char* const DATABASE_ATTACH_FUNCTION = "DynamicDatabaseAttach";
17 #if defined(OS_TIZEN_TV_PRODUCT)
18 const char* const URL_PARSING_FUNCTION = "DynamicTVUrlParsing";
20 const char* const URL_PARSING_FUNCTION = "DynamicUrlParsing";
23 typedef void (*StartSessionFun_v0)(const char* tizen_app_id,
24 v8::Handle<v8::Context> context,
27 const char* encoded_bundle,
32 WrtDynamicPlugin::WrtDynamicPlugin()
38 *reinterpret_cast<void**>(&parseURL_) = dlsym(handle_, URL_PARSING_FUNCTION);
40 LOG(ERROR) << "No " << URL_PARSING_FUNCTION << " symbol found!\n";
42 *reinterpret_cast<void**>(&set_widget_info_) =
43 dlsym(handle_, SET_WIDGET_INFO_FUNCTION);
44 if (!set_widget_info_)
45 LOG(ERROR) << "No " << SET_WIDGET_INFO_FUNCTION << " symbol found!";
47 *reinterpret_cast<void**>(&database_attach_) =
48 dlsym(handle_, DATABASE_ATTACH_FUNCTION);
49 if (!database_attach_) {
50 LOG(ERROR) << "No " << DATABASE_ATTACH_FUNCTION << " symbol found!\n";
54 *reinterpret_cast<void**>(&on_IPC_message_) =
55 dlsym(handle_, "DynamicOnIPCMessage");
57 LOG(ERROR) << "No DynamicOnIPCMessage symbol found!\n";
61 void WrtDynamicPlugin::StartSession(const char* tizen_app_id,
62 v8::Handle<v8::Context> context,
65 const char* encoded_bundle,
67 const char* baseURL) {
68 if (!start_session_ || !database_attach_)
72 auto startSession_v0 =
73 reinterpret_cast<StartSessionFun_v0>(start_session_);
74 startSession_v0(tizen_app_id, context, routing_handle, scale_factor,
75 encoded_bundle, theme, baseURL);
79 DynamicPlugin::StartSession(tizen_app_id, context, routing_handle,
88 void WrtDynamicPlugin::StopSession(const char* tizen_app_id,
89 v8::Handle<v8::Context> context) {
90 if (!stop_session_ || !database_attach_)
93 DynamicPlugin::StopSession(tizen_app_id, context);
96 void WrtDynamicPlugin::ParseURL(std::string* old_url,
98 const char* tizen_app_id,
99 bool* is_encrypted_file) {
100 if (!parseURL_ || !database_attach_)
103 #if defined(OS_TIZEN_TV_PRODUCT)
104 parseURL_(old_url, new_url, tizen_app_id, is_encrypted_file);
106 parseURL_(old_url, new_url, tizen_app_id);
110 void WrtDynamicPlugin::SetWidgetInfo(const std::string& tizen_app_id) {
111 if (!set_widget_info_)
114 set_widget_info_(tizen_app_id.c_str());
117 WrtDynamicPlugin::~WrtDynamicPlugin() {
118 if (database_attach_)
122 WrtDynamicPlugin& WrtDynamicPlugin::instance() {
123 static WrtDynamicPlugin dynamicPlugin;
124 return dynamicPlugin;
127 void WrtDynamicPlugin::MessageReceived(const Ewk_Wrt_Message_Data& data) {
128 if (!on_IPC_message_)
131 on_IPC_message_(data);