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

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

Issue 900443003: Add support for ContentViewCore helpers on Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 10 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.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 87803beeb4bae37b5174e0006768c03738c44dd3..1a8509ea7b945d946d4577cfe6946421ecd5171d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
@@ -63,6 +63,8 @@ import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.gfx.DeviceDisplayInfo;
import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -152,6 +154,12 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
/** A list of Tab observers. These are used to broadcast Tab events to listeners. */
private final ObserverList<TabObserver> mObservers = new ObserverList<TabObserver>();
+ /**
+ * A list of {@link ContentViewCore} overlay objects that are managed by external components but
+ * need to be sized and rendered along side this {@link Tab}s content.
+ */
+ private final List<ContentViewCore> mOverlayContentViewCores = new ArrayList<ContentViewCore>();
+
// Content layer Observers and Delegates
private ContentViewClient mContentViewClient;
private WebContentsObserver mWebContentsObserver;
@@ -1204,12 +1212,17 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
* whether or not the newly created {@link WebContents} will be hidden
* or not.
*/
- public void initialize(WebContents webContents, TabContentManager tabContentManager,
+ public final void initialize(WebContents webContents, TabContentManager tabContentManager,
boolean initiallyHidden) {
try {
TraceEvent.begin("Tab.initialize");
- internalInit(tabContentManager);
+ internalInit();
+
+ // 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.
+ nativeAttachToTabContentManager(mNativeTabAndroid, tabContentManager);
// If there is a frozen WebContents state or a pending lazy load, don't create a new
// WebContents.
@@ -1242,10 +1255,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
/**
* Perform any class-specific initialization tasks.
- * @param tabContentManager A {@link TabContentManager} instance or {@code null} if the web
- * content will be managed/displayed manually.
*/
- protected void internalInit(TabContentManager tabContentManager) {
+ protected void internalInit() {
initializeNative();
if (AppBannerManager.isEnabled()) {
@@ -1255,6 +1266,71 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
+ * Used to get a list of Android {@link View}s that represent both the normal content as well as
+ * overlays.
+ * @param content A {@link List} that will be populated with {@link View}s that represent all of
+ * the content in this {@link Tab}.
+ */
+ public void getAllViews(List<View> content) {
+ content.add(getView());
+ for (int i = 0; i < mOverlayContentViewCores.size(); i++) {
+ content.add(mOverlayContentViewCores.get(i).getContainerView());
+ }
+ }
+
+ /**
+ * Used to get a list of {@link ContentViewCore}s that represent both the normal content as well
+ * as overlays. These are all {@link ContentViewCore}s currently showing or rendering content
+ * for this {@link Tab}.
+ * @param content A {@link List} that will be populated with {@link ContentViewCore}s currently
+ * rendering content related to this {@link Tab}.
+ */
+ public void getAllContentViewCores(List<ContentViewCore> content) {
+ content.add(mContentViewCore);
+ for (int i = 0; i < mOverlayContentViewCores.size(); i++) {
+ content.add(mOverlayContentViewCores.get(i));
+ }
+ }
+
+ /**
+ * Adds a {@link ContentViewCore} to this {@link Tab} as an overlay object. This
+ * {@link ContentViewCore} will be attached to the CC layer hierarchy and have all layout events
+ * propagated to it. This {@link ContentViewCore} can be removed via
+ * {@link #detachOverlayContentViewCore(ContentViewCore)}.
+ * @param content The {@link ContentViewCore} to attach.
+ * @param visible Whether or not to make the content visible.
+ */
+ public void attachOverlayContentViewCore(ContentViewCore content, boolean visible) {
+ if (content == null) return;
+
+ assert !mOverlayContentViewCores.contains(content);
+ mOverlayContentViewCores.add(content);
+ nativeAttachOverlayContentViewCore(mNativeTabAndroid, content, visible);
+ for (TabObserver observer : mObservers) {
+ observer.onOverlayContentViewCoreAdded(this, content);
+ }
+ }
+
+ /**
+ * Removes a {@link ContentViewCore} overlay object from this {@link Tab}. This
+ * {@link ContentViewCore} must have previously been added via
+ * {@link #attachOverlayContentViewCore(ContentViewCore, boolean)}.
+ * @param content The {@link ContentViewCore} to detach.
+ */
+ public void detachOverlayContentViewCore(ContentViewCore content) {
+ if (content == null) return;
+
+ for (TabObserver observer : mObservers) {
+ observer.onOverlayContentViewCoreRemoved(this, content);
+ }
+
+ assert mOverlayContentViewCores.contains(content);
+ mOverlayContentViewCores.remove(content);
+
+ nativeDetachOverlayContentViewCore(mNativeTabAndroid, content);
+ }
+
+ /**
* Called when a page has started loading.
* @param validatedUrl URL being loaded.
* @param showingErrorPage Whether an error page is being shown.
@@ -2391,5 +2467,11 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
private native void nativeSearchByImageInNewTabAsync(long nativeTabAndroid);
private native void nativeSetInterceptNavigationDelegate(long nativeTabAndroid,
InterceptNavigationDelegate delegate);
+ private native void nativeAttachToTabContentManager(long nativeTabAndroid,
+ TabContentManager tabContentManager);
+ private native void nativeAttachOverlayContentViewCore(long nativeTabAndroid,
+ ContentViewCore content, boolean visible);
+ private native void nativeDetachOverlayContentViewCore(long nativeTabAndroid,
+ ContentViewCore content);
private static native void nativeRecordStartupToCommitUma();
}

Powered by Google App Engine
This is Rietveld 408576698