Tizen 2.2.1
[framework/osp/web.git] / src / FWeb_BookmarkItemImpl.cpp
index 63bca69..3ad4240 100755 (executable)
@@ -28,6 +28,7 @@
 #include <FBaseSysLog.h>
 #include <FGrpBitmap.h>
 #include <FGrpDimension.h>
+#include <FUiCtrlFrame.h>
 #include <FWebBookmarkItem.h>
 #include "FWeb_BookmarkItemImpl.h"
 #include "FWebCtrl_Utility.h"
@@ -35,6 +36,7 @@
 
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
+using namespace Tizen::Ui::Controls;
 using namespace Tizen::Web::Controls;
 
 
@@ -87,36 +89,51 @@ Bitmap*
 _BookmarkItemImpl::GetFaviconN(void) const
 {
        result r = E_SUCCESS;
+       Frame* pFrame = null;
+       Evas* pEvas = null;
+       Evas_Object* pIcon = null;
+
+       BufferInfo bufferInfo;
+       ByteBuffer byteBuffer;
 
-       Evas* pEvas = _Utility::GetEvasFromUiApp();
-       SysTryReturn(NID_WEB, pEvas, null, E_SYSTEM, "[E_SYSTEM] Propagating.");
+       std::unique_ptr<Bitmap> pImage;
+       Dimension dimension;
+       int ret = 0;
 
-       Evas_Object* pIcon = null;
-       int ret = favorites_bookmark_get_favicon(__id, pEvas, &pIcon);
-       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] Propagating.");
+       pEvas = _Utility::GetEvasFromUiApp(pFrame);
+       SysTryCatch(NID_WEB, pEvas, , E_SYSTEM, "[E_SYSTEM] Propagating.");
+
+       ret = favorites_bookmark_get_favicon(__id, pEvas, &pIcon);
+       SysTryCatch(NID_WEB, ret == FAVORITES_ERROR_NONE, , E_SYSTEM, "[E_SYSTEM] Propagating.");
 
        if (!pIcon)
        {
                return null;
        }
 
-       BufferInfo bufferInfo;
        r = _Utility::GetPixelBufferFromEvasObject(pIcon,  bufferInfo);
-       SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-       const Dimension dimension(bufferInfo.width, bufferInfo.height);
+       dimension.width = bufferInfo.width;
+       dimension.height = bufferInfo.height;
 
-       ByteBuffer byteBuffer;
        r = byteBuffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
-       SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-       std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
-       SysTryReturn(NID_WEB, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       pImage = std::unique_ptr<Bitmap>(new (std::nothrow) Bitmap());
+       SysTryCatch(NID_WEB, pImage.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
        r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
-       SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       delete pFrame;
 
        return pImage.release();
+
+CATCH:
+       delete pFrame;
+
+       return null;
 }