NavigationHistory.java revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
1// Copyright 2012 The Chromium Authors. 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 5package org.chromium.content_public.browser; 6 7//import org.chromium.content_public.browser.NavigationEntry; 8 9import java.util.ArrayList; 10 11/** 12 * {@link NavigationHistory} captures a snapshot of the navigation history of a 13 * {@link ContentViewCore}. It is a copy and will not be updated as navigation 14 * occurs on the source {@link ContentViewCore}. 15 */ 16public class NavigationHistory { 17 18 private final ArrayList<NavigationEntry> mEntries = new ArrayList<NavigationEntry>(); 19 private int mCurrentEntryIndex; 20 21 public void addEntry(NavigationEntry entry) { 22 mEntries.add(entry); 23 } 24 25 public void setCurrentEntryIndex(int currentEntryIndex) { 26 mCurrentEntryIndex = currentEntryIndex; 27 } 28 29 /** 30 * @return The number of entries in the history. 31 */ 32 public int getEntryCount() { 33 return mEntries.size(); 34 } 35 36 /** 37 * Returns the {@link NavigationEntry} for the given index. 38 */ 39 public NavigationEntry getEntryAtIndex(int index) { 40 return mEntries.get(index); 41 } 42 43 /** 44 * Returns the index of the entry the {@link ContentViewCore} was navigated to 45 * when the history was fetched. 46 */ 47 public int getCurrentEntryIndex() { 48 return mCurrentEntryIndex; 49 } 50 51} 52