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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java

Issue 2829943002: Redirecting off-origin navigations in PWAs to CCT. (Closed)
Patch Set: Relaxed the WebApkIntegrationTest Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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;
22 import org.chromium.components.navigation_interception.NavigationParams; 23 import org.chromium.components.navigation_interception.NavigationParams;
23 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; 24 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager;
24 25
25 import java.util.concurrent.TimeUnit; 26 import java.util.concurrent.TimeUnit;
26 27
27 /** 28 /**
28 * An Activity is designed for WebAPKs (native Android apps) and displays a weba pp in a nearly 29 * An Activity is designed for WebAPKs (native Android apps) and displays a weba pp in a nearly
29 * UI-less Chrome. 30 * UI-less Chrome.
30 */ 31 */
31 public class WebApkActivity extends WebappActivity { 32 public class WebApkActivity extends WebappActivity {
(...skipping 18 matching lines...) Expand all
50 protected void initializeUI(Bundle savedInstance) { 51 protected void initializeUI(Bundle savedInstance) {
51 super.initializeUI(savedInstance); 52 super.initializeUI(savedInstance);
52 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toString( )); 53 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toString( ));
53 } 54 }
54 55
55 @Override 56 @Override
56 protected TabDelegateFactory createTabDelegateFactory() { 57 protected TabDelegateFactory createTabDelegateFactory() {
57 return new WebappDelegateFactory(this) { 58 return new WebappDelegateFactory(this) {
58 @Override 59 @Override
59 public InterceptNavigationDelegateImpl createInterceptNavigationDele gate(Tab tab) { 60 public InterceptNavigationDelegateImpl createInterceptNavigationDele gate(Tab tab) {
60 return new InterceptNavigationDelegateImpl(tab) { 61 return new WebappInterceptNavigationDelegate(WebApkActivity.this , tab) {
61 @Override 62 @Override
62 public ExternalNavigationParams.Builder buildExternalNavigat ionParams( 63 public ExternalNavigationParams.Builder buildExternalNavigat ionParams(
63 NavigationParams navigationParams, 64 NavigationParams navigationParams,
64 TabRedirectHandler tabRedirectHandler, boolean shoul dCloseTab) { 65 TabRedirectHandler tabRedirectHandler, boolean shoul dCloseTab) {
65 ExternalNavigationParams.Builder builder = 66 ExternalNavigationParams.Builder builder =
66 super.buildExternalNavigationParams( 67 super.buildExternalNavigationParams(
67 navigationParams, tabRedirectHandler, sh ouldCloseTab); 68 navigationParams, tabRedirectHandler, sh ouldCloseTab);
68 builder.setWebApkPackageName(getWebApkPackageName()); 69 builder.setWebApkPackageName(getWebApkPackageName());
69 return builder; 70 return builder;
70 } 71 }
72
73 @Override
74 protected boolean isUrlOutsideWebappScope(WebappInfo info, S tring url) {
75 return !UrlUtilities.isUrlWithinScope(url, info.scopeUri ().toString());
76 }
71 }; 77 };
72 } 78 }
73 79
74 @Override 80 @Override
75 public boolean canShowAppBanners(Tab tab) { 81 public boolean canShowAppBanners(Tab tab) {
76 // Do not show app banners for WebAPKs regardless of the current page URL. 82 // Do not show app banners for WebAPKs regardless of the current page URL.
77 // A WebAPK can display a page outside of its WebAPK scope if a page within the 83 // A WebAPK can display a page outside of its WebAPK scope if a page within the
78 // WebAPK scope navigates via JavaScript while the WebAPK is in the background. 84 // WebAPK scope navigates via JavaScript while the WebAPK is in the background.
79 return false; 85 return false;
80 } 86 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 208 }
203 209
204 @Override 210 @Override
205 protected void onDestroyInternal() { 211 protected void onDestroyInternal() {
206 if (mUpdateManager != null) { 212 if (mUpdateManager != null) {
207 mUpdateManager.destroy(); 213 mUpdateManager.destroy();
208 } 214 }
209 super.onDestroyInternal(); 215 super.onDestroyInternal();
210 } 216 }
211 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698