Support plugin without feature define
[platform/framework/web/wrt-plugins-common.git] / src / plugin-loading / js_page_session.cpp
index 04841bf..1534d24 100644 (file)
@@ -67,7 +67,7 @@ using namespace WrtPlugins::W3C;
 
 namespace {
 const char *LIBRARY_PATH_SEPARATOR = "/";
-const char* FEATURE_WAC20_DEVICAPIS_NAME = "http://wacapps.net/api/deviceapis";
+const char *TIZEN_ROOT_FEATURES = "http://tizen.org/privilege/tizen";
 }
 
 class JSPageSession::Impl
@@ -103,6 +103,7 @@ class JSPageSession::Impl
 
     void loadInjectedJavaScript();
     void installStandardFeatures();
+    void installRootFeatures();
     void installRequestedFeatures();
 
     //returns true if success or false if failed
@@ -190,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");
@@ -220,39 +230,8 @@ void JSPageSession::Impl::installRequestedFeatures()
 {
     LogInfo("Installing requested widget features...");
 
-    //TODO it have to return LIST NOT SET!!!
-    WidgetDAOReadOnly widgetDao(m_widgetHandle);
-    DbWidgetFeatureSet features = widgetDao.getFeaturesList();
-
-    std::list<std::string> allowedFeatures;
-
-    FOREACH(it, features)
-    {
-        LogInfo("Loading api-feature: " << it->name);
-        if (it->rejected) {
-            LogWarning("Api-feature was rejected by ace. (Api-feature name: "
-                       << it->name << ")" );
-            continue;
-        }
-
-        allowedFeatures.push_back(DPL::ToUTF8String(it->name));
-    }
-
-    auto widgetType =  widgetDao.getWidgetType();
-
-    //WAC2.0 requirement
-    if (widgetType == APP_TYPE_WAC20)
-    {
-       auto it = find(allowedFeatures.begin(),
-                      allowedFeatures.end(),
-                      FEATURE_WAC20_DEVICAPIS_NAME);
-
-       if (allowedFeatures.end() == it)
-       {
-           LogInfo("WAC2.0 Deviceapis not declared but added");
-           allowedFeatures.push_front(FEATURE_WAC20_DEVICAPIS_NAME);
-       }
-    }
+    std::list<std::string> allowedFeatures =
+            m_pluginsSupport->getAllowedFeatures(m_widgetHandle);
 
     PluginContainerSupport::PluginsList allowedPlugins;
 
@@ -311,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,
@@ -530,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();