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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.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/webapps/WebappActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java
index a2fdd312582db9a49bde32a97a06a02642159d26..f4708334ca862692f58bfcb4790ce5c8990fbb58 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java
@@ -31,7 +31,9 @@ import org.chromium.chrome.browser.metrics.WebappUma;
import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.chrome.browser.tab.TabDelegateFactory;
import org.chromium.chrome.browser.tab.TabObserver;
+import org.chromium.chrome.browser.tab.TopControlsVisibilityDelegate;
import org.chromium.chrome.browser.util.ColorUtils;
import org.chromium.chrome.browser.util.UrlUtilities;
import org.chromium.content.browser.ScreenOrientationProvider;
@@ -495,17 +497,32 @@ public class WebappActivity extends FullScreenActivity {
return null;
}
- // Implements {@link FullScreenActivityTab.TopControlsVisibilityDelegate}.
@Override
- public boolean shouldShowTopControls(String url, int securityLevel) {
- boolean visible = false; // do not show top controls when URL is not ready yet.
- if (!TextUtils.isEmpty(url)) {
- boolean isSameWebsite =
- UrlUtilities.sameDomainOrHost(mWebappInfo.uri().toString(), url, true);
- visible = !isSameWebsite || securityLevel == ConnectionSecurityLevel.SECURITY_ERROR
- || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING;
- }
+ protected TabDelegateFactory createTabDelegateFactory() {
+ return new FullScreenDelegateFactory() {
+ @Override
+ public TopControlsVisibilityDelegate createTopControlsVisibilityDelegate(Tab tab) {
+ return new TopControlsVisibilityDelegate(tab) {
+ @Override
+ public boolean isShowingTopControlsEnabled() {
+ if (!super.isShowingTopControlsEnabled()) return false;
+ return shouldShowTopControls(mTab.getUrl(), mTab.getSecurityLevel());
+ }
+ };
+ }
+ };
+ }
+ public boolean shouldShowTopControls(String url, int securityLevel) {
+ // do not show top controls when URL is not ready yet.
gone 2015/12/16 21:58:10 Make this comment a full sentence.
Yusuf 2015/12/16 22:14:34 Done.
+ boolean visible = false;
+ if (TextUtils.isEmpty(url)) return false;
+
+ boolean isSameWebsite = UrlUtilities.sameDomainOrHost(
+ mWebappInfo.uri().toString(), url, true);
+ visible = !isSameWebsite
+ || securityLevel == ConnectionSecurityLevel.SECURITY_ERROR
+ || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING;
return visible;
}

Powered by Google App Engine
This is Rietveld 408576698