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

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

Issue 1374603004: Refactor contextual search's panel host and scene layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extract-contextual-search
Patch Set: rebase Created 5 years, 2 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelHost.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
index f4aa8fe67fe81b2f7856d4a6377ab3af7923d07f..4d5241299278ae75526d69192009768dfb40694a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java
@@ -10,7 +10,10 @@ import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchPanelAnimation;
import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost;
+import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer;
+import org.chromium.chrome.browser.tab.Tab;
import org.chromium.content.browser.ContentViewCore;
+import org.chromium.ui.resources.ResourceManager;
/**
* Controls the Overlay Panel.
@@ -79,6 +82,11 @@ public class OverlayPanel extends ContextualSearchPanelAnimation
*/
private OverlayPanelContent mContent;
+ /**
+ * The {@link OverlayPanelHost} used to communicate with the supported layout.
+ */
+ private OverlayPanelHost mOverlayPanelHost;
+
// ============================================================================================
// Constructor
// ============================================================================================
@@ -122,6 +130,18 @@ public class OverlayPanel extends ContextualSearchPanelAnimation
return doesPanelHeightMatchState(PanelState.EXPANDED);
}
+ @Override
+ public void closePanel(StateChangeReason reason, boolean animate) {
+ super.closePanel(reason, animate);
+
+ // If the close action is animated, the Layout will be hidden when
+ // the animation is finished, so we should only hide the Layout
+ // here when not animating.
+ if (!animate && mOverlayPanelHost != null) {
+ mOverlayPanelHost.hideLayout(true);
+ }
+ }
+
/**
* @param url The URL that the panel should load.
*/
@@ -194,6 +214,22 @@ public class OverlayPanel extends ContextualSearchPanelAnimation
}
/**
+ * Updates the top controls state for the base tab. As these values are set at the renderer
+ * level, there is potential for this impacting other tabs that might share the same
+ * process. See {@link Tab#updateTopControlsState(int current, boolean animate)}
+ * @param current The desired current state for the controls. Pass
+ * {@link TopControlsState#BOTH} to preserve the current position.
+ * @param animate Whether the controls should animate to the specified ending condition or
+ * should jump immediately.
+ */
+ public void updateTopControlsState(int current, boolean animate) {
+ Tab currentTab = mActivity.getActivityTab();
+ if (currentTab != null) {
+ currentTab.updateTopControlsState(current, animate);
+ }
+ }
+
+ /**
* Sets the top control state based on the internals of the panel.
*/
public void updateTopControlsState() {
@@ -232,6 +268,32 @@ public class OverlayPanel extends ContextualSearchPanelAnimation
}
// ============================================================================================
+ // Animation Handling
+ // ============================================================================================
+
+ @Override
+ protected void onAnimationFinished() {
+ super.onAnimationFinished();
+
+ if (shouldHideOverlayPanelLayout()) {
+ if (mOverlayPanelHost != null) {
+ mOverlayPanelHost.hideLayout(false);
+ }
+ }
+ }
+
+ /**
+ * Whether the Overlay Panel Layout should be hidden.
+ *
+ * @return Whether the Overlay Panel Layout should be hidden.
+ */
+ private boolean shouldHideOverlayPanelLayout() {
+ final PanelState state = getPanelState();
+ return (state == PanelState.PEEKED || state == PanelState.CLOSED)
+ && getHeight() == getPanelHeightFromState(state);
+ }
+
+ // ============================================================================================
// ContextualSearchPanelBase methods.
// ============================================================================================
@@ -243,6 +305,32 @@ public class OverlayPanel extends ContextualSearchPanelAnimation
}
// ============================================================================================
+ // Layout Integration
+ // ============================================================================================
+
+ /**
+ * Sets the {@OverlayPanelHost} used to communicate with the supported layout.
+ * @param host The {@OverlayPanelHost}.
+ */
+ public void setHost(OverlayPanelHost host) {
+ mOverlayPanelHost = host;
+ }
+
+ /**
+ * @return The scene layer used to draw this panel.
+ */
+ public SceneLayer getSceneLayer() {
+ return null;
+ }
+
+ /**
+ * Update this panel's scene layer. This should be implemented by each panel type.
+ * @param resourceManager Used to access static resources.
+ */
+ public void updateSceneLayer(ResourceManager resourceManager) {
+ }
+
+ // ============================================================================================
// Generic Event Handling
// ============================================================================================
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelHost.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698