merge with master
[platform/framework/web/wrt.git] / src / view / webkit / bundles / bundle_uri_handling.cpp
index 1d34020..9a9792e 100644 (file)
 #include <WKType.h>
 
 namespace {
-
 char const * const SCHEME_TYPE_FILE = "file";
 char const * const SCHEME_TYPE_WIDGET = "widget";
 char const * const WARP_ERROR_MSG =
-        "file:///usr/etc/wrt/warp_security_error.msg";
+    "file:///usr/etc/wrt/warp_security_error.msg";
 char const * const PARAM_URL = "param:url";
 char const * const ACE_IGNORED_SCHEMA[] = { "file://", "widget://", "data:",
-    "tel:", "sms:", "mmsto:", "mailto:", 0 };
-
-WKStringRef block_message = WKStringCreateWithUTF8CString("uri_block_msg");
-
+                                            "tel:", "sms:", "mmsto:", "mailto:",
+                                            0 };
 
 bool checkWARP(const char *url, const DPL::String& tizenId)
 {
@@ -69,7 +66,7 @@ bool checkWARP(const char *url, const DPL::String& tizenId)
     dao.getWidgetAccessInfo(widgetAccessInfoList);
 
     return (static_cast<WidgetAccessList>(widgetAccessInfoList)).isRequiredIRI(
-            DPL::FromUTF8String(std::string(url)));
+               DPL::FromUTF8String(std::string(url)));
 }
 
 bool checkACE(const char* url, bool xhr, const DPL::String& tizenId)
@@ -101,19 +98,18 @@ bool checkACE(const char* url, bool xhr, const DPL::String& tizenId)
 
     if (xhr) {
         aceRequest.dev_cap_list.items[0].name =
-                const_cast<ace_string_t>(devCapNamesXHR);
+            const_cast<ace_string_t>(devCapNamesXHR);
     } else {
         aceRequest.dev_cap_list.items[0].name =
-                const_cast<ace_string_t>(devCapNamesMarkup);
+            const_cast<ace_string_t>(devCapNamesMarkup);
     }
 
     aceRequest.dev_cap_list.items[0].param_list.count = 1;
     aceRequest.dev_cap_list.items[0].param_list.items = new ace_param_t[1];
     aceRequest.dev_cap_list.items[0].param_list.items[0].name =
-            const_cast<ace_string_t>(PARAM_URL);
+        const_cast<ace_string_t>(PARAM_URL);
     aceRequest.dev_cap_list.items[0].param_list.items[0].value =
-            const_cast<ace_string_t>(url);
-
+        const_cast<ace_string_t>(url);
 
     ace_bool_t result = ACE_FALSE;
 
@@ -123,31 +119,27 @@ bool checkACE(const char* url, bool xhr, const DPL::String& tizenId)
 
     LogDebug("Result is: " << static_cast<int>(result));
 
-    delete [] aceRequest.dev_cap_list.items[0].param_list.items;
-    delete [] aceRequest.dev_cap_list.items;
+    delete[] aceRequest.dev_cap_list.items[0].param_list.items;
+    delete[] aceRequest.dev_cap_list.items;
 
     return ACE_OK == ret && ACE_TRUE == result;
 }
 
-
 bool filterURIBySecurity(DPL::OptionalString &op_uri,
-         bool is_xhr,
-         const DPL::String& tizenId)
+                         bool is_xhr,
+                         const DPL::String& tizenId)
 {
-    if (!op_uri)
-    {
+    if (!op_uri) {
         return true; //accept empty uri
     }
 
     auto uri = DPL::ToUTF8String(*op_uri);
-    if (!checkWARP(uri.c_str(), tizenId))
-    {
+    if (!checkWARP(uri.c_str(), tizenId)) {
         LogDebug("Request was blocked by WARP: " << uri);
         return false;
     }
 
-    if (!checkACE(uri.c_str(), is_xhr, tizenId))
-    {
+    if (!checkACE(uri.c_str(), is_xhr, tizenId)) {
         LogDebug("Request was blocked by ACE: " << uri);
         return false;
     }
@@ -157,38 +149,27 @@ bool filterURIBySecurity(DPL::OptionalString &op_uri,
 } // namespace (anonymous)
 
 namespace BundleURIHandling {
-
-DPL::Optional<DPL::String> processURI(const DPL::String& inputURI,
-        bool is_xhr, const DPL::String& tizenId, WKBundleRef bundle)
+bool processURI(const DPL::String& inputURI,
+                bool is_xhr,
+                const DPL::String& tizenId,
+                WKBundleRef /*bundle*/)
 {
-    DPL::Optional<DPL::String> uri = localizeURI(inputURI, tizenId);
-
-    if (uri.IsNull())
-    {
+    DPL::Optional<DPL::String> uri(inputURI);
+    if (uri.IsNull()) {
         LogDebug("uri is empty");
-        return uri;
+        return true;
     }
 
     // check ACE, WARP
-    if (!filterURIBySecurity(uri, is_xhr, tizenId))
-    {
-        WKStringRef urlStr = WKStringCreateWithUTF8CString(
-                DPL::ToUTF8String(*uri).c_str());
-        WKTypeRef retVal = NULL;
-        // Send information about blocked URI to view_logic
-        LogInfo("Sent blocked uri to open browser later : " << uri);
-        WKBundlePostSynchronousMessage(bundle, block_message,
-                urlStr, &retVal);
-        WKRelease(urlStr);
-        WKRelease(retVal);
-        return DPL::Optional<DPL::String>::Null;
+    if (!filterURIBySecurity(uri, is_xhr, tizenId)) {
+        return false;
     }
 
-    return uri;
+    return true;
 }
 
 DPL::OptionalString localizeURI(const DPL::String& inputURI,
-        const DPL::String& tizenId)
+                                const DPL::String& tizenId)
 {
     auto uri = DPL::ToUTF8String(inputURI);
     LogDebug("localizing url: " << uri);
@@ -224,5 +205,4 @@ DPL::OptionalString localizeURI(const DPL::String& inputURI,
         return DPL::OptionalString(uri);
     }
 }
-
 } // namespace BundleURIHandling