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

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: Renaming is apparently difficult for me... 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 a6f9c7a7afd595472f13fe902213a9604e35a933..bd74b41a978d78c17ec99ff4d78442f6a0e7ff8a 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,14 +1255,79 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
/**
* Perform any subclass-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();
}
/**
+ * 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);
Ted C 2015/02/06 01:52:39 should we be adding this if we're currently showin
David Trainor- moved to gerrit 2015/02/06 18:37:04 Good point, we probably shouldn't. I'll take anot
+ 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) {
+ 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) {
+ for (TabObserver observer : mObservers) {
+ observer.onOverlayContentViewCoreRemoved(this, content);
+ }
+ mOverlayContentViewCores.remove(content);
Ted C 2015/02/06 01:52:39 should we be asserting the return value is true ju
David Trainor- moved to gerrit 2015/02/06 18:37:04 Sure we can do that. I should probably also null
David Trainor- moved to gerrit 2015/02/06 22:10:24 Ended up just doing an assert mOverlayContentViewC
+ nativeDetachOverlayContentViewCore(mNativeTabAndroid, content);
+ }
+
+ /**
+ * Sets the visibility of the {@link ContentViewCore} overlay object represented by
+ * {@code content}.
+ * @param content The {@link ContentViewCore} to change the visibility of.
+ * @param visible The visibility that {@code content} should have.
+ */
+ public void setOverlayContentViewCoreVisibility(ContentViewCore content, boolean visible) {
+ nativeSetOverlayContentViewCoreVisibility(mNativeTabAndroid, content, visible);
+ }
+
+ /**
* Called when a page has started loading.
* @param validatedUrl URL being loaded.
* @param showingErrorPage Whether an error page is being shown.
@@ -2383,5 +2461,13 @@ 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 native void nativeSetOverlayContentViewCoreVisibility(long nativeTabAndroid,
+ ContentViewCore content, boolean visible);
private static native void nativeRecordStartupToCommitUma();
}

Powered by Google App Engine
This is Rietveld 408576698