Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / core / src / org / xwalk / core / WebBackForwardList.java
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.xwalk.core;
6
7 import java.io.Serializable;
8
9 import org.chromium.content.browser.NavigationHistory;
10
11 // Wrap NavigationHistory in content as WebBackForwardList.
12 public class WebBackForwardList implements Cloneable, Serializable {
13     private NavigationHistory mHistory;
14
15     public WebBackForwardList(NavigationHistory history) {
16         mHistory = history;
17     }
18
19     public WebBackForwardList(WebBackForwardList list) {
20         mHistory = list.mHistory;
21     }
22
23     public synchronized WebHistoryItem getCurrentItem() {
24        return getItemAtIndex(getCurrentIndex());
25     }
26
27     public synchronized int getCurrentIndex() {
28         return mHistory.getCurrentEntryIndex();
29     }
30
31     public synchronized WebHistoryItem getItemAtIndex(int index) {
32         return new WebHistoryItem(mHistory.getEntryAtIndex(index));
33     }
34
35     public synchronized int getSize() {
36         return mHistory.getEntryCount();
37     }
38
39     protected synchronized WebBackForwardList clone() {
40         return new WebBackForwardList(this);
41     }
42 }