Merge "fix: use EINA_* booleans instread of TRUE/FALSE" into tizen
[platform/framework/web/wrt.git] / src / view / webkit / injected-bundle / wrt-injected-bundle.cpp
index 9ddd6d4..5cc22ab 100644 (file)
@@ -39,7 +39,6 @@
 #include <set>
 #include <memory>
 
-#include <dpl/log/log.h>
 #include <dpl/foreach.h>
 #include <dpl/assert.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
@@ -51,6 +50,7 @@
 #include <dpl/localization/LanguageTagsProvider.h>
 #include <dpl/event/main_event_dispatcher.h>
 
+#include <dpl/log/secure_log.h>
 #include <wrt_plugin_module.h>
 #include <profiling_util.h>
 
 #include "injected_bundle_viewmodes_support.h"
 
 namespace {
-const char * const SCHEME_HTTP = "http";
-const char * const SCHEME_HTTPS = "https";
-const char * const SCHEME_FILE = "file";
-const char * const SCHEME_FILE_SLASH = "file://";
-const char * const SCHEME_BOX_SLASH = "box://";
-const char * const BLANK_PAGE_URL = "about:blank";
-const char * const HTML_MIME = "text/html";
-const char * const PHP_MIME = "application/x-php";
+const char SCHEME_HTTP[] = "http";
+const char SCHEME_HTTPS[] = "https";
+const char SCHEME_FILE[] = "file";
+const char SCHEME_FILE_SLASH[] = "file://";
+const char SCHEME_BOX_SLASH[] = "box://";
+const char BLANK_PAGE_URL[] = "about:blank";
+const char SRC_DOC_PAGE_URL[] = "about:srcdoc";
+const char HTML_MIME[] = "text/html";
+const char PHP_MIME[] = "application/x-php";
+const char WRT_WILL_SEND_REQUEST_LOG_ENABLE[] = "WRT_WILL_SEND_REQUEST_LOG_ENABLE";
 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";
+const char PRIVILEGE_APP_TYPE[] = "wgt";
 #ifdef CORS_WHITELISTING_ENABLED
 const char * const warpAllowProtocolsForWildcard[] = { "http", "https" };
 #endif
@@ -100,7 +102,6 @@ Bundle::Bundle(WKBundleRef bundle) :
     m_encodedBundle(""),
     m_theme(""),
     m_willRemoveContext(NULL),
-    m_widgetType(WrtDB::APP_TYPE_UNKNOWN),
     m_securityModelVersion(
         WrtDB::WidgetSecurityModelVersion::WIDGET_SECURITY_MODEL_V1),
     m_initialized(false),
@@ -111,13 +112,9 @@ Bundle::Bundle(WKBundleRef bundle) :
         WrtDB::WrtDatabase::attachToThreadRO();
         LOG_PROFILE_STOP("Bundle attachToThread");
     } Catch (DPL::DB::SqlConnection::Exception::Base) {
-        LogError("## Db attach was failed! Terminate WebProcess by force. ##");
+        _E("## Db attach was failed! Terminate WebProcess by force. ##");
         exit(-1);
     }
-
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-    sendWebProcessPid();
-#endif
 }
 
 Bundle::~Bundle()
@@ -125,7 +122,7 @@ Bundle::~Bundle()
     WrtDB::WrtDatabase::detachFromThread();
 
     if (!m_pagesList.empty()) {
-        LogError("There are not closed pages!");
+        _E("There are not closed pages!");
     }
     WKRelease(m_bundle);
 }
