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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java

Issue 2536223003: Refactor ContentViewClient (3/6) (Closed)
Patch Set: addressed comments Created 4 years 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/compositor/bottombar/OverlayPanelContent.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java
index e897886fd04ea083bf522c2693913b24fbdeaa85..495585ea89a130bcbaaa1a58db8e26f85530c6de 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContent.java
@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.compositor.bottombar;
import android.text.TextUtils;
import android.view.View;
+import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import org.chromium.base.VisibleForTesting;
@@ -21,7 +22,6 @@ import org.chromium.components.navigation_interception.NavigationParams;
import org.chromium.components.web_contents_delegate_android.WebContentsDelegateAndroid;
import org.chromium.content.browser.ContentVideoViewEmbedder;
import org.chromium.content.browser.ContentView;
-import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.WebContents;
@@ -72,9 +72,6 @@ public class OverlayPanelContent {
/** Whether the content view is currently being displayed. */
private boolean mIsContentViewShowing;
- /** The ContentViewCore responsible for displaying content. */
- private ContentViewClient mContentViewClient;
-
/** The observer used by this object to inform implementers of different events. */
private OverlayContentDelegate mContentDelegate;
@@ -88,6 +85,10 @@ public class OverlayPanelContent {
// java layer. Otherwise, the instance could be garbage-collected unexpectedly.
private InterceptNavigationDelegate mInterceptNavigationDelegate;
+ /** The desired size of the {@link ContentView} associated with this panel content. */
+ private int mContentViewWidth;
+ private int mContentViewHeight;
+
// ============================================================================================
// InterceptNavigationDelegateImpl
// ============================================================================================
@@ -199,6 +200,17 @@ public class OverlayPanelContent {
}
/**
+ * Set the desired size of the underlying {@link ContentView}. This is determined
+ * by the {@link OverlayPanel} before the creation of the content view.
+ * @param width The width of the content view.
+ * @param height The height of the content view.
+ */
+ void setContentViewSize(int width, int height) {
+ mContentViewWidth = width;
+ mContentViewHeight = height;
+ }
+
+ /**
* Makes the content visible, causing it to be rendered.
*/
public void showContent() {
@@ -228,13 +240,15 @@ public class OverlayPanelContent {
mContentViewCore = createContentViewCore(mActivity);
- if (mContentViewClient == null) {
- mContentViewClient = new ContentViewClient();
- }
-
- mContentViewCore.setContentViewClient(mContentViewClient);
-
ContentView cv = ContentView.createContentView(mActivity, mContentViewCore);
+ if (mContentViewWidth != 0 || mContentViewHeight != 0) {
+ int width = mContentViewWidth == 0 ? ContentView.DEFAULT_MEASURE_SPEC
+ : MeasureSpec.makeMeasureSpec(mContentViewWidth, MeasureSpec.EXACTLY);
+ int height = mContentViewHeight == 0 ? ContentView.DEFAULT_MEASURE_SPEC
+ : MeasureSpec.makeMeasureSpec(mContentViewHeight, MeasureSpec.EXACTLY);
+ cv.setDesiredMeasureSpec(width, height);
+ mActivity.getCompositorViewHolder().setDesiredMeasureSpec(width, height);
+ }
// Creates an initially hidden WebContents which gets shown when the panel is opened.
WebContents panelWebContents = WebContentsFactory.createWebContents(false, true);
@@ -427,17 +441,6 @@ public class OverlayPanelContent {
}
/**
- * Set a ContentViewClient for this panel to use (will be reused for each new ContentViewCore).
- * @param viewClient The ContentViewClient to use.
- */
- public void setContentViewClient(ContentViewClient viewClient) {
- mContentViewClient = viewClient;
- if (mContentViewCore != null) {
- mContentViewCore.setContentViewClient(mContentViewClient);
- }
- }
-
- /**
* @return true if the ContentViewCore is visible on the page.
*/
public boolean isContentShowing() {

Powered by Google App Engine
This is Rietveld 408576698