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 <FWebHistoryItem.h>
34 #include "FWeb_HistoryItemImpl.h"
35 #include "FWebCtrl_Utility.h"
38 using namespace Tizen::Base;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Web::Controls;
43 namespace Tizen { namespace Web
47 _HistoryItemImpl::_HistoryItemImpl(void)
55 _HistoryItemImpl::~_HistoryItemImpl(void)
61 _HistoryItemImpl::SetHistoryItem(const String& url, const String& title, int id)
70 _HistoryItemImpl::GetTitle(void) const
77 _HistoryItemImpl::GetUrl(void) const
84 _HistoryItemImpl::GetFaviconN(void) const
88 Evas* pEvas = _Utility::GetEvasFromUiApp();
89 SysTryReturn(NID_WEB_CTRL, pEvas, null, E_SYSTEM, "[E_SYSTEM] Propagating.");
91 Evas_Object* pIcon = null;
94 Ewk_Context* pDefaultContext = ewk_context_default_get();
96 const std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(__url));
97 pIcon = ewk_context_icon_database_icon_object_add(pDefaultContext, pUrl.get(), pEvas);
101 int ret = favorites_history_get_favicon(__id, pEvas, &pIcon);
102 SysTryReturn(NID_WEB_CTRL, ret == FAVORITES_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] Propagating.");
110 BufferInfo bufferInfo;
111 r = _Utility::GetPixelBufferFromEvasObject(pIcon, bufferInfo);
112 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
114 const Dimension dimension(bufferInfo.width, bufferInfo.height);
116 ByteBuffer byteBuffer;
117 r = byteBuffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
118 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
120 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
121 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
123 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
124 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
126 return pBitmapImage.release();
131 _HistoryItemImpl::GetInstance(HistoryItem* pHistoryItem)
133 return pHistoryItem->__pHistoryItemImpl;
137 const _HistoryItemImpl*
138 _HistoryItemImpl::GetInstance(const HistoryItem* pHistoryItem)
140 return pHistoryItem->__pHistoryItemImpl;