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 FWebWebHistory.cpp
20 * @brief The file contains the definition of WebHistory class.
22 * This file contains the definition of WebHistory class.
25 #include <unique_ptr.h>
26 #include <FBaseResult.h>
27 #include <FBaseSysLog.h>
28 #include <FWebWebHistory.h>
29 #include <FSec_AccessController.h>
30 #include "FWeb_WebHistoryImpl.h"
33 using namespace Tizen::Security;
36 namespace Tizen { namespace Web
40 WebHistory::WebHistory(void)
41 : __pWebHistoryImpl(null)
46 WebHistory::~WebHistory(void)
48 delete __pWebHistoryImpl;
49 __pWebHistoryImpl = null;
54 WebHistory::Construct(void)
56 SysAssertf(__pWebHistoryImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
60 std::unique_ptr<_WebHistoryImpl> pWebHistoryImpl(new (std::nothrow) _WebHistoryImpl());
61 SysTryReturnResult(NID_WEB, pWebHistoryImpl.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
63 r = pWebHistoryImpl->Construct();
64 SysTryReturn(NID_WEB, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
66 __pWebHistoryImpl = pWebHistoryImpl.release();
73 WebHistory::GetItemAt(int index) const
75 SysAssertf(__pWebHistoryImpl != null, "Not yet constructed. Construct() should be called before use.");
80 r = _AccessController::CheckUserPrivilege(_PRV_WEB_PRIVACY);
81 SysTryReturn(NID_WEB, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
83 const HistoryItem* pItem = __pWebHistoryImpl->GetItemAt(index);
84 SysTryReturn(NID_WEB, pItem, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
86 SysLog(NID_WEB, "The current value of index is %d", index);
93 WebHistory::GetItemCount(void) const
95 SysAssertf(__pWebHistoryImpl != null, "Not yet constructed. Construct() should be called before use.");
100 r = _AccessController::CheckUserPrivilege(_PRV_WEB_PRIVACY);
101 SysTryReturn(NID_WEB, r == E_SUCCESS, -1, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
103 return __pWebHistoryImpl->GetItemCount();