Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1199)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 2233023002: Adding BlimpNavigationController to Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nav_handler_remove
Patch Set: @nyquist feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
index 9a19635f6b5200dd89e1445b187604bcef6eba5f..ef448c77fbdfa4bcd96f479bb547e81be8d401ff 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -39,6 +39,7 @@ import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
+import org.chromium.blimp_public.contents.BlimpContents;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeApplication;
@@ -54,6 +55,7 @@ import org.chromium.chrome.browser.TabState.WebContentsState;
import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.WebContentsFactory;
import org.chromium.chrome.browser.banners.AppBannerManager;
+import org.chromium.chrome.browser.blimp.BlimpClientContextFactory;
import org.chromium.chrome.browser.bookmarks.BookmarkUtils;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator;
@@ -167,6 +169,9 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
/** Whether or not this tab is an incognito tab. */
private final boolean mIncognito;
+ /** Whether or not this tab is running in blimp mode. */
+ private final boolean mBlimp;
+
/**
* An Application {@link Context}. Unlike {@link #mActivity}, this is the only one that is
* publicly exposed to help prevent leaking the {@link Activity}.
@@ -213,6 +218,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
private ContentViewClient mContentViewClient;
private TabWebContentsObserver mWebContentsObserver;
private TabWebContentsDelegateAndroid mWebContentsDelegate;
+ private BlimpContents mBlimpContents;
/**
* If this tab was opened from another tab, store the id of the tab that
@@ -648,6 +654,11 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
mThemeColor = mDefaultThemeColor;
}
+ mBlimp = BlimpClientContextFactory
David Trainor- moved to gerrit 2016/08/18 17:06:30 We should pass this into tab. Some tabs will not
shaktisahu 2016/08/18 19:36:06 Yes, the creator should pass this to tab. But that
+ .getBlimpClientContextForProfile(
+ Profile.getLastUsedProfile().getOriginalProfile())
+ .isBlimpEnabled();
David Trainor- moved to gerrit 2016/08/18 18:28:19 && !mIsIncognito
shaktisahu 2016/08/18 19:36:06 Done.
+
// Restore data from the TabState, if it existed.
if (frozenState != null) {
assert type == TabLaunchType.FROM_RESTORE;
@@ -734,29 +745,50 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
* @return Whether or not this tab has a previous navigation entry.
*/
public boolean canGoBack() {
- return getWebContents() != null && getWebContents().getNavigationController().canGoBack();
+ if (isBlimpTab()) {
+ return getBlimpContents() != null
+ && getBlimpContents().getNavigationController().canGoBack();
+ } else {
+ return getWebContents() != null
+ && getWebContents().getNavigationController().canGoBack();
+ }
}
/**
* @return Whether or not this tab has a navigation entry after the current one.
*/
public boolean canGoForward() {
- return getWebContents() != null && getWebContents().getNavigationController()
- .canGoForward();
+ if (isBlimpTab()) {
+ return getBlimpContents() != null
+ && getBlimpContents().getNavigationController().canGoForward();
+ } else {
+ return getWebContents() != null
+ && getWebContents().getNavigationController().canGoForward();
+ }
}
/**
* Goes to the navigation entry before the current one.
*/
public void goBack() {
- if (getWebContents() != null) getWebContents().getNavigationController().goBack();
+ if (isBlimpTab()) {
+ if (getBlimpContents() != null) getBlimpContents().getNavigationController().goBack();
+ } else {
+ if (getWebContents() != null) getWebContents().getNavigationController().goBack();
+ }
}
/**
* Goes to the navigation entry after the current one.
*/
public void goForward() {
- if (getWebContents() != null) getWebContents().getNavigationController().goForward();
+ if (isBlimpTab()) {
+ if (getBlimpContents() != null) {
+ getBlimpContents().getNavigationController().goForward();
+ }
+ } else {
+ if (getWebContents() != null) getWebContents().getNavigationController().goForward();
+ }
}
/**
@@ -991,7 +1023,13 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
*/
public void reload() {
// TODO(dtrainor): Should we try to rebuild the ContentView if it's frozen?
- if (getWebContents() != null) getWebContents().getNavigationController().reload(true);
+ if (isBlimpTab()) {
+ if (getBlimpContents() != null) {
+ getBlimpContents().getNavigationController().reload();
+ }
+ } else {
+ if (getWebContents() != null) getWebContents().getNavigationController().reload(true);
+ }
}
/**
@@ -1132,6 +1170,20 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
+ * @return The {@link BlimpContents} associated with this tab, if in blimp mode.
+ */
+ public BlimpContents getBlimpContents() {
+ return mBlimpContents;
+ }
+
+ /**
+ * @return Whether or not this tab is running in blimp mode.
+ */
+ public boolean isBlimpTab() {
+ return mBlimp;
+ }
+
+ /**
* @return The profile associated with this tab.
*/
public Profile getProfile() {
@@ -1152,6 +1204,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
/**
* @return Whether or not this tab is incognito.
*/
+ @CalledByNative
public boolean isIncognito() {
return mIncognito;
}
@@ -1188,8 +1241,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
*/
public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChange) {
if (getWebContents() != null) {
- getWebContents().getNavigationController()
- .setUseDesktopUserAgent(useDesktop, reloadOnChange);
+ getWebContents().getNavigationController().setUseDesktopUserAgent(
+ useDesktop, reloadOnChange);
}
}
@@ -1197,8 +1250,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
* @return Whether or not the {@link ContentViewCore} is using a desktop user agent.
*/
public boolean getUseDesktopUserAgent() {
- return getWebContents() != null && getWebContents().getNavigationController()
- .getUseDesktopUserAgent();
+ return getWebContents() != null
+ && getWebContents().getNavigationController().getUseDesktopUserAgent();
}
/**
@@ -1450,6 +1503,12 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
return;
}
+ if (isBlimpTab() && getBlimpContents() == null) {
+ nativeInitBlimpContents(mNativeTabAndroid);
David Trainor- moved to gerrit 2016/08/18 17:06:30 Can we just return the BlimpContents from this?
shaktisahu 2016/08/18 19:36:06 Done. Removing the nativeGetBlimpContents method.
+ mBlimpContents = nativeGetBlimpContents(mNativeTabAndroid);
+ getBlimpContents().addObserver(new TabBlimpContentsObserver(this));
+ }
+
boolean creatingWebContents = webContents == null;
if (creatingWebContents) {
webContents = WebContentsFactory.createWebContents(isIncognito(), initiallyHidden);
@@ -2016,6 +2075,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
destroyNativePageInternal(currentNativePage);
destroyContentViewCore(true);
+ mBlimpContents = null;
David Trainor- moved to gerrit 2016/08/18 17:06:30 Who destroys this? When do we drop the native poi
shaktisahu 2016/08/18 19:36:06 The native pointer is a unique_ptr owned by TabAnd
David Trainor- moved to gerrit 2016/08/22 21:30:00 Can you add a comment to that effect? Thanks!
+
// Destroys the native tab after destroying the ContentView but before destroying the
// InfoBarContainer. The native tab should be destroyed before the infobar container as
// destroying the native tab cleanups up any remaining infobars. The infobar container
@@ -2050,6 +2111,10 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
public String getUrl() {
String url = getWebContents() != null ? getWebContents().getUrl() : "";
+ if (isBlimpTab() && getBlimpContents() != null) {
+ url = getBlimpContents().getNavigationController().getUrl();
+ }
+
// If we have a ContentView, or a NativePage, or the url is not empty, we have a WebContents
// so cache the WebContent's url. If not use the cached version.
if (getContentViewCore() != null || getNativePage() != null || !TextUtils.isEmpty(url)) {
@@ -2076,6 +2141,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
String title = "";
if (mNativePage != null) {
title = mNativePage.getTitle();
+ } else if (getBlimpContents() != null) {
+ title = getBlimpContents().getNavigationController().getTitle();
} else if (getWebContents() != null) {
title = getWebContents().getTitle();
}
@@ -3251,6 +3318,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
private native void nativeInitWebContents(long nativeTabAndroid, boolean incognito,
WebContents webContents, TabWebContentsDelegateAndroid delegate,
ContextMenuPopulator contextMenuPopulator);
+ private native void nativeInitBlimpContents(long nativeTabAndroid);
David Trainor- moved to gerrit 2016/08/18 18:28:19 Make this take a profile? Profile profile = Profi
+ private native BlimpContents nativeGetBlimpContents(long nativeTabAndroid);
private native void nativeUpdateDelegates(long nativeTabAndroid,
TabWebContentsDelegateAndroid delegate, ContextMenuPopulator contextMenuPopulator);
private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative);

Powered by Google App Engine
This is Rietveld 408576698