/** Create a new OverlayPanelContent object. This can be overridden for tests. */ public OverlayPanelContent createNewOverlayPanelContent() { OverlayPanelContent overlayPanelContent = new OverlayPanelContent( mManagementDelegate.getOverlayContentDelegate(), new PanelProgressObserver(), mActivity); // Adds a ContentViewClient to override the default fullscreen size. if (!isFullscreenSizePanel()) { overlayPanelContent.setContentViewClient( new ContentViewClient() { @Override public int getDesiredWidthMeasureSpec() { return MeasureSpec.makeMeasureSpec( getSearchContentViewWidthPx(), MeasureSpec.EXACTLY); } @Override public int getDesiredHeightMeasureSpec() { return MeasureSpec.makeMeasureSpec( getSearchContentViewHeightPx(), MeasureSpec.EXACTLY); } }); } return overlayPanelContent; }
@Override public void updateTopControlState() { if (mOverlayPanelContent == null) return; if (isFullscreenSizePanel()) { // Consider the ContentView height to be fullscreen, and inform the system that // the Toolbar is always visible (from the Compositor's perspective), even though // the Toolbar and Base Page might be offset outside the screen. This means the // renderer will consider the ContentView height to be the fullscreen height // minus the Toolbar height. // // This is necessary to fix the bugs: crbug.com/510205 and crbug.com/510206 mOverlayPanelContent.updateTopControlsState(false, true, false); } else { mOverlayPanelContent.updateTopControlsState(true, false, false); } }
@Override protected void onClose(StateChangeReason reason) { destroySearchBarControl(); destroyPeekPromoControl(); if (mOverlayPanelContent != null) { mOverlayPanelContent.destroyContentView(); } mManagementDelegate.onCloseContextualSearch(reason); }
/** * Handles the movement of the swipe gesture. * * @param ty The movement's total displacement in dps. */ public void handleSwipeMove(float ty) { if (ty > 0 && getPanelState() == PanelState.MAXIMIZED) { // Resets the Search Content View scroll position when swiping the Panel down // after being maximized. mOverlayPanelContent.resetContentViewScroll(); } // Negative ty value means an upward movement so subtracting ty means expanding the panel. setClampedPanelHeight(mInitialPanelHeight - ty); requestUpdate(); }
/** Destroy the native components associated with this panel's content. */ public void destroy() { // It is possible that an OverlayPanelContent was never created for this panel. if (mOverlayPanelContent != null) { mOverlayPanelContent.destroy(); } }
@Override public void removeLastHistoryEntry(String historyUrl, long urlTimeMs) { if (mOverlayPanelContent == null) return; // Expose OverlayPanelContent method. mOverlayPanelContent.removeLastHistoryEntry(historyUrl, urlTimeMs); }
@Override public ContentViewCore getContentViewCore() { // Expose OverlayPanelContent method. return mOverlayPanelContent != null ? mOverlayPanelContent.getContentViewCore() : null; }
@Override public boolean didLoadAnyUrl() { return mOverlayPanelContent != null && mOverlayPanelContent.didLoadAnyUrl(); }
@Override public boolean isContentViewShowing() { return mOverlayPanelContent != null && mOverlayPanelContent.isContentViewShowing(); }
/** @return The vertical scroll position of the content. */ public float getSearchContentViewVerticalScroll() { return mOverlayPanelContent.getContentViewVerticalScroll(); }