Support plugin without feature define
[platform/framework/web/wrt-plugins-common.git] / src / plugin-loading / js_page_session.cpp
index 2262e2d..1534d24 100644 (file)
@@ -67,6 +67,7 @@ using namespace WrtPlugins::W3C;
 
 namespace {
 const char *LIBRARY_PATH_SEPARATOR = "/";
+const char *TIZEN_ROOT_FEATURES = "http://tizen.org/privilege/tizen";
 }
 
 class JSPageSession::Impl
@@ -102,6 +103,7 @@ class JSPageSession::Impl
 
     void loadInjectedJavaScript();
     void installStandardFeatures();
+    void installRootFeatures();
     void installRequestedFeatures();
 
     //returns true if success or false if failed
@@ -189,6 +191,15 @@ void JSPageSession::Impl::installStandardFeatures()
     LogInfo("Standard widget features installed.");
 }
 
+void JSPageSession::Impl::installRootFeatures()
+{
+    LogInfo("Installing requested widget features...");
+    WrtDB::FeatureDAOReadOnly dao(TIZEN_ROOT_FEATURES);
+    auto plugin = m_pluginsSupport->getPluginModelById(dao.GetPluginHandle());
+    installPlugin(plugin);
+    LogInfo("requested root feature installed.");
+}
+
 bool JSPageSession::Impl::installPlugin(PluginModelPtr plugin)
 {
     Assert(plugin && "Plugin Model is NULL");
@@ -279,13 +290,16 @@ bool JSPageSession::Impl::loadPluginOnDemand(
 //        return;
 //    }
 //
-    auto plugin = m_pluginsSupport->getPluginModelById(pluginHandle);
-    if (!plugin) {
-        LogError("Failed to load plugin. plugin handle: " << pluginHandle);
-        return false;
-    }
-
-    return installPluginOnDemand(plugin,parentObject,context);
+//    auto plugin = m_pluginsSupport->getPluginModelById(pluginHandle);
+//    if (!plugin) {
+//        LogError("Failed to load plugin. plugin handle: " << pluginHandle);
+//        return false;
+//    }
+    m_pluginsSupport->registerPluginModel(pluginHandle);
+    return installPluginOnDemand(
+        m_pluginsSupport->getPluginModelById(pluginHandle),
+        parentObject,
+        context);
 }
 
 bool JSPageSession::Impl::installPluginOnDemand(PluginModelPtr plugin,
@@ -498,6 +512,11 @@ void JSPageSession::Impl::startSession(int widgetHandle,
     // Register standard features
     installStandardFeatures();
 
+    WidgetDAOReadOnly dao(m_widgetHandle);
+    WidgetType appType = dao.getWidgetType();
+    if (appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
+        installRootFeatures();
+    }
     // Register special features
     installRequestedFeatures();