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 c519959ad2457e0b68058243cf77f7f26be48a88..631f21a454f0076fc1b93cdc606f960e109a71ed 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 |
@@ -314,7 +314,7 @@ public class OverlayPanel extends ContextualSearchPanelAnimation |
*/ |
private OverlayPanelContent createNewOverlayPanelContentInternal() { |
OverlayPanelContent content = mContentFactory.createNewOverlayPanelContent(); |
- // Adds a ContentViewClient to override the default fullscreen size. |
+ |
content.setContentViewClient(new ContentViewClient() { |
@Override |
public int getDesiredWidthMeasureSpec() { |
@@ -338,6 +338,7 @@ public class OverlayPanel extends ContextualSearchPanelAnimation |
} |
} |
}); |
+ |
return content; |
} |
@@ -490,6 +491,32 @@ public class OverlayPanel extends ContextualSearchPanelAnimation |
return true; |
} |
+ /** |
+ * Handles the device orientation change. |
+ */ |
+ public void onOrientationChanged() { |
+ if (isNarrowSizePanelSupported()) { |
+ // TODO(pedrosimonetti): We cannot preserve the panel when rotating from/to a |
+ // narrow version of the Panel because the Content is resized before the Panel |
+ // gets a notification of the resize. |
+ closePanel(StateChangeReason.UNKNOWN, false); |
+ } else { |
+ updatePanelForOrientationChange(); |
+ } |
+ } |
+ |
+ /** |
+ * Updates the Panel so it preserves its state when the orientation changes. |
+ */ |
+ protected void updatePanelForOrientationChange() { |
+ // NOTE(pedrosimonetti): We cannot tell where the selection will be after the |
+ // orientation change, so we are setting the selection position to zero, which |
+ // means the base page will be positioned in its original state and we won't |
+ // try to keep the selection in view. |
+ updateBasePageSelectionYPx(0.f); |
+ resizePanelToState(getPanelState(), StateChangeReason.UNKNOWN); |
+ } |
+ |
// ============================================================================================ |
// Generic Event Handling |
// ============================================================================================ |