fix crash issue for authentication popup
[framework/osp/web.git] / src / controls / FWebCtrl_PageNavigationListImpl.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                FWebCtrl_PageNavigationListImpl.cpp
20  * @brief               The file contains the definition of _PageNavigationListImpl class.
21  *
22  * The file contains the definition of _PageNavigationListImpl class.
23  */
24 #include <FWebCtrlPageNavigationList.h>
25 #include <FWebHistoryItem.h>
26 #include <FBaseSysLog.h>
27 #include "FWebCtrl_PageNavigationListImpl.h"
28
29
30 using namespace Tizen::Base::Collection;
31
32
33 namespace Tizen { namespace Web { namespace Controls
34 {
35
36
37 _PageNavigationListImpl::_PageNavigationListImpl(void)
38         : __pNavigationList(null)
39         , __currentIndex(-1)
40 {
41 }
42
43
44 _PageNavigationListImpl::~_PageNavigationListImpl(void)
45 {
46 }
47
48
49 void
50 _PageNavigationListImpl::SetPageNavigationList(IList* pList, int currentIndex)
51 {
52         __pNavigationList = std::unique_ptr<IList, AllElementsDeleter>(pList);
53         __currentIndex  = currentIndex;
54 }
55
56
57 const HistoryItem*
58 _PageNavigationListImpl::GetCurrentItem(void) const
59 {
60         int index = GetCurrentIndex();
61
62         return GetItemAt(index);
63 }
64
65
66 int
67 _PageNavigationListImpl::GetCurrentIndex(void) const
68 {
69         return __currentIndex;
70 }
71
72
73 const HistoryItem*
74 _PageNavigationListImpl::GetItemAt(int index) const
75 {
76         SysTryReturn(NID_WEB_CTRL,
77                            index >= 0 && index < GetItemCount(), null, E_OUT_OF_RANGE,
78                            "[E_OUT_OF_RANGE] The index(%d) must be between 0 and %d(%d).", index, GetItemCount() - 1, index);
79
80         return dynamic_cast< const HistoryItem* >(__pNavigationList->GetAt(index));
81 }
82
83
84 int
85 _PageNavigationListImpl::GetItemCount(void) const
86 {
87         return __pNavigationList->GetCount();
88 }
89
90
91 _PageNavigationListImpl*
92 _PageNavigationListImpl::GetInstance(PageNavigationList* pPageNavigationList)
93 {
94         return pPageNavigationList->__pPageNavigationListImpl;
95 }
96
97
98 const _PageNavigationListImpl*
99 _PageNavigationListImpl::GetInstance(const PageNavigationList* pPageNavigationList)
100 {
101         return pPageNavigationList->__pPageNavigationListImpl;
102 }
103
104
105 }}} // Tizen::Web::Controls