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

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

Issue 2758193002: [Android WebAPKs] Don't navigate WebAPK when launching it from launcher (Closed)
Patch Set: Merge branch 'master' into twitter Created 3 years, 9 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 9
9 import org.chromium.base.ContextUtils; 10 import org.chromium.base.ContextUtils;
10 import org.chromium.base.library_loader.LibraryProcessType; 11 import org.chromium.base.library_loader.LibraryProcessType;
11 import org.chromium.base.process_launcher.ChildProcessCreationParams; 12 import org.chromium.base.process_launcher.ChildProcessCreationParams;
12 import org.chromium.chrome.browser.ShortcutHelper;
13 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; 13 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams;
14 import org.chromium.chrome.browser.metrics.WebApkUma; 14 import org.chromium.chrome.browser.metrics.WebApkUma;
15 import org.chromium.chrome.browser.tab.BrowserControlsVisibilityDelegate; 15 import org.chromium.chrome.browser.tab.BrowserControlsVisibilityDelegate;
16 import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl; 16 import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl;
17 import org.chromium.chrome.browser.tab.Tab; 17 import org.chromium.chrome.browser.tab.Tab;
18 import org.chromium.chrome.browser.tab.TabDelegateFactory; 18 import org.chromium.chrome.browser.tab.TabDelegateFactory;
19 import org.chromium.chrome.browser.tab.TabRedirectHandler; 19 import org.chromium.chrome.browser.tab.TabRedirectHandler;
20 import org.chromium.components.navigation_interception.NavigationParams; 20 import org.chromium.components.navigation_interception.NavigationParams;
21 import org.chromium.content_public.browser.LoadUrlParams;
22 import org.chromium.ui.base.PageTransition;
23 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; 21 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager;
24 22
25 /** 23 /**
26 * An Activity is designed for WebAPKs (native Android apps) and displays a weba pp in a nearly 24 * An Activity is designed for WebAPKs (native Android apps) and displays a weba pp in a nearly
27 * UI-less Chrome. 25 * UI-less Chrome.
28 */ 26 */
29 public class WebApkActivity extends WebappActivity { 27 public class WebApkActivity extends WebappActivity {
30 /** Manages whether to check update for the WebAPK, and starts update check if needed. */ 28 /** Manages whether to check update for the WebAPK, and starts update check if needed. */
31 private WebApkUpdateManager mUpdateManager; 29 private WebApkUpdateManager mUpdateManager;
32 30
33 /** Indicates whether launching renderer in WebAPK process is enabled. */ 31 /** Indicates whether launching renderer in WebAPK process is enabled. */
34 private boolean mCanLaunchRendererInWebApkProcess; 32 private boolean mCanLaunchRendererInWebApkProcess;
35 33
36 private final ChildProcessCreationParams mDefaultParams = 34 private final ChildProcessCreationParams mDefaultParams =
37 ChildProcessCreationParams.getDefault(); 35 ChildProcessCreationParams.getDefault();
38 36
39 @Override 37 @Override
40 protected void onNewIntent(Intent intent) {
41 super.onNewIntent(intent);
42 // We could bring a WebAPK hosted WebappActivity to foreground and navig ate it to a
43 // different URL. For example, WebAPK "foo" is launched and navigates to
44 // "www.foo.com/foo". In Chrome, user clicks a link "www.foo.com/bar" in Google search
45 // results. After clicking the link, WebAPK "foo" is brought to foregrou nd, and
46 // loads the page of "www.foo.com/bar" at the same time.
47 // The extra {@link ShortcutHelper.EXTRA_URL} provides the URL that the WebAPK will
48 // navigate to.
49 String overrideUrl = intent.getStringExtra(ShortcutHelper.EXTRA_URL);
50 if (overrideUrl != null && isInitialized()
51 && !overrideUrl.equals(getActivityTab().getUrl())) {
52 getActivityTab().loadUrl(
53 new LoadUrlParams(overrideUrl, PageTransition.AUTO_TOPLEVEL) );
54 }
55 if (isInitialized()) {
56 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toStr ing());
57 }
58 }
59
60 @Override
61 protected WebappInfo createWebappInfo(Intent intent) { 38 protected WebappInfo createWebappInfo(Intent intent) {
62 return (intent == null) ? WebApkInfo.createEmpty() : WebApkInfo.create(i ntent); 39 return (intent == null) ? WebApkInfo.createEmpty() : WebApkInfo.create(i ntent);
63 } 40 }
64 41
65 @Override 42 @Override
43 protected void initializeUI(Bundle savedInstance) {
44 super.initializeUI(savedInstance);
45 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toString( ));
46 }
47
48 @Override
66 protected TabDelegateFactory createTabDelegateFactory() { 49 protected TabDelegateFactory createTabDelegateFactory() {
67 return new WebappDelegateFactory(this) { 50 return new WebappDelegateFactory(this) {
68 @Override 51 @Override
69 public InterceptNavigationDelegateImpl createInterceptNavigationDele gate(Tab tab) { 52 public InterceptNavigationDelegateImpl createInterceptNavigationDele gate(Tab tab) {
70 return new InterceptNavigationDelegateImpl(tab) { 53 return new InterceptNavigationDelegateImpl(tab) {
71 @Override 54 @Override
72 public ExternalNavigationParams.Builder buildExternalNavigat ionParams( 55 public ExternalNavigationParams.Builder buildExternalNavigat ionParams(
73 NavigationParams navigationParams, 56 NavigationParams navigationParams,
74 TabRedirectHandler tabRedirectHandler, boolean shoul dCloseTab) { 57 TabRedirectHandler tabRedirectHandler, boolean shoul dCloseTab) {
75 ExternalNavigationParams.Builder builder = 58 ExternalNavigationParams.Builder builder =
(...skipping 18 matching lines...) Expand all
94 Tab tab) { 77 Tab tab) {
95 return new WebApkBrowserControlsDelegate(WebApkActivity.this, ta b); 78 return new WebApkBrowserControlsDelegate(WebApkActivity.this, ta b);
96 } 79 }
97 }; 80 };
98 } 81 }
99 82
100 @Override 83 @Override
101 public void finishNativeInitialization() { 84 public void finishNativeInitialization() {
102 super.finishNativeInitialization(); 85 super.finishNativeInitialization();
103 if (!isInitialized()) return; 86 if (!isInitialized()) return;
104 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toString( ));
105 mCanLaunchRendererInWebApkProcess = ChromeWebApkHost.canLaunchRendererIn WebApkProcess(); 87 mCanLaunchRendererInWebApkProcess = ChromeWebApkHost.canLaunchRendererIn WebApkProcess();
106 } 88 }
107 89
108 @Override 90 @Override
109 public void onStop() { 91 public void onStop() {
110 super.onStop(); 92 super.onStop();
111 WebApkServiceConnectionManager.getInstance().disconnect( 93 WebApkServiceConnectionManager.getInstance().disconnect(
112 ContextUtils.getApplicationContext(), getWebApkPackageName()); 94 ContextUtils.getApplicationContext(), getWebApkPackageName());
113 } 95 }
114 96
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 173 }
192 174
193 @Override 175 @Override
194 protected void onDestroyInternal() { 176 protected void onDestroyInternal() {
195 if (mUpdateManager != null) { 177 if (mUpdateManager != null) {
196 mUpdateManager.destroy(); 178 mUpdateManager.destroy();
197 } 179 }
198 super.onDestroyInternal(); 180 super.onDestroyInternal();
199 } 181 }
200 } 182 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698