Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/Tab.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java |
| index c48ba357ee14a3315c78c1992b0d229fc44ec15d..12b70df9e007868e16aab943e00ca9e4042133fa 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java |
| @@ -13,7 +13,6 @@ import android.view.View; |
| import org.chromium.base.CalledByNative; |
| import org.chromium.base.ObserverList; |
| -import org.chromium.base.TraceEvent; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.banners.AppBannerManager; |
| @@ -31,9 +30,10 @@ import org.chromium.chrome.browser.toolbar.ToolbarModel; |
| import org.chromium.content.browser.ContentView; |
| import org.chromium.content.browser.ContentViewClient; |
| import org.chromium.content.browser.ContentViewCore; |
| -import org.chromium.content.browser.NavigationClient; |
| import org.chromium.content.browser.WebContentsObserver; |
| import org.chromium.content_public.browser.LoadUrlParams; |
| +import org.chromium.content_public.browser.NavigationController; |
| +import org.chromium.content_public.browser.NavigationEntry; |
| import org.chromium.content_public.browser.NavigationHistory; |
| import org.chromium.content_public.browser.WebContents; |
| import org.chromium.ui.base.Clipboard; |
| @@ -72,7 +72,7 @@ import java.util.concurrent.atomic.AtomicInteger; |
| * unless special care is taken to make sure {@link Tab#incrementIdCounterTo(int)} is called with |
| * the correct value across all affected {@link Activity}s. |
| */ |
| -public class Tab implements NavigationClient { |
| +public class Tab implements NavigationController { |
|
Ted C
2014/10/22 17:41:33
We shouldn't be doing this.
Some of these methods
Yaron
2014/10/22 17:54:04
Ya, I definitely agree with Ted here
AKVT
2014/10/23 13:34:27
Done. Thank you
AKVT
2014/10/23 13:34:27
Done. Thank you
|
| public static final int INVALID_TAB_ID = -1; |
| /** Used for automatically generating tab ids. */ |
| @@ -383,6 +383,7 @@ public class Tab implements NavigationClient { |
| /** |
| * @return Whether or not this tab has a previous navigation entry. |
| */ |
| + @Override |
| public boolean canGoBack() { |
| return getWebContents() != null && getWebContents().getNavigationController().canGoBack(); |
| } |
| @@ -390,6 +391,7 @@ public class Tab implements NavigationClient { |
| /** |
| * @return Whether or not this tab has a navigation entry after the current one. |
| */ |
| + @Override |
| public boolean canGoForward() { |
| return getWebContents() != null && getWebContents().getNavigationController() |
| .canGoForward(); |
| @@ -398,6 +400,7 @@ public class Tab implements NavigationClient { |
| /** |
| * Goes to the navigation entry before the current one. |
| */ |
| + @Override |
| public void goBack() { |
| if (getWebContents() != null) getWebContents().getNavigationController().goBack(); |
| } |
| @@ -405,6 +408,7 @@ public class Tab implements NavigationClient { |
| /** |
| * Goes to the navigation entry after the current one. |
| */ |
| + @Override |
| public void goForward() { |
| if (getWebContents() != null) getWebContents().getNavigationController().goForward(); |
| } |
| @@ -427,8 +431,19 @@ public class Tab implements NavigationClient { |
| } |
| /** |
| + * @return The pending {@link NavigationEntry} for this tab or {@code null} if none |
| + * exists. |
| + */ |
| + @Override |
| + public NavigationEntry getPendingEntry() { |
| + if (getWebContents() == null) return null; |
| + return getWebContents().getNavigationController().getPendingEntry(); |
| + } |
| + |
| + /** |
| * Loads the current navigation if there is a pending lazy load (after tab restore). |
| */ |
| + @Override |
| public void loadIfNecessary() { |
| if (getWebContents() != null) getWebContents().getNavigationController().loadIfNecessary(); |
| } |
| @@ -436,7 +451,8 @@ public class Tab implements NavigationClient { |
| /** |
| * Requests the current navigation to be loaded upon the next call to loadIfNecessary(). |
| */ |
| - protected void requestRestoreLoad() { |
| + @Override |
| + public void requestRestoreLoad() { |
| if (getWebContents() != null) { |
| getWebContents().getNavigationController().requestRestoreLoad(); |
| } |
| @@ -447,33 +463,93 @@ public class Tab implements NavigationClient { |
| * @param params parameters describing the url load. Note that it is important to set correct |
| * page transition as it is used for ranking URLs in the history so the omnibox |
| * can report suggestions correctly. |
| - * @return FULL_PRERENDERED_PAGE_LOAD or PARTIAL_PRERENDERED_PAGE_LOAD if the page has been |
| - * prerendered. DEFAULT_PAGE_LOAD if it had not. |
| - */ |
| - public int loadUrl(LoadUrlParams params) { |
| - TraceEvent.begin(); |
| - |
| - // We load the URL from the tab rather than directly from the ContentView so the tab has a |
| - // chance of using a prerenderer page is any. |
| - int loadType = nativeLoadUrl( |
| - mNativeTabAndroid, |
| - params.getUrl(), |
| - params.getVerbatimHeaders(), |
| - params.getPostData(), |
| - params.getTransitionType(), |
| - params.getReferrer() != null ? params.getReferrer().getUrl() : null, |
| - // Policy will be ignored for null referrer url, 0 is just a placeholder. |
| - // TODO(ppi): Should we pass Referrer jobject and add JNI methods to read it from |
| - // the native? |
| - params.getReferrer() != null ? params.getReferrer().getPolicy() : 0, |
| - params.getIsRendererInitiated()); |
| - |
| - TraceEvent.end(); |
| + */ |
| + @Override |
| + public void loadUrl(LoadUrlParams params) { |
| + if (getWebContents() != null) getWebContents().getNavigationController().loadUrl(params); |
| + } |
| - for (TabObserver observer : mObservers) { |
| - observer.onLoadUrl(this, params.getUrl(), loadType); |
| + /** |
| + * Clears SSL preferences for this Tab. |
| + */ |
| + @Override |
| + public void clearSslPreferences() { |
| + if (getWebContents() != null) { |
| + getWebContents().getNavigationController().clearSslPreferences(); |
| + } |
| + } |
| + |
| + /** |
| + * Get Original URL for current Navigation entry of Tab. |
| + * @return The original request URL for the current navigation entry, or null if there is no |
| + * current entry. |
| + */ |
| + @Override |
| + public String getOriginalUrlForVisibleNavigationEntry() { |
| + if (getWebContents() == null) return null; |
| + return getWebContents().getNavigationController() |
| + .getOriginalUrlForVisibleNavigationEntry(); |
| + } |
| + |
| + /** |
| + * Get a copy of the navigation history of NavigationController. |
| + * @return navigation history of Tab. |
| + */ |
| + @Override |
| + public NavigationHistory getNavigationHistory() { |
| + if (getWebContents() == null) return null; |
| + return getWebContents().getNavigationController().getNavigationHistory(); |
| + } |
| + |
| + /** |
| + * Clears Tab's page history in both backwards and |
| + * forwards directions. |
| + */ |
| + @Override |
| + public void clearHistory() { |
| + if (getWebContents() != null) getWebContents().getNavigationController().clearHistory(); |
| + } |
| + |
| + /** |
| + * Continue the pending reload. |
| + */ |
| + @Override |
| + public void continuePendingReload() { |
| + if (getWebContents() != null) { |
| + getWebContents().getNavigationController().continuePendingReload(); |
| + } |
| + } |
| + |
| + /** |
| + * Cancel the pending reload. |
| + */ |
| + @Override |
| + public void cancelPendingReload() { |
| + if (getWebContents() != null) { |
| + getWebContents().getNavigationController().continuePendingReload(); |
| + } |
| + } |
| + |
| + /** |
| + * @param offset The offset into the navigation history. |
| + * @return Whether we can move in history by given offset |
| + */ |
| + @Override |
| + public boolean canGoToOffset(int offset) { |
| + if (getWebContents() == null) return false; |
| + return getWebContents().getNavigationController().canGoToOffset(offset); |
| + } |
| + |
| + /** |
| + * Navigates to the specified offset from the "current entry". Does nothing if the offset is |
| + * out of bounds. |
| + * @param offset The offset into the navigation history. |
| + */ |
| + @Override |
| + public void goToOffset(int offset) { |
| + if (getWebContents() != null) { |
| + getWebContents().getNavigationController().goToOffset(offset); |
| } |
| - return loadType; |
| } |
| /** |
| @@ -557,18 +633,22 @@ public class Tab implements NavigationClient { |
| /** |
| * Reloads the current page content. |
| */ |
| - public void reload() { |
| + @Override |
| + public void reload(boolean checkForRepost) { |
| // TODO(dtrainor): Should we try to rebuild the ContentView if it's frozen? |
| - if (getWebContents() != null) getWebContents().getNavigationController().reload(true); |
| + if (getWebContents() != null) { |
| + getWebContents().getNavigationController().reload(checkForRepost); |
| + } |
| } |
| /** |
| * Reloads the current page content. |
| * This version ignores the cache and reloads from the network. |
| */ |
| - public void reloadIgnoringCache() { |
| + @Override |
| + public void reloadIgnoringCache(boolean checkForRepost) { |
| if (getWebContents() != null) { |
| - getWebContents().getNavigationController().reloadIgnoringCache(true); |
| + getWebContents().getNavigationController().reloadIgnoringCache(checkForRepost); |
| } |
| } |
| @@ -648,6 +728,7 @@ public class Tab implements NavigationClient { |
| * @param useDesktop If {@code true}, use a desktop user agent. Otherwise use a mobile one. |
| * @param reloadOnChange Reload the page if the user agent has changed. |
| */ |
| + @Override |
| public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChange) { |
| if (getWebContents() != null) { |
| getWebContents().getNavigationController() |
| @@ -658,6 +739,7 @@ public class Tab implements NavigationClient { |
| /** |
| * @return Whether or not the {@link ContentViewCore} is using a desktop user agent. |
| */ |
| + @Override |
| public boolean getUseDesktopUserAgent() { |
| return getWebContents() != null && getWebContents().getNavigationController() |
| .getUseDesktopUserAgent(); |