{
'target_name': 'tizen_account',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'account_api.js',
'account_extension.cc',
{
'target_name': 'tizen_alarm',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'alarm_api.js',
'alarm_extension.cc',
{
'target_name': 'tizen_application',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'application_api.js',
'application_extension.cc',
extern const char kSource_application_api[];
common::Extension* CreateExtension() {
- std::string app_id = common::Extension::GetRuntimeVariable("app_id", 64);
- LoggerD("app_id: %s", app_id.c_str());
+ ApplicationExtension* e = new ApplicationExtension();
- if (app_id.empty()) {
+ if (e->app_id().empty()) {
LoggerD("Application extension will not be created.");
- return NULL;
+ delete e;
+ return nullptr;
}
- return new ApplicationExtension(app_id);
+ return e;
}
-ApplicationExtension::ApplicationExtension(const std::string& app_id) {
- app_id_ = app_id;
+ApplicationExtension::ApplicationExtension() {
+ app_id_ = GetRuntimeVariable("app_id", 64);
+
+ LoggerD("app_id: %s", app_id_.c_str());
SetExtensionName("tizen.application");
SetJavaScriptAPI(kSource_application_api);
class ApplicationExtension : public common::Extension {
public:
- explicit ApplicationExtension(const std::string& app_id);
+ ApplicationExtension();
virtual ~ApplicationExtension();
+ std::string app_id() const { return app_id_; }
+
private:
std::string app_id_;
// common::Extension implementation.
void ApplicationInstance::AppGetRequestedAppControl(
const picojson::value& args, picojson::object& out) {
std::string bundle_str =
- common::Extension::GetRuntimeVariable("encoded_bundle", 1024);
+ common::GetCurrentExtension()->GetRuntimeVariable("encoded_bundle", 1024);
if (bundle_str.empty()) {
LoggerE("Getting encoded_bundle is failed");
ReportError(UnknownException("Gettng encoded_bundle is failed"), out);
{
'target_name': 'tizen_archive',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'archive_api.js',
'archive_extension.cc',
{
'target_name': 'tizen_badge',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'badge_api.js',
'badge_extension.cc',
{
'target_name': 'tizen_bluetooth',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'bluetooth_api.js',
'bluetooth_adapter.cc',
{
'target_name': 'tizen_bookmark',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'bookmark_api.js',
'bookmark_extension.cc',
{
'target_name': 'tizen_calendar',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'calendar_api.js',
'calendar_extension.cc',
{
'target_name': 'tizen_callhistory',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'callhistory_api.js',
'callhistory.cc',
--- /dev/null
+// Copyright (c) 2013 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is compiled into each plugin, hence its size should be minimized.
+
+#include "common/extension.h"
+
+namespace {
+
+common::Extension* g_extension = nullptr;
+
+} // namespace
+
+namespace common {
+
+Extension* GetCurrentExtension() {
+ assert(g_extension);
+ return g_extension;
+}
+
+class Extension::Detail {
+ private:
+ friend int32_t (::XW_Initialize)(XW_Extension extension,
+ XW_GetInterface get_interface);
+
+ static int32_t XW_Initialize(XW_Extension extension, XW_GetInterface get_interface);
+
+ // XW_Extension callbacks.
+ static void OnInstanceCreated(XW_Instance xw_instance);
+ static void OnShutdown(XW_Extension);
+};
+
+int32_t Extension::Detail::XW_Initialize(XW_Extension extension, XW_GetInterface get_interface) {
+ g_extension = CreateExtension();
+ if (!g_extension) {
+ std::cerr << "Can't initialize extension: "
+ << "CreateExtension() returned NULL.\n";
+ return XW_ERROR;
+ }
+ return XW_OK;
+}
+
+void Extension::Detail::OnInstanceCreated(XW_Instance xw_instance) {
+ if (!g_extension) {
+ return;
+ }
+ Instance* instance = g_extension->CreateInstance();
+ if (!instance) {
+ return;
+ }
+ Extension::OnInstanceCreated(xw_instance, instance);
+}
+
+void Extension::Detail::OnShutdown(XW_Extension) {
+ delete g_extension;
+ g_extension = nullptr;
+}
+
+} // namespace common
+
+// Entry point for CrossWalk plugin
+extern "C" int32_t XW_Initialize(XW_Extension extension, XW_GetInterface get_interface) {
+ return common::Extension::XW_Initialize(extension, get_interface,
+ common::Extension::Detail::XW_Initialize,
+ common::Extension::Detail::OnInstanceCreated,
+ common::Extension::Detail::OnShutdown);
+}
--- /dev/null
+{
+ 'includes':[
+ '../common/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'tizen_common',
+ 'type': 'loadable_module',
+ 'sources': [
+ 'converter.cc',
+ 'converter.h',
+ 'current_application.cc',
+ 'current_application.h',
+ 'extension.cc',
+ 'extension.h',
+ 'filter-utils.cc',
+ 'filter-utils.h',
+ 'picojson.h',
+ 'utils.h',
+ 'logger.cc',
+ 'logger.h',
+ 'platform_exception.cc',
+ 'platform_exception.h',
+ 'dbus_operation.cc',
+ 'dbus_operation.h',
+ 'XW_Extension.h',
+ 'XW_Extension_EntryPoints.h',
+ 'XW_Extension_Permissions.h',
+ 'XW_Extension_Runtime.h',
+ 'XW_Extension_SyncMessage.h',
+ 'scope_exit.h',
+ 'task-queue.cpp',
+ 'task-queue.h',
+ 'callback_user_data.cc',
+ 'callback_user_data.h',
+ 'optional.h',
+ #'multi_callback_user_data.cc',
+ #'multi_callback_user_data.h',
+ 'platform_result.cc',
+ 'platform_result.h',
+ 'assert.h'
+ ],
+ 'cflags': [
+ '-fvisibility=default',
+ ],
+ 'conditions': [
+ ['tizen == 1', {
+ 'variables': {
+ 'packages': [
+ 'capi-appfw-app-manager',
+ 'capi-appfw-package-manager',
+ ]
+ },
+ 'conditions': [
+ ['privilege_engine == "DB"', {
+ 'defines': ['PRIVILEGE_USE_DB'],
+ 'variables': {
+ 'packages': [
+ 'sqlite3',
+ ],
+ },
+ }],
+ ['privilege_engine == "ACE"', {
+ 'defines': ['PRIVILEGE_USE_ACE'],
+ 'variables': {
+ 'packages': [
+ 'sqlite3',
+ 'security-client',
+ ],
+ },
+ }],
+ ['privilege_engine == "CYNARA"', {
+ 'defines': ['PRIVILEGE_USE_CYNARA'],
+ 'variables': {
+ 'packages': [
+ ],
+ },
+ }],
+ ],
+ }],
+ ],
+ 'direct_dependent_settings': {
+ 'libraries' : [
+ '-ltizen_common',
+ ],
+ },
+ },
+ ],
+}
'dbus-1',
'dlog',
'glib-2.0',
- 'capi-appfw-app-manager',
- 'capi-appfw-package-manager',
]
},
- 'conditions': [
- ['privilege_engine == "DB"', {
- 'defines': ['PRIVILEGE_USE_DB'],
- 'variables': {
- 'packages': [
- 'sqlite3',
- ],
- },
- }],
- ['privilege_engine == "ACE"', {
- 'defines': ['PRIVILEGE_USE_ACE'],
- 'variables': {
- 'packages': [
- 'sqlite3',
- 'security-client',
- ],
- },
- }],
- ['privilege_engine == "CYNARA"', {
- 'defines': ['PRIVILEGE_USE_CYNARA'],
- 'variables': {
- 'packages': [
- ],
- },
- }],
- ],
}, {
'sources/': [['exclude', '_tizen\\.cc$|tizen/']],
'includes/': [['exclude', '_tizen\\.gypi$|tizen/']],
'<(SHARED_INTERMEDIATE_DIR)',
],
'sources': [
- 'converter.cc',
- 'converter.h',
- 'current_application.cc',
- 'current_application.h',
- 'extension.cc',
- 'extension.h',
- 'filter-utils.cc',
- 'filter-utils.h',
- 'picojson.h',
- 'utils.h',
- 'logger.cc',
- 'logger.h',
- 'platform_exception.cc',
- 'platform_exception.h',
- 'dbus_operation.cc',
- 'dbus_operation.h',
- 'XW_Extension.h',
- 'XW_Extension_EntryPoints.h',
- 'XW_Extension_Permissions.h',
- 'XW_Extension_Runtime.h',
- 'XW_Extension_SyncMessage.h',
- 'scope_exit.h',
- 'task-queue.cpp',
- 'task-queue.h',
- 'callback_user_data.cc',
- 'callback_user_data.h',
- 'optional.h',
- #'multi_callback_user_data.cc',
- #'multi_callback_user_data.h',
- 'platform_result.cc',
- 'platform_result.h',
- 'assert.h'
+ 'XW_Extension.cc',
],
'cflags': [
'-std=c++0x',
'-fPIC',
'-fvisibility=hidden',
],
+ 'libraries' : [
+ '-L .',
+ '-Wl,-rpath=/usr/lib/tizen-extensions-crosswalk',
+ ],
},
}
#include "common/logger.h"
#include "common/scope_exit.h"
+// This function is hidden, because each plugin needs to have own implementation.
+__attribute__ ((visibility ("hidden"))) common::Extension* CreateExtension() {
+ common::Extension* e = new common::Extension();
+ e->SetExtensionName("common");
+ return e;
+}
+
namespace {
-common::Extension* g_extension = NULL;
-XW_Extension g_xw_extension = 0;
+// this variable is valid only during Extension::XW_Initialize() call
+// do not use !!!
+// it's here, so we don't have to modify the interface of CreateExtension(), Extension(), etc.
+XW_Extension g_xw_extension_ = 0;
const XW_CoreInterface* g_core = NULL;
const XW_MessagingInterface* g_messaging = NULL;
const XW_Internal_PermissionsInterface* g_permission = NULL;
bool InitializeInterfaces(XW_GetInterface get_interface) {
- g_core = reinterpret_cast<const XW_CoreInterface*>(
- get_interface(XW_CORE_INTERFACE));
- if (!g_core) {
- std::cerr << "Can't initialize extension: error getting Core interface.\n";
- return false;
- }
+ static bool initialized = false;
- g_messaging = reinterpret_cast<const XW_MessagingInterface*>(
- get_interface(XW_MESSAGING_INTERFACE));
- if (!g_messaging) {
- std::cerr <<
- "Can't initialize extension: error getting Messaging interface.\n";
- return false;
- }
+ if (!initialized) {
+ g_core = reinterpret_cast<const XW_CoreInterface*>(
+ get_interface(XW_CORE_INTERFACE));
+ if (!g_core) {
+ std::cerr << "Can't initialize extension: error getting Core interface.\n";
+ return false;
+ }
- g_sync_messaging =
- reinterpret_cast<const XW_Internal_SyncMessagingInterface*>(
- get_interface(XW_INTERNAL_SYNC_MESSAGING_INTERFACE));
- if (!g_sync_messaging) {
- std::cerr <<
- "Can't initialize extension: error getting SyncMessaging interface.\n";
- return false;
- }
+ g_messaging = reinterpret_cast<const XW_MessagingInterface*>(
+ get_interface(XW_MESSAGING_INTERFACE));
+ if (!g_messaging) {
+ std::cerr <<
+ "Can't initialize extension: error getting Messaging interface.\n";
+ return false;
+ }
- g_entry_points = reinterpret_cast<const XW_Internal_EntryPointsInterface*>(
- get_interface(XW_INTERNAL_ENTRY_POINTS_INTERFACE));
- if (!g_entry_points) {
- std::cerr << "NOTE: Entry points interface not available in this version "
- << "of Crosswalk, ignoring entry point data for extensions.\n";
- }
+ g_sync_messaging =
+ reinterpret_cast<const XW_Internal_SyncMessagingInterface*>(
+ get_interface(XW_INTERNAL_SYNC_MESSAGING_INTERFACE));
+ if (!g_sync_messaging) {
+ std::cerr <<
+ "Can't initialize extension: error getting SyncMessaging interface.\n";
+ return false;
+ }
- g_runtime = reinterpret_cast<const XW_Internal_RuntimeInterface*>(
- get_interface(XW_INTERNAL_RUNTIME_INTERFACE));
- if (!g_runtime) {
- std::cerr << "NOTE: runtime interface not available in this version "
- << "of Crosswalk, ignoring runtime variables for extensions.\n";
- }
+ g_entry_points = reinterpret_cast<const XW_Internal_EntryPointsInterface*>(
+ get_interface(XW_INTERNAL_ENTRY_POINTS_INTERFACE));
+ if (!g_entry_points) {
+ std::cerr << "NOTE: Entry points interface not available in this version "
+ << "of Crosswalk, ignoring entry point data for extensions.\n";
+ }
- g_permission = reinterpret_cast<const XW_Internal_PermissionsInterface*>(
- get_interface(XW_INTERNAL_PERMISSIONS_INTERFACE));
- if (!g_permission) {
- std::cerr << "NOTE: permission interface not available in this version "
- << "of Crosswalk, ignoring permission for extensions.\n";
+ g_runtime = reinterpret_cast<const XW_Internal_RuntimeInterface*>(
+ get_interface(XW_INTERNAL_RUNTIME_INTERFACE));
+ if (!g_runtime) {
+ std::cerr << "NOTE: runtime interface not available in this version "
+ << "of Crosswalk, ignoring runtime variables for extensions.\n";
+ }
+
+ g_permission = reinterpret_cast<const XW_Internal_PermissionsInterface*>(
+ get_interface(XW_INTERNAL_PERMISSIONS_INTERFACE));
+ if (!g_permission) {
+ std::cerr << "NOTE: permission interface not available in this version "
+ << "of Crosswalk, ignoring permission for extensions.\n";
+ }
+
+ initialized = true;
}
return true;
} // namespace
-int32_t XW_Initialize(XW_Extension extension, XW_GetInterface get_interface) {
- assert(extension);
- g_xw_extension = extension;
-
- if (!InitializeInterfaces(get_interface))
- return XW_ERROR;
-
- g_extension = CreateExtension();
- if (!g_extension) {
- std::cerr << "Can't initialize extension: "
- << "create extension returned NULL.\n";
- return XW_ERROR;
- }
-
- using common::Extension;
- g_core->RegisterShutdownCallback(g_xw_extension, Extension::OnShutdown);
- g_core->RegisterInstanceCallbacks(
- g_xw_extension, Extension::OnInstanceCreated,
- Extension::OnInstanceDestroyed);
- g_messaging->Register(g_xw_extension, Extension::HandleMessage);
- g_sync_messaging->Register(g_xw_extension, Extension::HandleSyncMessage);
- return XW_OK;
-}
-
namespace common {
-Extension::Extension() {}
+Extension::Extension() : xw_extension_(g_xw_extension_) {
+}
Extension::~Extension() {}
void Extension::SetExtensionName(const char* name) {
- g_core->SetExtensionName(g_xw_extension, name);
+ g_core->SetExtensionName(xw_extension_, name);
}
void Extension::SetJavaScriptAPI(const char* api) {
- g_core->SetJavaScriptAPI(g_xw_extension, api);
+ g_core->SetJavaScriptAPI(xw_extension_, api);
}
void Extension::SetExtraJSEntryPoints(const char** entry_points) {
if (g_entry_points)
- g_entry_points->SetExtraJSEntryPoints(g_xw_extension, entry_points);
+ g_entry_points->SetExtraJSEntryPoints(xw_extension_, entry_points);
}
bool Extension::RegisterPermissions(const char* perm_table) {
if (g_permission)
- return g_permission->RegisterPermissions(g_xw_extension, perm_table);
+ return g_permission->RegisterPermissions(xw_extension_, perm_table);
return false;
}
bool Extension::CheckAPIAccessControl(const char* api_name) {
if (g_permission)
- return g_permission->CheckAPIAccessControl(g_xw_extension, api_name);
+ return g_permission->CheckAPIAccessControl(xw_extension_, api_name);
return false;
}
return "";
std::vector<char> res(len + 1, 0);
- g_runtime->GetRuntimeVariableString(g_xw_extension, var_name, &res[0], len);
+ g_runtime->GetRuntimeVariableString(xw_extension_, var_name, &res[0], len);
return std::string(res.begin(), res.end());
}
// static
-void Extension::OnShutdown(XW_Extension) {
- delete g_extension;
- g_extension = NULL;
-}
-
-// static
-void Extension::OnInstanceCreated(XW_Instance xw_instance) {
+void Extension::OnInstanceCreated(XW_Instance xw_instance, Instance* instance) {
assert(!g_core->GetInstanceData(xw_instance));
- Instance* instance = g_extension->CreateInstance();
if (!instance)
return;
instance->xw_instance_ = xw_instance;
instance->HandleSyncMessage(msg);
}
+//static
+int32_t Extension::XW_Initialize(XW_Extension extension,
+ XW_GetInterface get_interface,
+ XW_Initialize_Func initialize,
+ XW_CreatedInstanceCallback created_instance,
+ XW_ShutdownCallback shutdown) {
+ assert(extension);
+
+ if (!InitializeInterfaces(get_interface)) {
+ return XW_ERROR;
+ }
+
+ g_xw_extension_ = extension;
+
+ if (XW_ERROR == initialize(extension, get_interface)) {
+ return XW_ERROR;
+ }
+
+ g_xw_extension_ = 0;
+
+ using common::Extension;
+ g_core->RegisterShutdownCallback(extension, shutdown);
+ g_core->RegisterInstanceCallbacks(extension, created_instance,
+ Extension::OnInstanceDestroyed);
+ g_messaging->Register(extension, Extension::HandleMessage);
+ g_sync_messaging->Register(extension, Extension::HandleSyncMessage);
+ return XW_OK;
+}
+
+
Instance::Instance()
: xw_instance_(0) {}
const char* kQuery = "select name from WidgetFeature where app_id = "
"(select app_id from WidgetInfo where tizen_appid = ?)"
" and rejected = 0";
- const std::string app_id = common::Extension::GetRuntimeVariable("app_id", 64);
+ const std::string app_id = common::GetCurrentExtension()->GetRuntimeVariable("app_id", 64);
sqlite3_stmt* stmt = nullptr;
ret = sqlite3_prepare_v2(db, kQuery, -1, &stmt, nullptr);
}
const char* kQuery = "select app_id from WidgetInfo where tizen_appid = ?";
- const std::string app_id = common::Extension::GetRuntimeVariable("app_id", 64);
+ const std::string app_id = common::GetCurrentExtension()->GetRuntimeVariable("app_id", 64);
sqlite3_stmt* stmt = nullptr;
ret = sqlite3_prepare_v2(db, kQuery, -1, &stmt, nullptr);
// an appropriate Extension subclass.
common::Extension* CreateExtension();
-
namespace common {
+// implemented in XW_Extension.cc
+// can be called only after the extension is fully created
+// (CreateExtension() has been called)
+Extension* GetCurrentExtension();
+
class Extension {
public:
Extension();
virtual Instance* CreateInstance();
- static std::string GetRuntimeVariable(const char* var_name, unsigned len);
+ std::string GetRuntimeVariable(const char* var_name, unsigned len);
private:
friend int32_t (::XW_Initialize)(XW_Extension extension,
- XW_GetInterface get_interface);
+ XW_GetInterface get_interface);
+
+ static int32_t XW_Initialize(XW_Extension extension,
+ XW_GetInterface get_interface,
+ XW_Initialize_Func initialize,
+ XW_CreatedInstanceCallback created_instance,
+ XW_ShutdownCallback shutdown);
// XW_Extension callbacks.
- static void OnShutdown(XW_Extension xw_extension);
- static void OnInstanceCreated(XW_Instance xw_instance);
+ static void OnInstanceCreated(XW_Instance xw_instance, Instance* instance); // modified
static void OnInstanceDestroyed(XW_Instance xw_instance);
static void HandleMessage(XW_Instance xw_instance, const char* msg);
static void HandleSyncMessage(XW_Instance xw_instance, const char* msg);
+
+ XW_Extension xw_extension_;
+
+ class Detail;
};
class Instance {
{
'target_name': 'tizen_contact',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'contact_api.js',
'contact_extension.cc',
{
'target_name': 'tizen_content',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'content_api.js',
'content_extension.cc',
{
'target_name': 'tizen_datacontrol',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'datacontrol_api.js',
'datacontrol_extension.cc',
{
'target_name': 'tizen_download',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'download_api.js',
'download_extension.cc',
['tizen == 1', {
'variables': {
'packages': [
- 'capi-web-url-download',
- 'capi-system-info'
+ 'capi-web-url-download',
+ 'capi-system-info'
]
},
}],
'includes': [
'../common/pkg-config.gypi',
],
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'exif_api.js',
'exif_extension.cc',
'storage',
],
},
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'filesystem_api.js',
'filesystem_extension.cc',
],
'conditions': [
[ 'tizen == 1', {
- 'variables': { 'packages': ['vconf'] },
+ 'variables': { 'packages': [
+ 'vconf',
+ 'capi-appfw-app-manager',
+ 'capi-appfw-package-manager',
+ ] },
}],
],
},
}
static std::string getAppRoot() {
- std::string appId = common::Extension::GetRuntimeVariable("app_id", 64);
+ std::string appId = common::GetCurrentExtension()->GetRuntimeVariable("app_id", 64);
app_info_h app_info;
int err = app_info_create(appId.c_str(), &app_info);
if (err != APP_MANAGER_ERROR_NONE) {
{
'target_name': 'tizen_mediakey',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'mediakey_api.js',
'mediakey_extension.cc',
{
'target_name': 'tizen_messageport',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'messageport_api.js',
'messageport_extension.cc',
{
'target_name': 'tizen_messaging',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'variables': {
'packages': [
'msg-service',
{
'target_name': 'tizen_networkbearerselection',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'variables': {
'packages': [
'icu-i18n',
{
'target_name': 'tizen_nfc',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'nfc_api.js',
'nfc_extension.cc',
{
'target_name': 'tizen_notification',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'notification_api.js',
'notification_extension.cc',
{
'target_name': 'tizen_package',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'package_api.js',
'package_extension.cc',
{
'target_name': 'tizen_power',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'power_api.js',
'power_extension.cc',
{
'target_name': 'tizen_push',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'push_api.js',
'push_extension.cc',
{
'target_name': 'tizen_fmradio',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'radio_api.js',
'radio_extension.cc',
{
'target_name': 'tizen_secureelement',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'secureelement_api.js',
'secureelement_extension.cc',
{
'target_name': 'tizen_sensor',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'sensor_api.js',
'sensor_extension.cc',
{
'target_name': 'tizen_sound',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'variables': {
'packages': [
'icu-i18n',
{
'target_name': 'tizen_systeminfo',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'systeminfo_api.js',
'systeminfo_extension.cc',
{
'target_name': 'tizen_systemsetting',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'systemsetting_api.js',
'systemsetting_extension.cc',
{
'target_name': 'tizen_time',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'variables': {
'packages': [
'icu-i18n',
'target_name': 'build_all_tizen_extensions',
'type': 'none',
'dependencies': [
+ 'common/common.gyp:*',
'tizen/tizen.gyp:*',
'utils/utils.gyp:*',
],
{
'target_name': 'tizen',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'tizen.h',
'tizen_api.js',
{
'target_name': 'tizen_tvaudio',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'tvaudio_api.js',
'tvaudio_extension.cc',
],
},
'dependencies': [
+ '../common/common.gyp:tizen_common',
'../tizen/tizen.gyp:tizen',
],
'includes': [
{
'target_name': 'tizen_tvdisplay',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'includes': [
'../common/pkg-config.gypi',
],
{
'target_name': 'tizen_tvinputdevice',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'tvinputdevice_api.js',
'tvinputdevice_extension.cc',
],
},
'dependencies': [
+ '../common/common.gyp:tizen_common',
'../tizen/tizen.gyp:tizen',
],
'includes': [
{
'target_name': 'tizen_utils',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'utils_api.js',
'utils_extension.cc',
{
'target_name': 'tizen_websetting',
'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
'sources': [
'websetting.cc',
'websetting.h',
explicit WebSetting(const std::string& app_id);
~WebSetting();
+ std::string app_id() const { return app_id_; }
+
std::unique_ptr<picojson::value> RemoveAllCookies();
std::unique_ptr<picojson::value> SetUserAgentString(
const std::string& user_agent);
#include "websetting/websetting.h"
#include "websetting/websetting_instance.h"
+#include "common/logger.h"
+
extern const char kSource_websetting_api[];
common::Extension* CreateExtension() {
- std::string env_app_id = common::Extension::GetRuntimeVariable("app_id", 64);
- std::string app_id = env_app_id.substr(1, env_app_id.rfind('"') - 1);
- if (app_id.empty()) {
- std::cerr << "Got invalid application ID." << std::endl;
+ WebSettingExtension* e = new WebSettingExtension();
+
+ if (e->current_app()->app_id().empty()) {
+ LoggerE("Got invalid application ID.");
+ delete e;
return nullptr;
}
- return new WebSettingExtension(app_id);
+
+ return e;
}
-WebSettingExtension::WebSettingExtension(const std::string& app_id) {
+WebSettingExtension::WebSettingExtension() {
+ std::string app_id = GetRuntimeVariable("app_id", 64);
+
+ LoggerD("app_id: %s", app_id.c_str());
+
current_app_.reset(new WebSetting(app_id));
SetExtensionName("tizen.websetting");
SetJavaScriptAPI(kSource_websetting_api);
class WebSettingExtension : public common::Extension {
public:
- explicit WebSettingExtension(const std::string& app_id);
+ WebSettingExtension();
virtual ~WebSettingExtension();
WebSetting* current_app() { return current_app_.get(); }
const double callback_id = args.get("callbackId").get<double>();
auto get = [=](const std::shared_ptr<JsonValue>& response) -> void {
const char* runtime_name =
- common::Extension::GetRuntimeVariable("runtime_name", 64).c_str();
+ common::GetCurrentExtension()->GetRuntimeVariable("runtime_name", 64).c_str();
LoggerD("runtime_name: %s", runtime_name);
if (strcmp(runtime_name, kWrtServiceName) == 0) {
ReportError(
const double callback_id = args.get("callbackId").get<double>();
auto get = [=](const std::shared_ptr<JsonValue>& response) -> void {
const char* runtime_name =
- common::Extension::GetRuntimeVariable("runtime_name", 64).c_str();
+ common::GetCurrentExtension()->GetRuntimeVariable("runtime_name", 64).c_str();
LoggerD("runtime_name: %s", runtime_name);
if (strcmp(runtime_name, kWrtServiceName) == 0) {
ReportError(