fix parameter of OnFaviconReceived()
[platform/framework/native/web.git] / src / controls / FWebCtrl_WebImpl.cpp
index e2a5b55..c2031f8 100755 (executable)
@@ -1119,6 +1119,27 @@ OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
 
 
 void
+OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
+{
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
+       SysAssertf(pImpl, "Failed to request");
+
+       if (pImpl->GetLoadingListener())
+       {
+               result r = E_SUCCESS;
+
+               std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
+               SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
+               SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               pEventArg.release();
+       }
+
+}
+
+
+void
 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
 {
        _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
@@ -3168,6 +3189,7 @@ _WebImpl::SetEventListenerCallback(void) const
                evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
 
                evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
+               evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
 
                Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
                SysAssertf(pContext, "Failed to get webkit instance.");
@@ -3240,6 +3262,7 @@ _WebImpl::RemoveEventListenerCallback(void) const
                evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
 
                evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
+               evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
 
                ewk_view_open_panel_callback_set(null, null, null);
 
@@ -3792,6 +3815,15 @@ _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
                break;
        }
 
+       case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
+       {
+               std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
+               SysTryReturn(NID_WEB_CTRL, pFavicon.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               pLoadingListner->OnFaviconReceived(*pFavicon.get());
+               break;
+       }
+
        default:
        {
                SysAssert(false);