Add the Web Contents Console Meesage 56/137356/2
authorcookie <cookie@samsung.com>
Wed, 5 Jul 2017 10:05:15 +0000 (10:05 +0000)
committercookie <cookie@samsung.com>
Thu, 6 Jul 2017 08:50:25 +0000 (08:50 +0000)
[ Problem ] http://suprem.sec.samsung.net/jira/browse/RWASP-1859
[ Cause ] There is no implementation
[ Solution]Implementation console msg
[ Verify ] Check it by sdb dlog

Change-Id: I8ec4548b7032443c57b1d90ce08060854adac2eb
Signed-off-by: cookie <cookie@samsung.com>
services/WebEngineService/WebView.cpp

index ccb47f4..76c1498 100755 (executable)
@@ -59,6 +59,8 @@
 #include <glib.h>
 #include <curl/curl.h>
 
+#define WEB_CONSOLE_MSG 0
+
 const char* const APPLICATION_NAME_FOR_USER_AGENT =
     "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.69 safari/537.36 ";
 
@@ -246,6 +248,23 @@ void __vibration_cancel_cb(void * /*data*/)
     cancel_vibration();
 }
 
+#if WEB_CONSOLE_MSG
+void __console_message_cb(void* , Evas_Object*, void* event_info)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    if (!event_info) {
+        BROWSER_LOGW("[%s] even_info = nullptr", __PRETTY_FUNCTION__);
+        return;
+    }
+    Ewk_Console_Message* console_message = (Ewk_Console_Message*)event_info;
+
+    BROWSER_LOGD("<<< __console_message_cb>>");
+    BROWSER_LOGD("console message:%s:", ewk_console_message_source_get(console_message));
+    BROWSER_LOGD("console line=%d:", ewk_console_message_line_get(console_message));
+    BROWSER_LOGD("console level=%d:", ewk_console_message_level_get(console_message));
+    BROWSER_LOGD("console text%s\n", ewk_console_message_text_get(console_message));
+}
+#endif
 void WebView::registerCallbacks()
 {
     evas_object_smart_callback_add(m_ewkView, "load,started", __loadStarted, this);
@@ -288,6 +307,10 @@ void WebView::registerCallbacks()
     evas_object_smart_callback_add(m_ewkView, "topcontrol,moved", __top_controls_moved_cb, this);
     evas_object_smart_callback_add(m_ewkView, "notification,permission,reply", __notification_reply_cb, this);
 
+#if WEB_CONSOLE_MSG
+    evas_object_smart_callback_add(m_ewkView, "console,message", __console_message_cb, this)
+#endif
+
     ewk_view_did_change_theme_color_callback_set(m_ewkView, __theme_color_changed, this);
 }
 
@@ -331,6 +354,11 @@ void WebView::unregisterCallbacks()
     evas_object_smart_callback_del_full(m_ewkView, "topcontrol,moved", __top_controls_moved_cb, this);
 
     evas_object_smart_callback_del_full(m_ewkView, "notification,permission,reply", __notification_reply_cb, this);
+
+#if WEB_CONSOLE_MSG
+    evas_object_smart_callback_del_full(m_ewkView, "ConsoleMessage", __console_message_cb, this);
+#endif
+
     ewk_context_push_message_callback_set(m_ewkContext, nullptr, nullptr);
 }