@@ -136,7 +133,6 @@ void Bundle::didCreatePageCallback(
     const void* clientInfo)
 {
     LOG_PROFILE_START("didCreatePageCallback");
-    LogDebug("didCreatePageCallback called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
     This->didCreatePage(page);
     LOG_PROFILE_STOP("didCreatePageCallback");
@@ -148,7 +144,6 @@ void Bundle::didReceiveMessageCallback(
     WKTypeRef messageBody,
     const void *clientInfo)
 {
-    LogDebug("didReceiveMessageCallback called");
     Bundle* bundle = static_cast<Bundle*>(const_cast<void*>(clientInfo));
     bundle->didReceiveMessage(messageName, messageBody);
 }
@@ -158,7 +153,6 @@ void Bundle::willDestroyPageCallback(
     WKBundlePageRef page,
     const void* clientInfo)
 {
-    LogDebug("willDestroyPageCallback called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
     This->willDestroyPage(page);
 }
@@ -167,7 +161,7 @@ void Bundle::didCreatePage(WKBundlePageRef page)
 {
     if (!m_initialized)
     {
-        LogError("## Injected-bundle was not initialized! Terminate WebProcess by force. ##");
+        _E("## Injected-bundle was not initialized! Terminate WebProcess by force. ##");
         exit(-1);
     }
 
@@ -175,7 +169,7 @@ void Bundle::didCreatePage(WKBundlePageRef page)
     auto context = WKBundleFrameGetJavaScriptContext(mainFrame);
     m_pagesList.push_back(page);
     m_pageGlobalContext.insertContextForPage(page, context);
-    LogDebug("created Page : " << page << " created JSContext : " << context);
+    _D("created Page : %p created JSContext : %p", page, context);
     m_viewmodesSupport->initialize(page);
 
     WKBundlePageResourceLoadClient resourceLoadClient = {
@@ -242,7 +236,7 @@ void Bundle::didCreatePage(WKBundlePageRef page)
 
 void Bundle::willDestroyPage(WKBundlePageRef page)
 {
-    LogDebug("Destroyed page : " << page);
+    _D("Destroyed page : %p", page);
 
     auto context = m_pageGlobalContext.getContextForPage(page);
     m_pagesList.remove(page);
@@ -295,8 +289,10 @@ void Bundle::bypassCORSforWARPAccessList(WrtDB::WidgetDAOReadOnly & dao)
         std::string source = DPL::ToUTF8String(dao.getFullPath());
 #endif
 
-        LogDebug("WARP to WK whitelist position: " << source << " for "
-            << access.strIRI << " subDomains: " << access.bSubDomains);
+        _D("WARP to WK whitelist position: %s for %s subDomains: %d",
+           source.c_str(),
+           DPL::ToUTF8String(access.strIRI).c_str(),
+           access.bSubDomains);
 
         WKStringRef wkSource = WKStringCreateWithUTF8CString(source.c_str());
         WKStringRef wkHost;
@@ -330,21 +326,18 @@ void Bundle::bypassCORSforWARPAccessList(WrtDB::WidgetDAOReadOnly & dao)
 
 void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
 {
-    LogDebug("got message type: " << toString(messageName).c_str());
+    _D("message name: %s", toString(messageName).c_str());
     if (WKStringIsEqualToUTF8CString(messageName,
                                      Message::ToInjectedBundle::START))
     {
         if (!messageBody || WKStringGetTypeID() != WKGetTypeID(messageBody)) {
-            LogError("Wrong message format received, ignoring");
+            _E("Wrong message format received, ignoring");
             return;
         }
 
         std::string msgString =
             toString(static_cast<WKStringRef>(messageBody));
-        LogDebug("Got message text: " << msgString);
-        LogDebug("loading Page : " << m_pagesList.back() <<
-                 " loading JSContext : " <<
-                 m_pageGlobalContext.getContextForPage(m_pagesList.back()));
+        _D("message body: %s", msgString.c_str());
         // set information from ui process
         std::stringstream ssMsg(msgString);
         std::string argScale;
@@ -364,23 +357,20 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
     } else if (WKStringIsEqualToUTF8CString(messageName,
                                             Message::ToInjectedBundle::SHUTDOWN))
     {
-        LogDebug("shutdown plugins");
-
         if (m_pagesList.empty()) {
+            _D("shutdown plugins");
             PluginModule::shutdown();
         } else {
-            LogInfo(
-                "PluginModule shutdown ignored, there are still alive pages!");
+            _D("PluginModule shutdown ignored, there are still alive pages!");
         }
     }
     else if (WKStringIsEqualToUTF8CString(messageName,
                                           Message::ToInjectedBundle::SET_CUSTOM_PROPERTIES))
     {
-        LogDebug("reset custom properties of window objects");
         // set information from ui process
         std::string msgString =
             toString(static_cast<WKStringRef>(messageBody));
-
+        _D("message body: %s", msgString.c_str());
         std::string argScale;
         std::string argEncodedBundle;
         std::string argTheme;
@@ -404,7 +394,7 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
                    messageName,
                    Message::ToInjectedBundle::DISPATCH_JS_EVENT))
     {
-        LogDebug("dispatch javascript event to created frames");
+        _D("dispatch javascript event to created frames");
         using namespace WrtPlugins::W3C;
 
         // set information from ui process
@@ -439,9 +429,8 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
                    messageName,
                    Message::ToInjectedBundle::INIT))
     {
-        LogDebug("initialize");
-
         if (!m_initialized) {
+            _D("initialize");
             std::string msgString = toString(static_cast<WKStringRef>(messageBody));
             m_widgetTizenId = DPL::FromASCIIString(msgString);
             WrtDB::WidgetDAOReadOnly dao(m_widgetTizenId);
@@ -462,14 +451,13 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
                         GetUserWidgetExecPath() + "/" + tzAppId;
                 }
 
-                LogDebug("set_app_smack_label(" << appPath << ")");
-                if (set_app_smack_label(appPath.c_str()) != 0)
-                {
-                    LogError("set_app_smack_label() failed");
+                _D("set_app_smack_label(%s)", appPath.c_str());
+                if (set_app_smack_label(appPath.c_str()) != 0) {
+                    _E("set_app_smack_label() failed");
                 }
 
-                LogDebug("set_app_privilege(" << appPath << ")");
-                set_app_privilege(tzPkgId.c_str(), PRIVILEGE_APP_TYPE, appPath.c_str());
+                _D("perm_app_set_privilege(%s)", appPath.c_str());
+                perm_app_set_privilege(tzPkgId.c_str(), PRIVILEGE_APP_TYPE, appPath.c_str());
             }
 
             /* This type of message is received when widget is restarting
@@ -487,18 +475,14 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
             }
             LanguageTags tags =
                 LanguageTagsProviderSingleton::Instance().getLanguageTags();
-            LogDebug("Current widget locales (language tags):");
+            _D("Current widget locales (language tags):");
             FOREACH(it, tags) {
-                LogDebug("Locale: " << *it);
+                _D("Locale: %s", DPL::ToUTF8String(*it).c_str());
             }
 
-            m_widgetType = dao.getWidgetType();
-            LogDebug("m_widgetType : " << m_widgetType.getApptypeToString() <<
-                     "(m_widgetTizenId:" << m_widgetTizenId << ")");
-
-            LogDebug("Preload PluginLogicSingleton");
+            _D("Preload PluginLogicSingleton");
             PluginModule::init(WrtDB::WidgetDAOReadOnly::getHandle(m_widgetTizenId));
-            LogDebug("Preload PluginLogicSingleton_end");
+            _D("Preload PluginLogicSingleton_end");
 
             m_securityModelVersion = dao.getSecurityModelVersion();
 #ifdef CORS_WHITELISTING_ENABLED
@@ -509,7 +493,7 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
                 new InjectedBundle::ViewmodesSupport(m_widgetTizenId));
             m_initialized = true;
         } else {
-            LogDebug("already initalized");
+            _D("already initalized");
         }
     } else if (WKStringIsEqualToUTF8CString(
                    messageName,
@@ -517,21 +501,54 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
     {
             std::string msgString =
                 toString(static_cast<WKStringRef>(messageBody));
-            LogDebug("set x window handle [" << msgString << "]");
+#if 0 // sub mode disable
+            _D("set x window handle [%s]", msgString.c_str());
             IPCMessageSupport::setXwindowHandle(atoi(msgString.c_str()));
+#else
+            _D("sub mode is disabled, set x window handle [NULL]");
+#endif
+
     } else if (WKStringIsEqualToUTF8CString(
                    messageName,
                    Message::ToInjectedBundle::SET_VIEWMODES))
     {
         std::string msgBody =
             toString(static_cast<WKStringRef>(messageBody));
-        LogDebug("set viewmode to [" << msgBody << "]");
+        _D("set viewmode to [%s]", msgBody.c_str());
         if (msgBody == Message::ToInjectedBundle::SET_VIEWMODES_MSGBODY_EXIT) {
             m_viewmodesSupport->exitViewmodesAllPages();
         } else {
             m_viewmodesSupport->enterViewmodesAllPages(msgBody);
         }
     }
+    else if (WKStringIsEqualToUTF8CString(messageName, IPCMessageSupport::REPLY_ASYNC))
+    {
+        using namespace IPCMessageSupport;
+
+        std::string msgBody = toString(static_cast<WKStringRef>(messageBody));
+
+        if (msgBody.find_first_of('_') != std::string::npos) {
+            std::string strHandle = msgBody.substr(0, msgBody.find_first_of('_'));
+            std::string strBody = msgBody.substr(msgBody.find_first_of('_')+1);
+
+            _D("handle: %s, , Body: %s", strHandle.c_str(), strBody.c_str());
+
+            int handle = atoi(strHandle.c_str());
+
+            AsyncConnectionPtr connection = AsyncConnectionManager::instance().getConnection(handle);
+
+            if (connection) {
+                if (connection->replyCallback) {
+                    _D("connection->replyCallback()");
+                    (connection->replyCallback)(handle, connection->data, strBody.c_str());
+                }
+
+                AsyncConnectionManager::instance().removeConnection(handle);
+            } else {
+                _D("Connection is not available. Ignored.");
+            }
+        }
+    }
 }
 
 WKURLRequestRef Bundle::willSendRequestForFrameCallback(
@@ -554,7 +571,7 @@ void Bundle::didStartProvisionalLoadForFrameCallback(
     WKTypeRef* /*userData*/,
     const void *clientInfo)
 {
-    LogDebug("didStartProvisionalLoadForFrameCallback called");
+    _D("called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
 
     if (This->m_pageGlobalContext.find(page) == This->m_pageGlobalContext.end()) {
@@ -569,7 +586,7 @@ void Bundle::didStartProvisionalLoadForFrameCallback(
     ContextSet::iterator i = This->m_pageContext[page].find(context);
 
     if (i == This->m_pageContext[page].end()) {
-        LogDebug("Initially attached frame");
+        _D("Initially attached frame");
         return;
     }
 
@@ -583,11 +600,11 @@ void Bundle::didRemoveFrameFromHierarchyCallback(
     WKTypeRef* /*userData*/,
     const void *clientInfo)
 {
-    LogDebug("didRemoveFrameFromHierarchyCallback called");
+    _D("called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
 
     if (This->m_pageContext.count(page) == 0) {
-        LogDebug("his->m_pageContext.count(page) == 0");
+        _D("his->m_pageContext.count(page) == 0");
         return;
     }
 
@@ -596,7 +613,7 @@ void Bundle::didRemoveFrameFromHierarchyCallback(
     ContextSet::iterator i = This->m_pageContext[page].find(context);
 
     if (i == This->m_pageContext[page].end()) {
-        LogWarning("Tried to unload frame which has never been loaded");
+        _W("Tried to unload frame which has never been loaded");
         return;
     }
 
@@ -611,7 +628,7 @@ void Bundle::didFinishLoadForResourceCallback(
     uint64_t /*resourceIdentifier*/,
     const void* /*clientInfo*/)
 {
-    LogDebug("didFinishLoadForResourceCallback called");
+    _D("called");
 }
 
 void Bundle::didCommitLoadForFrameCallback(
@@ -620,14 +637,14 @@ void Bundle::didCommitLoadForFrameCallback(
     WKTypeRef* /*userData*/,
     const void *clientInfo)
 {
-    LogInfo("didCommitLoadForFrameCallback called");
+    _D("called");
     LOG_PROFILE_START("didCommitLoadForFrameCallback");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
 
     WKURLRef url = WKBundleFrameCopyURL(frame);
 
     if (url == NULL) {
-        LogInfo("url is NULL");
+        _W("url is NULL");
         return;
     }
 
@@ -641,7 +658,7 @@ void Bundle::didCommitLoadForFrameCallback(
     This->m_pageContext[page].insert(context);
 
     if (!WKBundleFrameIsMainFrame(frame)) {
-        LogInfo("frame isn't main frame");
+        _D("frame isn't main frame");
         PluginModule::start(
             WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
             context,
@@ -653,16 +670,15 @@ void Bundle::didCommitLoadForFrameCallback(
     }
 
     std::string urlStr = toString(url);
-    if (InjectedBundleURIHandling::processURIForPlugin(urlStr.c_str(),
-                                                       This->m_widgetTizenId))
-    {
-        LogDebug("start plugin");
+
+    if (InjectedBundleURIHandling::processURIForPlugin(urlStr.c_str())) {
+        _D("start plugin");
         if(This->m_pageGlobalContext.find(page) != This->m_pageGlobalContext.end())
         {
-            LogDebug("Previous context: " << This->m_pageGlobalContext.getContextForPage(page));
+            _D("Previous context: %p", This->m_pageGlobalContext.getContextForPage(page));
             PluginModule::stop(This->m_pageGlobalContext.getContextForPage(page));
         }
-        LogDebug("New context: " << context);
+        _D("New context: %p", context);
         //note that since we need old context for unloading plugins it must be sotred
         //custom container take care of increamenting and decrementing references
         This->m_pageGlobalContext.insertContextForPage(page, context);
@@ -677,13 +693,13 @@ void Bundle::didCommitLoadForFrameCallback(
 
         PluginModule::loadFrame(context);
     } else {
-        LogDebug("stop plugin");
+        _D("stop plugin");
         if(This->m_pageGlobalContext.find(page) != This->m_pageGlobalContext.end())
         {
-            LogDebug("Previous context: " << This->m_pageGlobalContext.getContextForPage(page));
+            _D("Previous context: %p", This->m_pageGlobalContext.getContextForPage(page));
             PluginModule::stop(This->m_pageGlobalContext.getContextForPage(page));
         }
-        LogDebug("New context: " << context);
+        _D("New context: %p", context);
         This->m_pageGlobalContext.insertContextForPage(page, context);
     }
     LOG_PROFILE_STOP("didCommitLoadForFrameCallback");
@@ -697,8 +713,7 @@ WKBundlePagePolicyAction Bundle::decidePolicyForNavigationActionCallback(
     WKTypeRef* userData,
     const void* clientInfo)
 {
-    LogDebug("decidePolicyForNavigationActionCallback called");
-
+    _D("called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
     return This->decidePolicyForAction(false,
                                        page,
@@ -717,8 +732,7 @@ WKBundlePagePolicyAction Bundle::decidePolicyForNewWindowActionCallback(
     WKTypeRef* userData,
     const void* clientInfo)
 {
-    LogDebug("decidePolicyForNewWindowActionCallback called");
-
+    _D("called");
     Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
     return This->decidePolicyForAction(true,
                                        page,
@@ -736,21 +750,20 @@ WKBundlePagePolicyAction Bundle::decidePolicyForResponseCallback(
     WKTypeRef*          /* userData */,
     const void*         /* clientInfo */)
 {
-    LogDebug("decidePolicyForResponseCallback called");
-
+    _D("called");
     Assert(response);
     WKStringRef contentTypeRef = WKURLResponseEflCopyContentType(response);
 
     std::string contentType = toString(contentTypeRef);
-    LogDebug("contentTypeRef : " << contentType);
+    _D("contentTypeRef : %s", contentType.c_str());
     WKRelease(contentTypeRef);
 
     if (contentType == HTML_MIME) {
-        LogDebug("Accepting HTML_MIME type");
+        _D("Accepting HTML_MIME type");
         return WKBundlePagePolicyActionUse;
     }
     if (contentType == PHP_MIME) {
-        LogDebug("Accepting php type");
+        _D("Accepting php type");
         return WKBundlePagePolicyActionUse;
     }
 
@@ -759,7 +772,7 @@ WKBundlePagePolicyAction Bundle::decidePolicyForResponseCallback(
 
 WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request)
 {
-    static bool logEnable = (getenv("WRT_WILL_SEND_REQUEST_LOG_ENABLE") != NULL);
+    static bool logEnable = (getenv(WRT_WILL_SEND_REQUEST_LOG_ENABLE) != NULL);
 
     WKURLRef    wkUrl   = WKURLRequestCopyURL(request);
     WKStringRef wkStr   = WKURLCopyString(wkUrl);
@@ -770,28 +783,34 @@ WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request)
     WKRelease(wkStr);
     WKRelease(wkUrl);
 
-    if (logEnable){ LogDebug("willSendRequestForFrame : " << stdUrl); }
+    if (logEnable){ _D("willSendRequestForFrame : %s", stdUrl.c_str()); }
+
+    std::string scheme = stdUrl.substr(0, stdUrl.find_first_of(':'));
+
+#ifdef APP_SCHEME_ENABLED
+    if (scheme == SCHEME_FILE) {
+        _E("File schema blocked for: %s", stdUrl.c_str());
+        return NULL;
+    }
+#endif
+
+    // "about:blank"/"about:srcdoc" uri doesn't need uri processing.
+    if (stdUrl == BLANK_PAGE_URL || stdUrl == SRC_DOC_PAGE_URL) {
+        WKRetain(request);
+        return request;
+    }
 
     localizedUrl = InjectedBundleURIHandling::localizeURI(stdUrl, DPL::ToUTF8String(m_widgetTizenId));
     bool ret = InjectedBundleURIHandling::processURI(localizedUrl, m_widgetTizenId, m_securityModelVersion);
 
-    if (!ret)
-    {
-        LogDebug("Not permitted resource: " << localizedUrl);
+    if (!ret) {
+        _D("Not permitted resource: %s", localizedUrl.c_str());
         return NULL;
     }
 
     // log disabled for performance
     //LogDebug("URI processing result: " << result);
-    std::string scheme = localizedUrl.substr(0, localizedUrl.find_first_of(':'));
-
-#ifdef APP_SCHEME_ENABLED
-    if (scheme == SCHEME_FILE)
-    {
-        LogError("File schema blocked for: " << stdUrl);
-        return NULL;
-    }
-#endif
+    scheme = localizedUrl.substr(0, localizedUrl.find_first_of(':'));
 
     // Return value must contain details information of input
     // WKURLRequestRef. Current webkit2 doesn't support api that
@@ -802,23 +821,19 @@ WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request)
     // external scheme also need to send message to UI process for
     // checking roaming and security
 
-    if (scheme == SCHEME_HTTP || scheme == SCHEME_HTTPS)
-    {
-        if (logEnable){ LogDebug("external scheme return original WKURLRequestRef"); }
+    if (scheme == SCHEME_HTTP || scheme == SCHEME_HTTPS) {
+        if (logEnable){ _D("external scheme return original WKURLRequestRef"); }
         WKRetain(request);
 
         return request;
-    }
-    else
-    {
+    } else {
         std::string checkUrl = localizedUrl;
 
-        if (m_decryptionSupport->isNeedDecryption(checkUrl))
-        {
+        if (m_decryptionSupport->isNeedDecryption(checkUrl)) {
             std::string decryptString =
                 m_decryptionSupport->decryptResource(checkUrl);
 
-            if (logEnable){ LogDebug("return value : " << decryptString ); }
+            if (logEnable){ _D("return value : %s", decryptString.c_str()); }
 
             WKURLRef destUrl =
                 WKURLCreateWithUTF8CString(decryptString.c_str());
@@ -833,7 +848,7 @@ WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request)
     WKURLRequestRef req = WKURLRequestCreateWithWKURL(newUrl);
     WKRelease(newUrl);
 
-    if (logEnable){ LogDebug("return value : " << localizedUrl); }
+    if (logEnable){ _D("return value : %s", localizedUrl.c_str()); }
 
     return req;
 }
@@ -853,7 +868,7 @@ WKBundlePagePolicyAction Bundle::decidePolicyForAction(
 
     std::string request_uri = toString(request);
 
-    LogInfo("Uri being checked: " << request_uri);
+    _D("request uri : %s", request_uri.c_str());
 
     // exception uri
     if (request_uri == BLANK_PAGE_URL) {
@@ -872,7 +887,7 @@ WKBundlePagePolicyAction Bundle::decidePolicyForAction(
                                                        m_securityModelVersion);
     if (!ret) {
         std::string blockedUrl = DPL::ToUTF8String(dplUrl);
-        LogDebug("URI is blocked: " << blockedUrl);
+        _D("URI is blocked: %s", blockedUrl.c_str());
 
         // Send information about blocked URI to UIProcess
         WKStringRef urlStr = WKStringCreateWithUTF8CString(blockedUrl.c_str());
@@ -894,11 +909,9 @@ WKBundlePagePolicyAction Bundle::decidePolicyForAction(
 
     // scheme action
     Scheme scheme(request_scheme);
-    LogDebug("Scheme: " << request_scheme);
-
     Scheme::Type type = scheme.GetType();
     if (type < Scheme::FILE || type >= Scheme::COUNT) {
-        LogError("Invalid scheme: " << request_scheme);
+        _D("Unknown scheme : %s", request_scheme.c_str());
         return WKBundlePagePolicyActionPassThrough;
     }
 
@@ -908,20 +921,11 @@ WKBundlePagePolicyAction Bundle::decidePolicyForAction(
         ctx = NEW_WINDOW;
     }
 
-    LogDebug("Scheme type: " << type);
-    LogDebug("Navigation context: " << ctx);
-    LogDebug("Application type: " << m_widgetType.getApptypeToString());
-
-    UriAction action;
-
-    if (m_widgetType == WrtDB::APP_TYPE_TIZENWEBAPP) {
-        action = g_tizenActionMap[type][ctx];
-    } else {
-        LogError("Unsupported application type: " << type);
-        return WKBundlePagePolicyActionPassThrough;
-    }
-
-    LogDebug("Uri action: " << action);
+    UriAction action = g_tizenActionMap[type][ctx];
+    _D("Scheme type: %d, Navigation context: %d, Action: %d",
+       type,
+       ctx,
+       action);
 
     if (action != URI_ACTION_WRT) {
         return WKBundlePagePolicyActionPassThrough;
@@ -932,12 +936,9 @@ WKBundlePagePolicyAction Bundle::decidePolicyForAction(
 
 std::string Bundle::toString(WKStringRef str)
 {
-    if (WKStringIsEmpty(str))
-    {
+    if (WKStringIsEmpty(str)) {
         return "";
-    }
-    else
-    {
+    } else {
         size_t size = WKStringGetMaximumUTF8CStringSize(str);
 
         char buffer[size + 1];
@@ -985,32 +986,16 @@ std::string Bundle::getScheme(std::string uri)
     return str;
 }
 
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-void Bundle::sendWebProcessPid()
-{
-    std::stringstream strPid;
-    strPid << getpid();
-    WKStringRef pidStr = WKStringCreateWithUTF8CString(strPid.str().c_str());
-    WKStringRef message =
-        WKStringCreateWithUTF8CString(
-            Message::ToUIProcess::SEND_WEBPROCESS_PID);
-    WKBundlePostMessage(m_bundle, message, pidStr);
-    WKRelease(pidStr);
-    WKRelease(message);
-}
-#endif
-
 extern "C"
 {
 WK_EXPORT
 void WKBundleInitialize(WKBundleRef bundle,
                         WKTypeRef)
 {
-    DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-BUNDLE");
-    LogDebug("Bundle initialized");
+    _D("Bundle initialized");
 
     DPL::Event::GetMainEventDispatcherInstance().ResetCrossEventCallHandler();
-    LogDebug("ResetCrossEventCallHandler()");
+    _D("ResetCrossEventCallHandler()");
 
     static Bundle s_bundle(bundle);
 
@@ -1025,8 +1010,7 @@ void WKBundleInitialize(WKBundleRef bundle,
     WKBundleSetClient(bundle, &client);
 
     // process pool - restore process priority
-    if (UID_ROOT == getuid())
-    {
+    if (UID_ROOT == getuid()) {
         setpriority(PRIO_PROCESS, 0, DEFAULT_PRIORITY);
     }
     IPCMessageSupport::setWKBundleRef(bundle);