Support cookie clear IPC 09/10209/1
authorJihoon Chung <jihoon.chung@samsung.com>
Sun, 9 Jun 2013 04:24:38 +0000 (13:24 +0900)
committerSoo-Hyun Choi <sh9.choi@samsung.com>
Tue, 24 Sep 2013 12:42:24 +0000 (21:42 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Support cookie clear IPC
Separate IPC to two types (sendSyncMessage, sendAsyncMessage)
Cookie clear API uses sendAsyncMessage with "tizen://clearAllCookies"
to the name argument
This API will be used by tizen API
[SCMRequest] N/A

Change-Id: Id96a514486d29f8cc8d46352a5c87a551a8d68d1

src/plugins-ipc-message/ipc_message_support.cpp
src/standards/W3C/Widget/JSPreferences.cpp

index fa36f8d..5d2f290 100644 (file)
@@ -33,6 +33,9 @@ static WKBundleRef s_injectedBundleRef = NULL;
 static unsigned  int s_xWindowHandle = 0;
 
 namespace {
+const char* const TIZEN_GET_WINDOW_HANDLE = "tizen://getWindowHandle";
+const char* const TIZEN_CLEAR_ALL_COOKIES = "tizen://clearAllCookies";
+
 std::string toString(WKStringRef str)
 {
     if (WKStringIsEmpty(str)) {
@@ -43,6 +46,48 @@ std::string toString(WKStringRef str)
     WKStringGetUTF8CString(str, buffer, size + 1);
     return buffer;
 }
+
+std::string sendSyncMessage(const char* name, const char* body)
+{
+    WKStringRef nameWKString = WKStringCreateWithUTF8CString(name);
+    WKStringRef bodyWKString = NULL;
+    if (body) {
+        bodyWKString = WKStringCreateWithUTF8CString(body);
+    }
+    WKTypeRef retWKType = NULL;
+    WKBundlePostSynchronousMessage(s_injectedBundleRef,
+                                   nameWKString,
+                                   bodyWKString,
+                                   &retWKType);
+    WKRelease(nameWKString);
+    if (bodyWKString) {
+        WKRelease(bodyWKString);
+    }
+    if (retWKType) {
+        std::string retString = toString(static_cast<WKStringRef>(retWKType));
+        WKRelease(retWKType);
+        return retString;
+    } else {
+        return std::string();
+    }
+}
+
+void sendAsyncMessage(const char* name, const char* body)
+{
+    WKStringRef nameWKString = WKStringCreateWithUTF8CString(name);
+    WKStringRef bodyWKString = NULL;
+    if (body) {
+        bodyWKString = WKStringCreateWithUTF8CString(body);
+    }
+    WKTypeRef retWKType = NULL;
+    WKBundlePostMessage(s_injectedBundleRef,
+                        nameWKString,
+                        bodyWKString);
+    WKRelease(nameWKString);
+    if (bodyWKString) {
+        WKRelease(bodyWKString);
+    }
+}
 }
 
 void IPCMessageSupport::setWKBundleRef(WKBundleRef bundleRef)
@@ -75,7 +120,8 @@ const char* IPCMessageSupport::sendMessageToUiProcess(
         return NULL;
     }
 
-    if (!strcmp(name, "tizen://getWindowHandle")) {
+    // tizen://getWindowHandle
+    if (!strcmp(name, TIZEN_GET_WINDOW_HANDLE)) {
         if (s_xWindowHandle == 0) {
             return NULL;
         } else {
@@ -86,26 +132,11 @@ const char* IPCMessageSupport::sendMessageToUiProcess(
         }
     }
 
-    WKStringRef bodyWKString = NULL;
-    WKStringRef nameWKString = WKStringCreateWithUTF8CString(name);
-    if (body) {
-        bodyWKString = WKStringCreateWithUTF8CString(body);
-    }
-    WKTypeRef retWKType = NULL;
-    WKBundlePostSynchronousMessage(s_injectedBundleRef,
-                                   nameWKString,
-                                   bodyWKString,
-                                   &retWKType);
-    WKRelease(nameWKString);
-    if (bodyWKString) {
-        WKRelease(bodyWKString);
-    }
-    if (retWKType) {
-        std::string retString = toString(static_cast<WKStringRef>(retWKType));
-        WKRelease(retWKType);
-        return strdup(retString.c_str());
-    } else {
+    // tizen://clearAllCookies
+    if (!strcmp(name, TIZEN_CLEAR_ALL_COOKIES)) {
+        sendAsyncMessage(name, body);
         return NULL;
     }
+
     return NULL;
 }
index 1f6326f..6f38328 100644 (file)
@@ -268,7 +268,7 @@ JSValueRef JSPreferences::removeItem(JSContextRef context,
 
         if (!!oldValue) { oldValueStr = *oldValue; }
         if (!!newValue) { newValueStr = *newValue; }
-        
+
         DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
 
         LogDebug("end");
@@ -308,7 +308,7 @@ JSValueRef JSPreferences::setItem(JSContextRef context,
 
         if (!!oldValue) { oldValueStr = *oldValue; }
         if (!!newValue) { newValueStr = *newValue; }
-        
+
         DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
 
         LogDebug("end");
@@ -523,7 +523,7 @@ bool JSPreferences::setProperty(JSContextRef context,
 
         if (!!oldValue) { oldValueStr = *oldValue; }
         if (!!newValue) { newValueStr = *newValue; }
-        
+
         DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
 
         LogDebug("end");