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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 1525793005: Move Tab's top controls visibility to a delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
index b6f0a4e846f6aa8ac20db3347299b1778b3f4255..cf34b0aaedb17a5ac70153eb4084f9e45f4c8171 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -49,7 +49,6 @@ import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper;
import org.chromium.chrome.browser.crash.MinidumpUploadService;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
-import org.chromium.chrome.browser.device.DeviceClassManager;
import org.chromium.chrome.browser.download.ChromeDownloadDelegate;
import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkUtils;
import org.chromium.chrome.browser.fullscreen.FullscreenManager;
@@ -73,7 +72,6 @@ import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
import org.chromium.chrome.browser.tabmodel.TabModelImpl;
-import org.chromium.chrome.browser.util.AccessibilityUtil;
import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
import org.chromium.components.navigation_interception.InterceptNavigationDelegate;
import org.chromium.content.browser.ActivityContentVideoViewClient;
@@ -521,6 +519,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
private TabDelegateFactory mDelegateFactory;
+ private TopControlsVisibilityDelegate mTopControlsVisibilityDelegate;
+
/**
* Creates an instance of a {@link Tab}.
* @param id The id this tab should be identified with.
@@ -1263,6 +1263,9 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
if (mAppBannerManager != null) addObserver(mAppBannerManager);
}
+ mTopControlsVisibilityDelegate =
+ mDelegateFactory.createTopControlsVisibilityDelegate(this);
+
// Attach the TabContentManager if we have one. This will bind this Tab's content layer
// to this manager.
// TODO(dtrainor): Remove this and move to a pull model instead of pushing the layer.
@@ -1449,6 +1452,13 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
/**
+ * @return Whether fullscreen state is waiting for the load to finish for an update.
+ */
+ boolean isFullscreenWaitingForLoad() {
+ return mIsFullscreenWaitingForLoad;
+ }
+
+ /**
* Called when a page has failed loading.
* @param errorCode The error code causing the page to fail loading.
*/
@@ -2406,29 +2416,8 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
/**
* @return Whether hiding top controls is enabled or not.
*/
- protected boolean isHidingTopControlsEnabled() {
- WebContents webContents = getWebContents();
- if (webContents == null || webContents.isDestroyed()) return false;
-
- String url = getUrl();
- boolean enableHidingTopControls = url != null && !url.startsWith(UrlConstants.CHROME_SCHEME)
- && !url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
-
- int securityState = getSecurityLevel();
- enableHidingTopControls &= (securityState != ConnectionSecurityLevel.SECURITY_ERROR
- && securityState != ConnectionSecurityLevel.SECURITY_WARNING);
-
- enableHidingTopControls &=
- !AccessibilityUtil.isAccessibilityEnabled(getApplicationContext());
- enableHidingTopControls &= !mContentViewCore.isFocusedNodeEditable();
- enableHidingTopControls &= !mIsShowingErrorPage;
- enableHidingTopControls &= !webContents.isShowingInterstitialPage();
- enableHidingTopControls &= (mFullscreenManager != null);
- enableHidingTopControls &= DeviceClassManager.enableFullscreen();
- enableHidingTopControls &= !DeviceClassManager.isAutoHidingToolbarDisabled(mActivity);
- enableHidingTopControls &= !mIsFullscreenWaitingForLoad;
-
- return enableHidingTopControls;
+ private boolean isHidingTopControlsEnabled() {
+ return mTopControlsVisibilityDelegate.isHidingTopControlsEnabled();
}
/**
@@ -2464,8 +2453,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
* @return Whether showing top controls is enabled or not.
*/
public boolean isShowingTopControlsEnabled() {
- if (mFullscreenManager == null) return true;
- return !mFullscreenManager.getPersistentFullscreenMode();
+ return mTopControlsVisibilityDelegate.isShowingTopControlsEnabled();
}
/**

Powered by Google App Engine
This is Rietveld 408576698