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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappBrowserControlsDelegate.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/WebappBrowserControlsDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappBrowserControlsDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappBrowserControlsDelegate.java
new file mode 100644
index 0000000000000000000000000000000000000000..8693831d8838c54d89643cb96641a10b44db8aff
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappBrowserControlsDelegate.java
@@ -0,0 +1,60 @@
+// Copyright 2017 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.webapps;
+
+import android.text.TextUtils;
+
+import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.chrome.browser.tab.TabStateBrowserControlsVisibilityDelegate;
+import org.chromium.chrome.browser.util.UrlUtilities;
+import org.chromium.components.security_state.ConnectionSecurityLevel;
+
+class WebappBrowserControlsDelegate extends TabStateBrowserControlsVisibilityDelegate {
+ private final WebappActivity mActivity;
+
+ public WebappBrowserControlsDelegate(WebappActivity activity, Tab tab) {
+ super(tab);
+ mActivity = activity;
+ }
+
+ @Override
+ public boolean isShowingBrowserControlsEnabled() {
+ if (!super.isShowingBrowserControlsEnabled()) return false;
+
+ return shouldShowBrowserControls(
+ mActivity.getWebappInfo(), 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} given the page's security level.
+ * @param info
+ * @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 boolean shouldShowBrowserControls(
+ WebappInfo info, String url, int securityLevel) {
+ // Do not show browser controls when URL is not ready yet.
+ if (TextUtils.isEmpty(url)) return false;
+
+ return shouldShowBrowserControlsForUrl(info, url)
+ || securityLevel == ConnectionSecurityLevel.DANGEROUS
+ || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING;
+ }
+
+ /**
+ * Returns whether the browser controls should be shown when a webapp is navigated to
+ * {@link url}.
+ */
+ protected boolean shouldShowBrowserControlsForUrl(WebappInfo info, String url) {
+ return !UrlUtilities.sameDomainOrHost(info.uri().toString(), url, true);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698