1 // Copyright 2014 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.
5 package org.chromium.content_public.browser;
7 import org.chromium.base.VisibleForTesting;
10 * The NavigationController Java wrapper to allow communicating with the native
11 * NavigationController object.
13 public interface NavigationController {
15 * @return Whether back navigation is possible from the "current entry".
20 * @return Whether forward navigation is possible from the "current entry".
22 boolean canGoForward();
25 * @param offset The offset into the navigation history.
26 * @return Whether we can move in history by given offset
28 boolean canGoToOffset(int offset);
31 * Navigates to the specified offset from the "current entry". Does nothing if the offset is
33 * @param offset The offset into the navigation history.
35 void goToOffset(int offset);
38 * Navigates to the specified index in the navigation entry for this page.
39 * @param index The navigation index to navigate to.
41 void goToNavigationIndex(int index);
44 * Goes to the navigation entry before the current one.
49 * Goes to the navigation entry following the current one.
54 * Loads the current navigation if there is a pending lazy load (after tab restore).
56 public void loadIfNecessary();
59 * Requests the current navigation to be loaded upon the next call to loadIfNecessary().
61 public void requestRestoreLoad();
64 * Reload the current page.
66 public void reload(boolean checkForRepost);
69 * Reload the current page, ignoring the contents of the cache.
71 public void reloadIgnoringCache(boolean checkForRepost);
74 * Cancel the pending reload.
76 public void cancelPendingReload();
79 * Continue the pending reload.
81 public void continuePendingReload();
84 * Load url without fixing up the url string. Consumers of NavigationController are
85 * responsible for ensuring the URL passed in is properly formatted (i.e. the
86 * scheme has been added if left off during user input).
87 * @param params Parameters for this load.
89 public void loadUrl(LoadUrlParams params);
92 * Clears NavigationController's page history in both backwards and
93 * forwards directions.
96 public void clearHistory();
99 * Get a copy of the navigation history of NavigationController.
100 * @return navigation history of NavigationController.
102 public NavigationHistory getNavigationHistory();
105 * Get the navigation history of NavigationController from current navigation entry index
106 * with direction (forward/backward)
107 * @param isForward determines forward or backward from current index
108 * @param itemLimit maximum number of entries to be retrieved in specified
110 * @return navigation history by keeping above constraints.
112 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit);
115 * Get Original URL for current Navigation entry of NavigationController.
116 * @return The original request URL for the current navigation entry, or null if there is no
119 public String getOriginalUrlForVisibleNavigationEntry();
122 * Clears SSL preferences for this NavigationController.
124 public void clearSslPreferences();
127 * Get whether or not we're using a desktop user agent for the currently loaded page.
128 * @return true, if use a desktop user agent and false for a mobile one.
130 public boolean getUseDesktopUserAgent();
133 * Set whether or not we're using a desktop user agent for the currently loaded page.
134 * @param override If true, use a desktop user agent. Use a mobile one otherwise.
135 * @param reloadOnChange Reload the page if the UA has changed.
137 public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange);
140 * @return The pending {@link NavigationEntry} for this controller or {@code null} if none
143 public NavigationEntry getPendingEntry();