NavigationController.java revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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. 4 5package org.chromium.content_public.browser; 6 7import org.chromium.base.VisibleForTesting; 8 9/** 10 * The NavigationController Java wrapper to allow communicating with the native 11 * NavigationController object. 12 */ 13public interface NavigationController { 14 /** 15 * @return Whether back navigation is possible from the "current entry". 16 */ 17 boolean canGoBack(); 18 19 /** 20 * @return Whether forward navigation is possible from the "current entry". 21 */ 22 boolean canGoForward(); 23 24 /** 25 * @param offset The offset into the navigation history. 26 * @return Whether we can move in history by given offset 27 */ 28 boolean canGoToOffset(int offset); 29 30 /** 31 * Navigates to the specified offset from the "current entry". Does nothing if the offset is 32 * out of bounds. 33 * @param offset The offset into the navigation history. 34 */ 35 void goToOffset(int offset); 36 37 /** 38 * Navigates to the specified index in the navigation entry for this page. 39 * @param index The navigation index to navigate to. 40 */ 41 void goToNavigationIndex(int index); 42 43 /** 44 * Goes to the navigation entry before the current one. 45 */ 46 void goBack(); 47 48 /** 49 * Goes to the navigation entry following the current one. 50 */ 51 void goForward(); 52 53 /** 54 * Loads the current navigation if there is a pending lazy load (after tab restore). 55 */ 56 public void loadIfNecessary(); 57 58 /** 59 * Requests the current navigation to be loaded upon the next call to loadIfNecessary(). 60 */ 61 public void requestRestoreLoad(); 62 63 /** 64 * Reload the current page. 65 */ 66 public void reload(boolean checkForRepost); 67 68 /** 69 * Reload the current page, ignoring the contents of the cache. 70 */ 71 public void reloadIgnoringCache(boolean checkForRepost); 72 73 /** 74 * Cancel the pending reload. 75 */ 76 public void cancelPendingReload(); 77 78 /** 79 * Continue the pending reload. 80 */ 81 public void continuePendingReload(); 82 83 /** 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. 88 */ 89 public void loadUrl(LoadUrlParams params); 90 91 /** 92 * Clears NavigationController's page history in both backwards and 93 * forwards directions. 94 */ 95 @VisibleForTesting 96 public void clearHistory(); 97 98 /** 99 * Get a copy of the navigation history of NavigationController. 100 * @return navigation history of NavigationController. 101 */ 102 public NavigationHistory getNavigationHistory(); 103 104 /** 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 109 * diection. 110 * @return navigation history by keeping above constraints. 111 */ 112 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit); 113 114 /** 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 117 * current entry. 118 */ 119 public String getOriginalUrlForVisibleNavigationEntry(); 120 121 /** 122 * Clears SSL preferences for this NavigationController. 123 */ 124 public void clearSslPreferences(); 125 126 /** 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. 129 */ 130 public boolean getUseDesktopUserAgent(); 131 132 /** 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. 136 */ 137 public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange); 138 139 /** 140 * @return The pending {@link NavigationEntry} for this controller or {@code null} if none 141 * exists. 142 */ 143 public NavigationEntry getPendingEntry(); 144} 145