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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDelegateFactory.java

Issue 2636103002: [WebAPKs] Show minibar when WebAPK navigates outside scope specified in Web Manifest (Closed)
Patch Set: Merge branch 'master' into minibar Created 3 years, 11 months 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/WebappDelegateFactory.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDelegateFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDelegateFactory.java
index 87f2d3edd4550c0e88d2733f04906bd675f9f06d..1eec43afb535d3bc9361103f67816721a8c31b0a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDelegateFactory.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDelegateFactory.java
@@ -8,16 +8,12 @@ import android.content.Intent;
import android.text.TextUtils;
import org.chromium.base.ContextUtils;
-import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.tab.BrowserControlsVisibilityDelegate;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabDelegateFactory;
-import org.chromium.chrome.browser.tab.TabStateBrowserControlsVisibilityDelegate;
import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
import org.chromium.chrome.browser.util.IntentUtils;
-import org.chromium.chrome.browser.util.UrlUtilities;
-import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.webapk.lib.client.WebApkNavigationClient;
/**
@@ -60,51 +56,6 @@ public class WebappDelegateFactory extends FullScreenDelegateFactory {
}
}
- @VisibleForTesting
- static class BrowserControlsDelegate extends TabStateBrowserControlsVisibilityDelegate {
- private final WebappActivity mActivity;
-
- public BrowserControlsDelegate(WebappActivity activity, Tab tab) {
- super(tab);
- mActivity = activity;
- }
-
- @Override
- public boolean isShowingBrowserControlsEnabled() {
- if (!super.isShowingBrowserControlsEnabled()) return false;
-
- String webappStartUrl = mActivity.getWebappInfo().uri().toString();
- return shouldShowBrowserControls(
- webappStartUrl, mTab.getUrl(), mTab.getSecurityLevel());
- }
-
- @Override
- public boolean isHidingBrowserControlsEnabled() {
- return !isShowingBrowserControlsEnabled();
- }
-
- /**
- * Returns whether the browser controls should be shown when a webapp is navigated to
- * {@link url}.
- * @param webappStartUrl The webapp's URL when it is opened from the home screen.
- * @param url The webapp's current URL
- * @param securityLevel The security level for the webapp's current URL.
- * @return Whether the browser controls should be shown for {@link url}.
- */
- public static boolean shouldShowBrowserControls(
- String webappStartUrl, String url, int securityLevel) {
- // Do not show browser controls when URL is not ready yet.
- boolean visible = false;
- if (TextUtils.isEmpty(url)) return false;
-
- boolean isSameWebsite =
- UrlUtilities.sameDomainOrHost(webappStartUrl, url, true);
- visible = !isSameWebsite || securityLevel == ConnectionSecurityLevel.DANGEROUS
- || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING;
- return visible;
- }
- }
-
private final WebappActivity mActivity;
public WebappDelegateFactory(WebappActivity activity) {
@@ -118,6 +69,6 @@ public class WebappDelegateFactory extends FullScreenDelegateFactory {
@Override
public BrowserControlsVisibilityDelegate createBrowserControlsVisibilityDelegate(Tab tab) {
- return new BrowserControlsDelegate(mActivity, tab);
+ return new WebappBrowserControlsDelegate(mActivity, tab);
}
}

Powered by Google App Engine
This is Rietveld 408576698