OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 | |
5 package org.chromium.chrome.browser.navigation; | |
6 | |
7 import android.support.annotation.VisibleForTesting; | |
8 | |
9 import org.chromium.content_public.browser.LoadUrlParams; | |
10 import org.chromium.content_public.browser.NavigationEntry; | |
11 import org.chromium.content_public.browser.NavigationHistory; | |
12 | |
13 /** | |
14 * Responsible for managing back-forward navigation for a tab. This interface en
ables the Chrome | |
15 * layer to interact with different types of navigation controllers from multipl
e sources. | |
16 */ | |
17 public interface NavigationHandler { | |
18 boolean canGoBack(); | |
19 | |
20 /** | |
21 * @return Whether forward navigation is possible from the "current entry". | |
22 */ | |
23 boolean canGoForward(); | |
24 | |
25 /** | |
26 * @param offset The offset into the navigation history. | |
27 * @return Whether we can move in history by given offset | |
28 */ | |
29 boolean canGoToOffset(int offset); | |
30 | |
31 /** | |
32 * Navigates to the specified offset from the "current entry". Does nothing
if the offset is | |
33 * out of bounds. | |
34 * @param offset The offset into the navigation history. | |
35 */ | |
36 void goToOffset(int offset); | |
37 | |
38 /** | |
39 * Navigates to the specified index in the navigation entry for this page. | |
40 * @param index The navigation index to navigate to. | |
41 */ | |
42 void goToNavigationIndex(int index); | |
43 | |
44 /** | |
45 * Goes to the navigation entry before the current one. | |
46 */ | |
47 void goBack(); | |
48 | |
49 /** | |
50 * Goes to the navigation entry following the current one. | |
51 */ | |
52 void goForward(); | |
53 | |
54 /** | |
55 * @return Whether the tab is navigating to the URL the tab is opened with. | |
56 */ | |
57 boolean isInitialNavigation(); | |
58 | |
59 /** | |
60 * Loads the current navigation if there is a pending lazy load (after tab r
estore). | |
61 */ | |
62 public void loadIfNecessary(); | |
63 | |
64 /** | |
65 * Requests the current navigation to be loaded upon the next call to loadIf
Necessary(). | |
66 */ | |
67 public void requestRestoreLoad(); | |
68 | |
69 /** | |
70 * Reload the current page. | |
71 */ | |
72 public void reload(boolean checkForRepost); | |
73 | |
74 /** | |
75 * Reload the current page to refresh page contents, may not revalidate the
cache contents. | |
76 */ | |
77 public void reloadToRefreshContent(boolean checkForRepost); | |
78 | |
79 /** | |
80 * Reload the current page, bypassing the contents of the cache. | |
81 */ | |
82 public void reloadBypassingCache(boolean checkForRepost); | |
83 | |
84 /** | |
85 * Reload the current page with Lo-Fi off, ignoring the contents of the cach
e. | |
86 */ | |
87 public void reloadDisableLoFi(boolean checkForRepost); | |
88 | |
89 /** | |
90 * Cancel the pending reload. | |
91 */ | |
92 public void cancelPendingReload(); | |
93 | |
94 /** | |
95 * Continue the pending reload. | |
96 */ | |
97 public void continuePendingReload(); | |
98 | |
99 /** | |
100 * Load url without fixing up the url string. Consumers of NavigationControl
ler are | |
101 * responsible for ensuring the URL passed in is properly formatted (i.e. th
e | |
102 * scheme has been added if left off during user input). | |
103 * @param params Parameters for this load. | |
104 */ | |
105 public void loadUrl(LoadUrlParams params); | |
106 | |
107 /** | |
108 * Get the navigation history of NavigationController from current navigation
entry index | |
109 * with direction (forward/backward) | |
110 * @param isForward determines forward or backward from current index | |
111 * @param itemLimit maximum number of entries to be retrieved in specified | |
112 * diection. | |
113 * @return navigation history by keeping above constraints. | |
114 */ | |
115 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int
itemLimit); | |
116 | |
117 /** | |
118 * Get Original URL for current Navigation entry of NavigationController. | |
119 * @return The original request URL for the current navigation entry, or nul
l if there is no | |
120 * current entry. | |
121 */ | |
122 public String getOriginalUrlForVisibleNavigationEntry(); | |
123 | |
124 /** | |
125 * Clears SSL preferences for this NavigationController. | |
126 */ | |
127 public void clearSslPreferences(); | |
128 | |
129 /** | |
130 * Get whether or not we're using a desktop user agent for the currently loa
ded page. | |
131 * @return true, if use a desktop user agent and false for a mobile one. | |
132 */ | |
133 public boolean getUseDesktopUserAgent(); | |
134 | |
135 /** | |
136 * Set whether or not we're using a desktop user agent for the currently loa
ded page. | |
137 * @param override If true, use a desktop user agent. Use a mobile one othe
rwise. | |
138 * @param reloadOnChange Reload the page if the UA has changed. | |
139 */ | |
140 public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange)
; | |
141 | |
142 /** | |
143 * Return the NavigationEntry at the given index. | |
144 * @param index Index to retrieve the NavigationEntry for. | |
145 * @return Entry containing info about the navigation, null if the index is
out of bounds. | |
146 */ | |
147 @VisibleForTesting | |
148 public NavigationEntry getEntryAtIndex(int index); | |
149 | |
150 /** | |
151 * @return The index of the last committed entry. | |
152 */ | |
153 public int getLastCommittedEntryIndex(); | |
154 | |
155 /** | |
156 * Removes the entry at the specified |index|. | |
157 * @return false, if the index is the last committed index or the pending en
try. Otherwise this | |
158 * call discards any transient or pending entries. | |
159 */ | |
160 public boolean removeEntryAtIndex(int index); | |
161 } | |
OLD | NEW |