2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWeb_HistoryItemImplcpp
20 * @brief The file contains the definition of _HistoryItemImpl class.
22 * This file contains the definition of _HistoryItemImpl class.
24 #include <Ecore_Evas.h>
25 //#include <elm_config.h>
27 #include <favorites.h>
28 #include <unique_ptr.h>
29 #include <FBaseSysLog.h>
30 #include <FGrpBitmap.h>
31 #include <FGrpDimension.h>
32 #include <FBase_StringConverter.h>
33 #include <FUiCtrlFrame.h>
34 #include <FWebHistoryItem.h>
35 #include "FWeb_HistoryItemImpl.h"
36 #include "FWebCtrl_Utility.h"
39 using namespace Tizen::Base;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Web::Controls;
45 namespace Tizen { namespace Web
49 _HistoryItemImpl::_HistoryItemImpl(void)
57 _HistoryItemImpl::~_HistoryItemImpl(void)
63 _HistoryItemImpl::SetHistoryItem(const String& url, const String& title, int id)
72 _HistoryItemImpl::GetTitle(void) const
79 _HistoryItemImpl::GetUrl(void) const
86 _HistoryItemImpl::GetFaviconN(void) const
91 Evas_Object* pIcon = null;
93 Ewk_Context* pDefaultContext = null;
94 std::unique_ptr<char[]> pUrl;
95 std::unique_ptr<Bitmap> pBitmapImage;
99 BufferInfo bufferInfo;
100 ByteBuffer byteBuffer;
102 Evas* pEvas = _Utility::GetEvasFromUiApp(pFrame);
103 SysTryCatch(NID_WEB_CTRL, pEvas, , E_SYSTEM, "[E_SYSTEM] Propagating.");
107 pDefaultContext = ewk_context_default_get();
109 pUrl = std::unique_ptr<char[]>(_StringConverter::CopyToCharArrayN(__url));
110 pIcon = ewk_context_icon_database_icon_object_add(pDefaultContext, pUrl.get(), pEvas);
114 ret = favorites_history_get_favicon(__id, pEvas, &pIcon);
115 SysTryCatch(NID_WEB_CTRL, ret == FAVORITES_ERROR_NONE, , E_SYSTEM, "[E_SYSTEM] Propagating.");
123 r = _Utility::GetPixelBufferFromEvasObject(pIcon, bufferInfo);
124 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
126 dimension.width = bufferInfo.width;
127 dimension.height = bufferInfo.height;
129 r = byteBuffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
130 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
132 pBitmapImage = std::unique_ptr<Bitmap>(new (std::nothrow) Bitmap());
133 SysTryCatch(NID_WEB_CTRL, pBitmapImage.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
135 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
136 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
141 return pBitmapImage.release();
151 _HistoryItemImpl::GetInstance(HistoryItem* pHistoryItem)
153 return pHistoryItem->__pHistoryItemImpl;
157 const _HistoryItemImpl*
158 _HistoryItemImpl::GetInstance(const HistoryItem* pHistoryItem)
160 return pHistoryItem->__pHistoryItemImpl;