Commit 9f52f0c2 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Merge FullscreenManager into ChromeFullscreenManager

The distinction between FullscreenManager and ChromeFullscreenManager
got fuzzy over time, and there has not been any other concrete
implementation. This CL merges the two classes into one. This is a
part of the fullscreen manager clean up task that will split the role
of browser controls positioning and HTML5 fullscreen API processing.

Bug: 966272
Change-Id: Ie5cf76d6f1caf14b02b390bf6d3b40f52fe4183b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217679
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774561}
parent 7d9ed458
......@@ -738,7 +738,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/fullscreen/BrowserStateBrowserControlsVisibilityDelegate.java",
"java/src/org/chromium/chrome/browser/fullscreen/ChromeFullscreenManager.java",
"java/src/org/chromium/chrome/browser/fullscreen/FullscreenHtmlApiHandler.java",
"java/src/org/chromium/chrome/browser/fullscreen/FullscreenManager.java",
"java/src/org/chromium/chrome/browser/fullscreen/FullscreenOptions.java",
"java/src/org/chromium/chrome/browser/fullscreen/TabGestureStateListener.java",
"java/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClient.java",
......
......@@ -30,7 +30,6 @@ import org.chromium.chrome.browser.document.ChromeIntentUtil;
import org.chromium.chrome.browser.document.DocumentWebContentsDelegate;
import org.chromium.chrome.browser.fullscreen.BrowserControlsStateProvider;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.fullscreen.FullscreenManager;
import org.chromium.chrome.browser.fullscreen.FullscreenOptions;
import org.chromium.chrome.browser.media.PictureInPicture;
import org.chromium.chrome.browser.policy.PolicyAuditor;
......@@ -127,7 +126,7 @@ public class ActivityTabWebContentsDelegateAndroid extends TabWebContentsDelegat
@Override
public boolean isFullscreenForTabOrPending() {
FullscreenManager manager = getFullscreenManager();
ChromeFullscreenManager manager = getFullscreenManager();
return manager != null ? manager.getPersistentFullscreenMode() : false;
}
......
......@@ -25,7 +25,7 @@ import org.chromium.chrome.browser.compositor.overlays.SceneOverlay;
import org.chromium.chrome.browser.compositor.overlays.strip.StripLayoutHelperManager;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchManagementDelegate;
import org.chromium.chrome.browser.device.DeviceClassManager;
import org.chromium.chrome.browser.fullscreen.FullscreenManager;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabCreatorManager;
......@@ -524,7 +524,7 @@ public class LayoutManagerChrome
@Override
public boolean isSwipeEnabled(@ScrollDirection int direction) {
FullscreenManager manager = mHost.getFullscreenManager();
ChromeFullscreenManager manager = mHost.getFullscreenManager();
if (getActiveLayout() != mStaticLayout
|| !DeviceClassManager.enableToolbarSwipe()
|| (manager != null && manager.getPersistentFullscreenMode())) {
......
......@@ -33,7 +33,6 @@ import org.chromium.chrome.browser.customtabs.content.CustomTabActivityTabContro
import org.chromium.chrome.browser.customtabs.content.CustomTabActivityTabProvider;
import org.chromium.chrome.browser.dependency_injection.ActivityScope;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.fullscreen.FullscreenManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.toolbar.ToolbarManager;
import org.chromium.content_public.common.BrowserControlsState;
......@@ -46,7 +45,7 @@ import dagger.Lazy;
/**
* Works with the toolbar in a Custom Tab. Encapsulates interactions with Chrome's toolbar-related
* classes such as {@link ToolbarManager} and {@link FullscreenManager}.
* classes such as {@link ToolbarManager} and {@link ChromeFullscreenManager}.
*
* TODO(pshmakov):
* 1. Reduce the coupling between Custom Tab toolbar and Chrome's common code. In particular,
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.fullscreen;
import android.view.View;
import android.view.Window;
import androidx.annotation.Nullable;
import org.chromium.chrome.browser.fullscreen.FullscreenHtmlApiHandler.FullscreenHtmlApiDelegate;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.content_public.browser.GestureListenerManager;
import org.chromium.content_public.browser.WebContents;
/**
* Manages the basic fullscreen functionality required by a Tab.
*/
// TODO(tedchoc): Remove Tab's requirement on the fullscreen tokens to slim down the API of this
// class.
public abstract class FullscreenManager {
private final FullscreenHtmlApiHandler mHtmlApiHandler;
@Nullable private Tab mTab;
/**
* Constructs the basic ChromeTab oriented FullscreenManager.
*
* @param window Top-level window to turn to fullscreen.
*/
public FullscreenManager(Window window) {
mHtmlApiHandler = new FullscreenHtmlApiHandler(window, createApiDelegate());
}
/**
* @return The delegate that will handle the embedder specific requirements of the
* fullscreen API handler.
*/
protected abstract FullscreenHtmlApiDelegate createApiDelegate();
/**
* @return The handler for managing interactions with the HTML fullscreen API.
*/
protected FullscreenHtmlApiHandler getHtmlApiHandler() {
return mHtmlApiHandler;
}
/**
* Updates the positions of the browser controls and content to the default non fullscreen
* values.
*/
public abstract void setPositionsForTabToNonFullscreen();
/**
* Updates the positions of the browser controls and content based on the desired position of
* the current tab.
* @param topControlsOffset The Y offset of the top controls in px.
* @param bottomControlsOffset The Y offset of the bottom controls in px.
* @param topContentOffset The Y offset for the content in px.
* @param topControlsMinHeightOffset The Y offset for the top controls min-height in px.
* @param bottomControlsMinHeightOffset The Y offset for the bottom controls min-height in px.
*/
public abstract void setPositionsForTab(int topControlsOffset, int bottomControlsOffset,
int topContentOffset, int topControlsMinHeightOffset,
int bottomControlsMinHeightOffset);
/**
* Updates the current ContentView's children and any popups with the correct offsets based on
* the current fullscreen state.
*/
public abstract void updateContentViewChildrenState();
/**
* Sets the currently selected tab for fullscreen.
*/
public void setTab(@Nullable Tab tab) {
if (mTab == tab) return;
mTab = tab;
}
/**
* @return The currently selected tab for fullscreen.
*/
@Nullable public Tab getTab() {
return mTab;
}
/**
* Enters persistent fullscreen mode. In this mode, the browser controls will be
* permanently hidden until this mode is exited.
*/
protected void enterPersistentFullscreenMode(FullscreenOptions options) {
mHtmlApiHandler.enterPersistentFullscreenMode(options);
updateMultiTouchZoomSupport(false);
}
/**
* Exits persistent fullscreen mode. In this mode, the browser controls will be
* permanently hidden until this mode is exited.
*/
public void exitPersistentFullscreenMode() {
mHtmlApiHandler.exitPersistentFullscreenMode();
updateMultiTouchZoomSupport(true);
}
/**
* @see GestureListenerManager#updateMultiTouchZoomSupport(boolean).
*/
protected void updateMultiTouchZoomSupport(boolean enable) {
Tab tab = getTab();
if (tab == null || tab.isHidden()) return;
WebContents webContents = tab.getWebContents();
if (webContents != null) {
GestureListenerManager manager = GestureListenerManager.fromWebContents(webContents);
if (manager != null) manager.updateMultiTouchZoomSupport(enable);
}
}
/**
* @return Whether the application is in persistent fullscreen mode.
* @see #setPersistentFullscreenMode(boolean)
*/
public boolean getPersistentFullscreenMode() {
return mHtmlApiHandler.getPersistentFullscreenMode();
}
/**
* Notified when the system UI visibility for the current ContentView has changed.
* @param visibility The updated UI visibility.
* @see View#getSystemUiVisibility()
*/
public void onContentViewSystemUiVisibilityChange(int visibility) {
mHtmlApiHandler.onContentViewSystemUiVisibilityChange(visibility);
}
/**
* Ensure the proper system UI flags are set after the window regains focus.
* @see android.app.Activity#onWindowFocusChanged(boolean)
*/
public void onWindowFocusChanged(boolean hasWindowFocus) {
mHtmlApiHandler.onWindowFocusChanged(hasWindowFocus);
}
/**
* Called when scrolling state of the ContentView changed.
*/
public void onContentViewScrollingStateChanged(boolean scrolling) {}
/**
* Destroys the FullscreenManager
*/
public void destroy() {
setTab(null);
}
}
......@@ -21,7 +21,7 @@ public final class TabGestureStateListener extends TabWebContentsUserData {
private final Tab mTab;
private GestureStateListener mGestureListener;
private FullscreenManager mFullscreenManager;
private ChromeFullscreenManager mFullscreenManager;
/**
* Creates TabGestureStateListener and lets the WebContentsUserData of the Tab manage it.
......@@ -45,7 +45,7 @@ public final class TabGestureStateListener extends TabWebContentsUserData {
* Set {@link FullscreenManager} instance. This is non-null for active tab.
* @param manager FullscreenManager instance.
*/
void setFullscreenManager(FullscreenManager manager) {
void setFullscreenManager(ChromeFullscreenManager manager) {
mFullscreenManager = manager;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment