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

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: Fixed javadocs, moved notification to before helper is removed. Created 5 years, 11 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..046e6a387815e5d24cb5bbeb811e158d2ca0cb05 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,11 @@ 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} objects that are managed by external helpers but need to
+ * be sized and rendered along side this {@link Tab}s content.
gone 2015/02/05 00:06:02 alongside, indentation fix
David Trainor- moved to gerrit 2015/02/05 23:37:53 Done.
+ */
+ private final List<ContentViewCore> mHelperContentViewCores = new ArrayList<ContentViewCore>();
+
// Content layer Observers and Delegates
private ContentViewClient mContentViewClient;
private WebContentsObserver mWebContentsObserver;
@@ -1204,12 +1211,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 +1254,76 @@ 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 need to be properly sized based on
+ * the available content area in the screen.
+ * @param content A {@link List} that will be populated with {@link View}s that need to be sized
+ * based on the available content area.
+ */
+ public void getViewsForLayout(List<View> content) {
+ content.add(getView());
+ for (int i = 0; i < mHelperContentViewCores.size(); i++) {
+ content.add(mHelperContentViewCores.get(i).getContainerView());
+ }
+ }
+
+ /**
+ * Used to get a list of {@link ContentViewCore}s that need to be sized based on the screen
+ * space and current draw area. 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 the {@link ContentViewCore}s
+ * currently rendering content related to this {@link Tab}.
+ */
+ public void getContentViewCoresForBackingSizing(List<ContentViewCore> content) {
+ content.add(mContentViewCore);
+ for (int i = 0; i < mHelperContentViewCores.size(); i++) {
+ content.add(mHelperContentViewCores.get(i));
+ }
+ }
+
+ /**
+ * Adds a {@link ContentViewCore} to this {@link Tab} as a helper 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 #detachHelperContent(ContentViewCore)}.
+ * @param content The {@link ContentViewCore} to attach.
+ * @param visible Whether or not to make the content visible.
+ */
+ public void attachHelperContent(ContentViewCore content, boolean visible) {
+ // TODO: Properly size this new ContentViewCore for the first time.
gone 2015/02/05 00:06:02 TODO(dtrainor)?
David Trainor- moved to gerrit 2015/02/05 23:37:53 Ah I actually took care of this with the listener.
+ mHelperContentViewCores.add(content);
+ nativeAttachHelperContent(mNativeTabAndroid, content, visible);
+ for (TabObserver observer : mObservers) observer.onHelperContentAdded(this, content);
+ }
+
+ /**
+ * Removes a {@link ContentViewCore} helper object from this {@link Tab}. This
+ * {@link ContentViewCore} must have previously been added via
+ * {@link #attachHelperContent(ContentViewCore, boolean)}.
+ * @param content The {@link ContentViewCore} to detach.
+ */
+ public void detachHelperContent(ContentViewCore content) {
+ for (TabObserver observer : mObservers) observer.onHelperContentRemoved(this, content);
+ mHelperContentViewCores.remove(content);
+ nativeDetachHelperContent(mNativeTabAndroid, content);
+ }
+
+ /**
+ * Sets the visibility of the {@link ContentViewCore} helper 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 setHelperContentVisibility(ContentViewCore content, boolean visible) {
+ nativeSetHelperContentVisibility(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 +2457,12 @@ 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 nativeAttachHelperContent(long nativeTabAndroid, ContentViewCore content,
+ boolean visible);
+ private native void nativeDetachHelperContent(long nativeTabAndroid, ContentViewCore content);
+ private native void nativeSetHelperContentVisibility(long nativeTabAndroid,
+ ContentViewCore content, boolean visible);
private static native void nativeRecordStartupToCommitUma();
}

Powered by Google App Engine
This is Rietveld 408576698