Custom handler callbacks connected to JS API.
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 29 Nov 2012 09:43:24 +0000 (10:43 +0100)
committerGerrit Code Review <gerrit2@kim11>
Tue, 4 Dec 2012 11:34:37 +0000 (20:34 +0900)
[Issue#] N/A
[Feature] Custom handler callbacks has to be connected to JS API
[Problem] N/A
[Cause] N/A
[Solution] Callbacks connected.

[Verification] Run manual test:
http://slp-info.sec.samsung.net/gerrit/#/c/119846/
Press all buttons and see if logs from handlers are displayed correctly.

Change-Id: I8bacfd01db14d44360e67bfa3e92ca2d7f8f585f

src/view/webkit/view_logic.cpp
src/view/webkit/view_logic.h

index 1d32022..a38fbda 100644 (file)
@@ -113,6 +113,14 @@ const char * const EWK_FULLSCREEN_EXIT = "fullscreen,exitfullscreen";
 // IME Callback
 const char * const EWK_INPUTMETHOD_CHANGED = "inputmethod,changed";
 const char * const EWK_EDITORCLIENT_IME_CLOSED = "editorclient,ime,closed";
+
+// Custom handlers
+const char * const EWK_PROTOCOLHANDLER_REGISTRATION = "protocolhandler,registration,requested";
+const char * const EWK_PROTOCOLHANDLER_ISREGISTERED = "protocolhandler,isregistered";
+const char * const EWK_PROTOCOLHANDLER_UNREGISTRATION = "protocolhandler,unregistration,requested";
+const char * const EWK_CONTENTHANDLER_REGISTRATION = "contenthandler,registration,requested";
+const char * const EWK_CONTENTHANDLER_ISREGISTERED = "contenthandler,isregistered";
+const char * const EWK_CONTENTHANDLER_UNREGISTRATION = "contenthandler,unregistration,requested";
 }
 
 ViewLogic::ViewLogic():
@@ -662,6 +670,39 @@ void ViewLogic::ewkClientInit(Evas_Object *wkView) {
         EWK_EDITORCLIENT_IME_CLOSED,
         imeCloseCallback,
         this);
+
+    // custom content/scheme handlers
+    evas_object_smart_callback_add(
+        wkView,
+        EWK_PROTOCOLHANDLER_REGISTRATION,
+        protocolHandlerRegistrationCallback,
+        this);
+    evas_object_smart_callback_add(
+        wkView,
+        EWK_PROTOCOLHANDLER_ISREGISTERED,
+        protocolHandlerIsRegisteredCallback,
+        this);
+    evas_object_smart_callback_add(
+        wkView,
+        EWK_PROTOCOLHANDLER_UNREGISTRATION,
+        protocolHandlerUnregistrationCallback,
+        this);
+
+    evas_object_smart_callback_add(
+        wkView,
+        EWK_CONTENTHANDLER_REGISTRATION,
+        contentHandlerRegistrationCallback,
+        this);
+    evas_object_smart_callback_add(
+        wkView,
+        EWK_CONTENTHANDLER_ISREGISTERED,
+        contentHandlerIsRegisteredCallback,
+        this);
+    evas_object_smart_callback_add(
+        wkView,
+        EWK_CONTENTHANDLER_UNREGISTRATION,
+        contentHandlerUnregistrationCallback,
+        this);
 }
 
 void ViewLogic::ewkClientDeinit(Evas_Object *wkView) {
@@ -784,6 +825,33 @@ void ViewLogic::ewkClientDeinit(Evas_Object *wkView) {
         wkView,
         EWK_EDITORCLIENT_IME_CLOSED,
         imeCloseCallback);
+
+    // custom content/scheme handlers
+    evas_object_smart_callback_del(
+        wkView,
+        EWK_PROTOCOLHANDLER_REGISTRATION,
+        protocolHandlerRegistrationCallback);
+    evas_object_smart_callback_del(
+        wkView,
+        EWK_PROTOCOLHANDLER_ISREGISTERED,
+        protocolHandlerIsRegisteredCallback);
+    evas_object_smart_callback_del(
+        wkView,
+        EWK_PROTOCOLHANDLER_UNREGISTRATION,
+        protocolHandlerUnregistrationCallback);
+
+    evas_object_smart_callback_del(
+        wkView,
+        EWK_CONTENTHANDLER_REGISTRATION,
+        contentHandlerRegistrationCallback);
+    evas_object_smart_callback_del(
+        wkView,
+        EWK_CONTENTHANDLER_ISREGISTERED,
+        contentHandlerIsRegisteredCallback);
+    evas_object_smart_callback_del(
+        wkView,
+        EWK_CONTENTHANDLER_UNREGISTRATION,
+        contentHandlerUnregistrationCallback);
 }
 
 void ViewLogic::createEwkView(Evas* canvas)
