Commit da4c40db authored by Peter E Conn's avatar Peter E Conn Committed by Commit Bot

🏃 Tidy up chrome/browser/fullscreen.

Remove a few unnecessary members and add @Nullable.

Bug: 740534
Change-Id: Ia51ac1cd79d42d5be725856fcb81d987c1bc2662
Reviewed-on: https://chromium-review.googlesource.com/660337Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Peter Conn <peconn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501213}
parent 92cc9dbb
......@@ -5,13 +5,12 @@
package org.chromium.chrome.browser.fullscreen;
import android.app.Activity;
import android.content.res.Resources;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.FrameLayout;
import org.chromium.base.ActivityState;
......@@ -47,7 +46,6 @@ public class ChromeFullscreenManager
private static final long ACTIVITY_RETURN_SHOW_REQUEST_DELAY_MS = 100;
private final Activity mActivity;
private final Window mWindow;
private final BrowserStateBrowserControlsVisibilityDelegate mBrowserVisibilityDelegate;
private final boolean mIsBottomControls;
private final boolean mExitFullscreenOnStop;
......@@ -55,7 +53,6 @@ public class ChromeFullscreenManager
private ControlContainer mControlContainer;
private int mTopControlContainerHeight;
private int mBottomControlContainerHeight;
private TabModelSelector mTabModelSelector;
private TabModelSelectorTabModelObserver mTabModelObserver;
private float mRendererTopControlOffset = Float.NaN;
......@@ -139,7 +136,6 @@ public class ChromeFullscreenManager
super(activity.getWindow());
mActivity = activity;
mWindow = activity.getWindow();
mIsBottomControls = isBottomControls;
mExitFullscreenOnStop = exitFullscreenOnStop;
mBrowserVisibilityDelegate = new BrowserStateBrowserControlsVisibilityDelegate(
......@@ -162,52 +158,47 @@ public class ChromeFullscreenManager
* @param modelSelector The tab model selector that will be monitored for tab changes.
* @param resControlContainerHeight The dimension resource ID for the control container height.
*/
public void initialize(ControlContainer controlContainer, TabModelSelector modelSelector,
public void initialize(ControlContainer controlContainer, final TabModelSelector modelSelector,
int resControlContainerHeight) {
ApplicationStatus.registerStateListenerForActivity(this, mActivity);
((BaseChromiumApplication) mActivity.getApplication())
.registerWindowFocusChangedListener(this);
mTabModelSelector = modelSelector;
mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelector) {
mTabModelObserver = new TabModelSelectorTabModelObserver(modelSelector) {
@Override
public void tabClosureCommitted(Tab tab) {
setTab(mTabModelSelector.getCurrentTab());
setTab(modelSelector.getCurrentTab());
}
@Override
public void allTabsClosureCommitted() {
setTab(mTabModelSelector.getCurrentTab());
setTab(modelSelector.getCurrentTab());
}
@Override
public void tabRemoved(Tab tab) {
setTab(mTabModelSelector.getCurrentTab());
setTab(modelSelector.getCurrentTab());
}
@Override
public void didSelectTab(Tab tab, TabSelectionType type, int lastId) {
setTab(mTabModelSelector.getCurrentTab());
setTab(modelSelector.getCurrentTab());
}
@Override
public void didCloseTab(int tabId, boolean incognito) {
setTab(mTabModelSelector.getCurrentTab());
setTab(modelSelector.getCurrentTab());
}
};
assert controlContainer != null;
mControlContainer = controlContainer;
Resources resources = mWindow.getContext().getResources();
int controlContainerHeight = resources.getDimensionPixelSize(resControlContainerHeight);
if (mIsBottomControls) {
mTopControlContainerHeight = 0;
mBottomControlContainerHeight = controlContainerHeight;
} else {
mTopControlContainerHeight = controlContainerHeight;
mBottomControlContainerHeight = 0;
}
int controlContainerHeight =
mActivity.getResources().getDimensionPixelSize(resControlContainerHeight);
mTopControlContainerHeight = mIsBottomControls ? 0 : controlContainerHeight;
mBottomControlContainerHeight = mIsBottomControls ? controlContainerHeight : 0;
mRendererTopContentOffset = mTopControlContainerHeight;
updateControlOffset();
......@@ -227,7 +218,7 @@ public class ChromeFullscreenManager
}
@Override
public void setTab(Tab tab) {
public void setTab(@Nullable Tab tab) {
Tab previousTab = getTab();
super.setTab(tab);
if (tab != null && previousTab != getTab()) {
......@@ -254,7 +245,7 @@ public class ChromeFullscreenManager
}, ACTIVITY_RETURN_SHOW_REQUEST_DELAY_MS);
} else if (newState == ActivityState.DESTROYED) {
ApplicationStatus.unregisterActivityStateListener(this);
((BaseChromiumApplication) mWindow.getContext().getApplicationContext())
((BaseChromiumApplication) mActivity.getApplicationContext())
.unregisterWindowFocusChangedListener(this);
mTabModelObserver.destroy();
......
......@@ -11,6 +11,7 @@ import static android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnLayoutChangeListener;
......@@ -43,11 +44,11 @@ public class FullscreenHtmlApiHandler {
private final Handler mHandler;
private final FullscreenHtmlApiDelegate mDelegate;
// We still need this since we are setting fullscreen UI state on the contentviewcore's
// container view, and a tab can have null content view core, i.e., if you navigate
// We still need this since we are setting fullscreen UI state on the ContentViewCore's
// container view, and a Tab can change to have null content view core, i.e., if you navigate
// to a native page.
private ContentViewCore mContentViewCoreInFullscreen;
private Tab mTabInFullscreen;
@Nullable private ContentViewCore mContentViewCoreInFullscreen;
@Nullable private Tab mTabInFullscreen;
private boolean mIsPersistentMode;
// Toast at the top of the screen that is shown when user enters fullscreen for the
......@@ -105,15 +106,18 @@ public class FullscreenHtmlApiHandler {
if (msg == null) return;
FullscreenHtmlApiHandler fullscreenHtmlApiHandler = mFullscreenHtmlApiHandler.get();
if (fullscreenHtmlApiHandler == null) return;
final ContentViewCore cvc = fullscreenHtmlApiHandler.mContentViewCoreInFullscreen;
if (cvc == null) return;
final View contentView = cvc.getContainerView();
int systemUiVisibility = contentView.getSystemUiVisibility();
switch (msg.what) {
case MSG_ID_SET_FULLSCREEN_SYSTEM_UI_FLAGS: {
assert fullscreenHtmlApiHandler.getPersistentFullscreenMode() :
"Calling after we exited fullscreen";
final ContentViewCore contentViewCore =
fullscreenHtmlApiHandler.mContentViewCoreInFullscreen;
if (contentViewCore == null) return;
final View contentView = contentViewCore.getContainerView();
int systemUiVisibility = contentView.getSystemUiVisibility();
if ((systemUiVisibility & SYSTEM_UI_FLAG_FULLSCREEN)
== SYSTEM_UI_FLAG_FULLSCREEN) {
return;
......@@ -144,20 +148,16 @@ public class FullscreenHtmlApiHandler {
}
case MSG_ID_CLEAR_LAYOUT_FULLSCREEN_FLAG: {
// Change this assert to simply ignoring the message to work around
// http://crbug/365638
// https://crbug/365638
// TODO(aberent): Fix bug
// assert mIsPersistentMode : "Calling after we exited fullscreen";
if (!fullscreenHtmlApiHandler.getPersistentFullscreenMode()) return;
final ContentViewCore contentViewCore =
fullscreenHtmlApiHandler.mContentViewCoreInFullscreen;
if (contentViewCore == null) return;
final View view = contentViewCore.getContainerView();
int systemUiVisibility = view.getSystemUiVisibility();
if ((systemUiVisibility & SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == 0) {
return;
}
systemUiVisibility &= ~SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
view.setSystemUiVisibility(systemUiVisibility);
contentView.setSystemUiVisibility(systemUiVisibility);
break;
}
default:
......
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.fullscreen;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
......@@ -20,7 +21,7 @@ public abstract class FullscreenManager {
private final FullscreenHtmlApiHandler mHtmlApiHandler;
private boolean mOverlayVideoMode;
private Tab mTab;
@Nullable private Tab mTab;
/**
* Constructs the basic ChromeTab oriented FullscreenManager.
......@@ -106,7 +107,7 @@ public abstract class FullscreenManager {
/**
* Sets the currently selected tab for fullscreen.
*/
public void setTab(Tab tab) {
public void setTab(@Nullable Tab tab) {
if (mTab == tab) return;
// Remove the fullscreen manager from the old tab before setting the new tab.
......@@ -121,7 +122,7 @@ public abstract class FullscreenManager {
/**
* @return The currently selected tab for fullscreen.
*/
public Tab getTab() {
@Nullable public Tab getTab() {
return mTab;
}
......
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