Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/tab/TopControlsVisibilityDelegate.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TopControlsVisibilityDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TopControlsVisibilityDelegate.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..28992aced0820ca9896c19255d57859616d90a64 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TopControlsVisibilityDelegate.java |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2015 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.tab; |
| + |
| +import org.chromium.chrome.browser.UrlConstants; |
| +import org.chromium.chrome.browser.device.DeviceClassManager; |
| +import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; |
| +import org.chromium.chrome.browser.util.AccessibilityUtil; |
| +import org.chromium.content_public.browser.WebContents; |
| + |
| +/** |
| + * A delegate to determine top controls visibility. |
|
gone
2015/12/16 21:58:10
visibility of the top controls
Yusuf
2015/12/16 22:14:34
Done.
|
| + */ |
| +public class TopControlsVisibilityDelegate { |
| + protected final Tab mTab; |
| + |
| + /** |
| + * Basic constructor. |
| + * @param tab The associated {@link Tab}. |
| + */ |
| + public TopControlsVisibilityDelegate(Tab tab) { |
| + mTab = tab; |
| + } |
| + |
| + /** |
| + * @return Whether hiding top controls is enabled or not. |
| + */ |
| + public boolean isHidingTopControlsEnabled() { |
| + WebContents webContents = mTab.getWebContents(); |
| + if (webContents == null || webContents.isDestroyed()) return false; |
| + |
| + String url = mTab.getUrl(); |
| + boolean enableHidingTopControls = url != null && !url.startsWith(UrlConstants.CHROME_SCHEME) |
|
gone
2015/12/16 21:58:10
if you're breaking the other conditions into &=, y
Yusuf
2015/12/16 22:14:34
Done.
|
| + && !url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME); |
| + |
| + int securityState = mTab.getSecurityLevel(); |
| + enableHidingTopControls &= (securityState != ConnectionSecurityLevel.SECURITY_ERROR |
| + && securityState != ConnectionSecurityLevel.SECURITY_WARNING); |
| + |
| + enableHidingTopControls &= |
| + !AccessibilityUtil.isAccessibilityEnabled(mTab.getApplicationContext()); |
| + enableHidingTopControls &= !mTab.getContentViewCore().isFocusedNodeEditable(); |
| + enableHidingTopControls &= !mTab.isShowingErrorPage(); |
| + enableHidingTopControls &= !webContents.isShowingInterstitialPage(); |
| + enableHidingTopControls &= (mTab.getFullscreenManager() != null); |
| + enableHidingTopControls &= DeviceClassManager.enableFullscreen(); |
| + enableHidingTopControls &= !DeviceClassManager.isAutoHidingToolbarDisabled( |
| + mTab.getApplicationContext()); |
| + enableHidingTopControls &= !mTab.isFullscreenWaitingForLoad(); |
| + |
| + return enableHidingTopControls; |
| + } |
| + |
| + /** |
| + * @return Whether showing top controls is enabled or not. |
| + */ |
| + public boolean isShowingTopControlsEnabled() { |
| + if (mTab.getFullscreenManager() == null) return true; |
| + return !mTab.getFullscreenManager().getPersistentFullscreenMode(); |
| + } |
| +} |