| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.Intent; | 7 import android.content.Intent; |
| 8 import android.os.Bundle; | 8 import android.os.Bundle; |
| 9 import android.os.SystemClock; | 9 import android.os.SystemClock; |
| 10 | 10 |
| 11 import org.chromium.base.ContextUtils; | 11 import org.chromium.base.ContextUtils; |
| 12 import org.chromium.base.library_loader.LibraryProcessType; | 12 import org.chromium.base.library_loader.LibraryProcessType; |
| 13 import org.chromium.base.metrics.RecordHistogram; | 13 import org.chromium.base.metrics.RecordHistogram; |
| 14 import org.chromium.base.process_launcher.ChildProcessCreationParams; | 14 import org.chromium.base.process_launcher.ChildProcessCreationParams; |
| 15 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; | 15 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; |
| 16 import org.chromium.chrome.browser.metrics.WebApkUma; | 16 import org.chromium.chrome.browser.metrics.WebApkUma; |
| 17 import org.chromium.chrome.browser.tab.BrowserControlsVisibilityDelegate; | 17 import org.chromium.chrome.browser.tab.BrowserControlsVisibilityDelegate; |
| 18 import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl; | 18 import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl; |
| 19 import org.chromium.chrome.browser.tab.Tab; | 19 import org.chromium.chrome.browser.tab.Tab; |
| 20 import org.chromium.chrome.browser.tab.TabDelegateFactory; | 20 import org.chromium.chrome.browser.tab.TabDelegateFactory; |
| 21 import org.chromium.chrome.browser.tab.TabRedirectHandler; | 21 import org.chromium.chrome.browser.tab.TabRedirectHandler; |
| 22 import org.chromium.chrome.browser.util.UrlUtilities; | |
| 23 import org.chromium.components.navigation_interception.NavigationParams; | 22 import org.chromium.components.navigation_interception.NavigationParams; |
| 24 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; | 23 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; |
| 25 | 24 |
| 26 import java.util.concurrent.TimeUnit; | 25 import java.util.concurrent.TimeUnit; |
| 27 | 26 |
| 28 /** | 27 /** |
| 29 * An Activity is designed for WebAPKs (native Android apps) and displays a weba
pp in a nearly | 28 * An Activity is designed for WebAPKs (native Android apps) and displays a weba
pp in a nearly |
| 30 * UI-less Chrome. | 29 * UI-less Chrome. |
| 31 */ | 30 */ |
| 32 public class WebApkActivity extends WebappActivity { | 31 public class WebApkActivity extends WebappActivity { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 51 protected void initializeUI(Bundle savedInstance) { | 50 protected void initializeUI(Bundle savedInstance) { |
| 52 super.initializeUI(savedInstance); | 51 super.initializeUI(savedInstance); |
| 53 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toString(
)); | 52 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toString(
)); |
| 54 } | 53 } |
| 55 | 54 |
| 56 @Override | 55 @Override |
| 57 protected TabDelegateFactory createTabDelegateFactory() { | 56 protected TabDelegateFactory createTabDelegateFactory() { |
| 58 return new WebappDelegateFactory(this) { | 57 return new WebappDelegateFactory(this) { |
| 59 @Override | 58 @Override |
| 60 public InterceptNavigationDelegateImpl createInterceptNavigationDele
gate(Tab tab) { | 59 public InterceptNavigationDelegateImpl createInterceptNavigationDele
gate(Tab tab) { |
| 61 return new WebappInterceptNavigationDelegate(WebApkActivity.this
, tab) { | 60 return new InterceptNavigationDelegateImpl(tab) { |
| 62 @Override | 61 @Override |
| 63 public ExternalNavigationParams.Builder buildExternalNavigat
ionParams( | 62 public ExternalNavigationParams.Builder buildExternalNavigat
ionParams( |
| 64 NavigationParams navigationParams, | 63 NavigationParams navigationParams, |
| 65 TabRedirectHandler tabRedirectHandler, boolean shoul
dCloseTab) { | 64 TabRedirectHandler tabRedirectHandler, boolean shoul
dCloseTab) { |
| 66 ExternalNavigationParams.Builder builder = | 65 ExternalNavigationParams.Builder builder = |
| 67 super.buildExternalNavigationParams( | 66 super.buildExternalNavigationParams( |
| 68 navigationParams, tabRedirectHandler, sh
ouldCloseTab); | 67 navigationParams, tabRedirectHandler, sh
ouldCloseTab); |
| 69 builder.setWebApkPackageName(getWebApkPackageName()); | 68 builder.setWebApkPackageName(getWebApkPackageName()); |
| 70 return builder; | 69 return builder; |
| 71 } | 70 } |
| 72 | |
| 73 @Override | |
| 74 protected boolean isUrlOutsideWebappScope(WebappInfo info, S
tring url) { | |
| 75 return !UrlUtilities.isUrlWithinScope(url, info.scopeUri
().toString()); | |
| 76 } | |
| 77 }; | 71 }; |
| 78 } | 72 } |
| 79 | 73 |
| 80 @Override | 74 @Override |
| 81 public boolean canShowAppBanners(Tab tab) { | 75 public boolean canShowAppBanners(Tab tab) { |
| 82 // Do not show app banners for WebAPKs regardless of the current
page URL. | 76 // Do not show app banners for WebAPKs regardless of the current
page URL. |
| 83 // A WebAPK can display a page outside of its WebAPK scope if a
page within the | 77 // A WebAPK can display a page outside of its WebAPK scope if a
page within the |
| 84 // WebAPK scope navigates via JavaScript while the WebAPK is in
the background. | 78 // WebAPK scope navigates via JavaScript while the WebAPK is in
the background. |
| 85 return false; | 79 return false; |
| 86 } | 80 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 202 } |
| 209 | 203 |
| 210 @Override | 204 @Override |
| 211 protected void onDestroyInternal() { | 205 protected void onDestroyInternal() { |
| 212 if (mUpdateManager != null) { | 206 if (mUpdateManager != null) { |
| 213 mUpdateManager.destroy(); | 207 mUpdateManager.destroy(); |
| 214 } | 208 } |
| 215 super.onDestroyInternal(); | 209 super.onDestroyInternal(); |
| 216 } | 210 } |
| 217 } | 211 } |
| OLD | NEW |