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 a4dc01af456a0b39a53308ed0484a59aebbae783..28d50b42319aa8e8df2fbcba545c878454c8f8fa 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; |
@@ -55,6 +56,7 @@ import org.chromium.chrome.browser.UrlConstants; |
import org.chromium.chrome.browser.WarmupManager; |
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.compositor.layouts.content.TabContentManager; |
import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; |
@@ -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 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 |
@@ -734,29 +740,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(); |
+ } |
} |
/** |
@@ -990,7 +1017,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); |
+ } |
} |
/** |
@@ -1128,6 +1161,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() { |
@@ -1184,8 +1231,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); |
} |
} |
@@ -1193,8 +1240,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(); |
} |
/** |
@@ -1434,6 +1481,12 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener, |
mTopControlsVisibilityDelegate = |
mDelegateFactory.createTopControlsVisibilityDelegate(this); |
+ mBlimp = BlimpClientContextFactory |
+ .getBlimpClientContextForProfile( |
+ Profile.getLastUsedProfile().getOriginalProfile()) |
+ .isBlimpEnabled() |
+ && !mIncognito; |
+ |
// Attach the TabContentManager if we have one. This will bind this Tab's content layer |
// to this manager. |
// TODO(dtrainor): Remove this and move to a pull model instead of pushing the layer. |
@@ -1446,6 +1499,13 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener, |
return; |
} |
+ if (isBlimpTab() && getBlimpContents() == null) { |
+ Profile profile = Profile.getLastUsedProfile(); |
+ if (mIncognito) profile = profile.getOffTheRecordProfile(); |
+ mBlimpContents = nativeInitBlimpContents(mNativeTabAndroid, profile); |
+ getBlimpContents().addObserver(new TabBlimpContentsObserver(this)); |
+ } |
+ |
boolean creatingWebContents = webContents == null; |
if (creatingWebContents) { |
webContents = WarmupManager.getInstance().takeSpareWebContents( |
@@ -2017,6 +2077,9 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener, |
destroyNativePageInternal(currentNativePage); |
destroyContentViewCore(true); |
+ // Native part of BlimpContents is destroyed on the subsequent call to nativeDestroy. |
+ mBlimpContents = null; |
+ |
// 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 |
@@ -2051,6 +2114,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)) { |
@@ -2077,6 +2144,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(); |
} |
@@ -3242,6 +3311,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener, |
private native void nativeInitWebContents(long nativeTabAndroid, boolean incognito, |
WebContents webContents, TabWebContentsDelegateAndroid delegate, |
ContextMenuPopulator contextMenuPopulator); |
+ private native BlimpContents nativeInitBlimpContents(long nativeTabAndroid, Profile profile); |
private native void nativeUpdateDelegates(long nativeTabAndroid, |
TabWebContentsDelegateAndroid delegate, ContextMenuPopulator contextMenuPopulator); |
private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); |