add OnFaviconReceived() callback
authorSeongjun Yim <se201.yim@samsung.com>
Wed, 20 Mar 2013 05:39:03 +0000 (14:39 +0900)
committerSeongjun Yim <se201.yim@samsung.com>
Wed, 20 Mar 2013 05:39:03 +0000 (14:39 +0900)
Change-Id: I148822f02b84ad90ae73483c3fbb1e929f5a0436
Signed-off-by: Seongjun Yim <se201.yim@samsung.com>
inc/FWebCtrlILoadingListener.h
inc/FWebCtrlWeb.h
src/controls/FWebCtrl_WebEventArg.h
src/controls/FWebCtrl_WebImpl.cpp

index 8690463..e004919 100755 (executable)
@@ -215,15 +215,16 @@ public:
         */
        virtual DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader) = 0;
 
+       /**
+        * Called when the favicon of the new page has been received. @n
+        * If receiving this callback the once, an application can get favicon by using Tizen::Web::Controls::GetFaviconN().
+        *
+        * @since               2.1
+        * @see Tizen::Web::Controls::GetFaviconN()
+        */
+       virtual void OnFaviconReceived(void) {}
+
 protected:
-       //
-       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
-       //
-       // Gets the Impl instance.
-       //
-       // @since               2.0
-       //
-       virtual void ILoadingListener_Reserved1(void) {}
 
        //
        // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
index 5d844c1..6aa64fc 100755 (executable)
@@ -858,6 +858,7 @@ public:
         * @since               2.0
         *
         * @return              The image
+        * @see Tizen::Web::Controls::ILoadingListener::OnFaviconReceived()
         */
        Tizen::Graphics::Bitmap* GetFaviconN(void) const;
 
index 236854b..5afbdc6 100755 (executable)
@@ -59,6 +59,7 @@ enum _WebEventType
        WEB_EVENT_LOADINGLISTENER_COMPLETED,
        WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_REQUESTED,
        WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED,
+       WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED,
 
        WEB_EVENT_WEBDOWNLOADLISTENER = 0x300,
        WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED,
index e2a5b55..5dd0515 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,12 @@ _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
                break;
        }
 
+       case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
+       {
+               pLoadingListner->OnFaviconReceived();
+               break;
+       }
+
        default:
        {
                SysAssert(false);