@@ -1587,6 +1655,84 @@ void ViewLogic::imeCloseCallback(
             &args);
 }
 
+// helper method
+void ViewLogic::debugCustomHandlerData(void* data)
+{
+    Assert(data);
+    Ewk_Custom_Handlers_Data* handler =
+                static_cast<Ewk_Custom_Handlers_Data*>(data);
+    const char* base_url = ewk_custom_handlers_data_base_url_get(handler);
+    if (base_url) {
+        LogDebug("base url: " << base_url);
+    }
+    const char* url = ewk_custom_handlers_data_url_get(handler);
+    if (url) {
+        LogDebug("url: " << url);
+    }
+    const char* target = ewk_custom_handlers_data_target_get(handler);
+    if (target) {
+        LogDebug("target: " << target);
+    }
+    const char* title = ewk_custom_handlers_data_title_get(handler);
+    if (title) {
+        LogDebug("title: " << title);
+    }
+}
+
+void ViewLogic::protocolHandlerRegistrationCallback(void* data,
+                                                    Evas_Object* obj,
+                                                    void* eventInfo)
+{
+    LogDebug("enter");
+    debugCustomHandlerData(eventInfo);
+    // TODO to be continued...
+}
+
+void ViewLogic::protocolHandlerIsRegisteredCallback(void* data,
+                                                    Evas_Object* obj,
+                                                    void* eventInfo)
+{
+    LogDebug("enter");
+    debugCustomHandlerData(eventInfo);
+    // TODO to be continued...
+}
+
+void ViewLogic::protocolHandlerUnregistrationCallback(void* data,
+                                                      Evas_Object* obj,
+                                                      void* eventInfo)
+{
+    LogDebug("enter");
+    debugCustomHandlerData(eventInfo);
+    // TODO to be continued...
+}
+
+void ViewLogic::contentHandlerRegistrationCallback(void* data,
+                                                   Evas_Object* obj,
+                                                   void* eventInfo)
+{
+    LogDebug("enter");
+    debugCustomHandlerData(eventInfo);
+    // TODO to be continued...
+}
+
+void ViewLogic::contentHandlerIsRegisteredCallback(void* data,
+                                                   Evas_Object* obj,
+                                                   void* eventInfo)
+{
+    LogDebug("enter");
+    debugCustomHandlerData(eventInfo);
+    // TODO to be continued...
+}
+
+void ViewLogic::contentHandlerUnregistrationCallback(void* data,
+                                                     Evas_Object* obj,
+                                                     void* eventInfo)
+{
+    LogDebug("enter");
+    debugCustomHandlerData(eventInfo);
+    // TODO to be continued...
+}
+
 void ViewLogic::didRunJavaScriptCallback(
         Evas_Object* /*obj*/,
         const char* result,
index a7f2884..84fce92 100644 (file)
@@ -215,6 +215,29 @@ class ViewLogic : public ViewModule::IViewModule
             Evas_Object* obj,
             void* eventInfo);
 
+    static void debugCustomHandlerData(void* data);
+
+    // custom content/scheme handlers
+    static void protocolHandlerRegistrationCallback(void* data,
+            Evas_Object* obj,
+            void* eventInfo);
+    static void protocolHandlerIsRegisteredCallback(void* data,
+            Evas_Object* obj,
+            void* eventInfo);
+    static void protocolHandlerUnregistrationCallback(void* data,
+            Evas_Object* obj,
+            void* eventInfo);
+
+    static void contentHandlerRegistrationCallback(void* data,
+            Evas_Object* obj,
+            void* eventInfo);
+    static void contentHandlerIsRegisteredCallback(void* data,
+            Evas_Object* obj,
+            void* eventInfo);
+    static void contentHandlerUnregistrationCallback(void* data,
+            Evas_Object* obj,
+            void* eventInfo);
+
     // JS execute callback
     static void didRunJavaScriptCallback(
             Evas_Object* obj,