[Release] wrt_0.8.166 for tizen_2.1 branch
[platform/framework/web/wrt.git] / src / view / webkit / bundles / wrt-wk2-bundle.cpp
index 8a2bc07..ef9f90e 100644 (file)
@@ -49,6 +49,7 @@
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 #include <dpl/localization/localization_utils.h>
 #include <dpl/string.h>
+#include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/utils/mime_type_utils.h>
 #include <dpl/localization/LanguageTagsProvider.h>
 
 #include <js_overlay_types.h>
 
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <privilege-control.h>
+
 // URI localization on WebProcess side
 #include "bundle_uri_handling.h"
 extern "C" {
@@ -94,6 +99,11 @@ const char * const PHP_MIME = "application/x-php";
 const char * const VIEWMODE_TYPE_FULLSCREEN = "fullscreen";
 const char * const VIEWMODE_TYPE_MAXIMIZED = "maximized";
 const std::size_t FILE_BUF_MAX_SIZE = 1024; // bytes
+const std::size_t PLAIN_CHUNK_SIZE = 1008; // bytes
+const unsigned int UID_ROOT = 0;
+const unsigned int DEFAULT_PRIORITY = 0;
+const char * const PRIVILEGE_APP_TYPE = "wgt";
+
 static bool m_initWebApp = false;
 
 Tizen::Base::ByteBuffer *DecryptChunkByTrustZone(
@@ -412,6 +422,23 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
             m_widgetTizenId = DPL::FromASCIIString(msgString);
 
             WrtDB::WidgetDAOReadOnly dao(m_widgetTizenId);
+
+            // process pool - set app_privilige
+            if (UID_ROOT == getuid())
+            {
+                using namespace WrtDB::GlobalConfig;
+
+                std::string appPath;
+                std::string tzAppId = DPL::ToUTF8String(dao.getTzAppId());
+                std::string tzPkgId = DPL::ToUTF8String(dao.getTizenPkgId());
+
+                appPath = appPath + GetUserInstalledWidgetPath() + "/" +
+                          tzPkgId + GetUserWidgetExecPath() + "/" + tzAppId;
+
+                LogDebug("set_app_privilege(" << appPath << ")");
+                set_app_privilege(tzPkgId.c_str(), PRIVILEGE_APP_TYPE, appPath.c_str());
+            }
+
             /* This type of message is received when widget is restarting
              * (proably in other situation too). Widget restart can be
              * called after system language change so language tags have to
@@ -797,6 +824,7 @@ WKBundlePagePolicyAction Bundle::pageDecidePolicyForNavigationAction(
         WKRelease(urlStr);
         WKRelease(retVal);
         WKRelease(blockMessage);
+        return WKBundlePagePolicyActionPassThrough;
     }
 
     // get scheme string
@@ -1023,5 +1051,11 @@ void WKBundleInitialize(WKBundleRef bundle,
         &Bundle::didReceiveMessageCallback
     };
     WKBundleSetClient(bundle, &client);
+
+    // process pool - restore process priority
+    if (UID_ROOT == getuid())
+    {
+        setpriority(PRIO_PROCESS, 0, DEFAULT_PRIORITY);
+    }
 }
 }