add patch
[framework/osp/web.git] / src / controls / FWebCtrlPageNavigationList.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file                FWebCtrlPageNavigationList.cpp
20  * @brief               The file contains the definition of PageNavigationList class.
21  *
22  * The file contains the definition of PageNavigationList class.
23  */
24 #include <new>
25 #include <FBaseResult.h>
26 #include <FBaseSysLog.h>
27 #include <FWebCtrlPageNavigationList.h>
28 #include <FWebHistoryItem.h>
29 #include "FWebCtrl_PageNavigationListImpl.h"
30
31
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34
35
36 namespace Tizen { namespace Web { namespace Controls
37 {
38
39
40 PageNavigationList::PageNavigationList(void)
41         : __pPageNavigationListImpl(new (std::nothrow) _PageNavigationListImpl())
42 {
43         SysTryReturnVoidResult(NID_WEB_CTRL, __pPageNavigationListImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
44 }
45
46
47 PageNavigationList::~PageNavigationList(void)
48 {
49         delete __pPageNavigationListImpl;
50         __pPageNavigationListImpl = null;
51 }
52
53
54 const HistoryItem*
55 PageNavigationList::GetCurrentItem(void) const
56 {
57         SysAssertf(__pPageNavigationListImpl != null, "Not yet constructed. Construct() should be called before use.");
58
59         return __pPageNavigationListImpl->GetCurrentItem();
60 }
61
62
63 int
64 PageNavigationList::GetCurrentIndex(void) const
65 {
66         SysAssertf(__pPageNavigationListImpl != null, "Not yet constructed. Construct() should be called before use.");
67
68         return __pPageNavigationListImpl->GetCurrentIndex();
69 }
70
71
72 const HistoryItem*
73 PageNavigationList::GetItemAt(int index) const
74 {
75         SysAssertf(__pPageNavigationListImpl != null, "Not yet constructed. Construct() should be called before use.");
76
77         ClearLastResult();
78
79         const HistoryItem* pItem = __pPageNavigationListImpl->GetItemAt(index);
80         SysTryReturn(NID_WEB_CTRL, pItem, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
81
82         SysLog(NID_WEB_CTRL, "The current value of index is %d", index);
83
84         return pItem;
85 }
86
87
88 int
89 PageNavigationList::GetItemCount(void) const
90 {
91         SysAssertf(__pPageNavigationListImpl != null, "Not yet constructed. Construct() should be called before use.");
92
93         return __pPageNavigationListImpl->GetItemCount();
94 }
95
96
97 }}} // Tizen::Web::Controls