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 | 8 |
9 import org.chromium.base.ContextUtils; | 9 import org.chromium.base.ContextUtils; |
| 10 import org.chromium.base.library_loader.LibraryProcessType; |
| 11 import org.chromium.chrome.browser.ChromeApplication; |
10 import org.chromium.chrome.browser.ShortcutHelper; | 12 import org.chromium.chrome.browser.ShortcutHelper; |
11 import org.chromium.chrome.browser.banners.AppBannerManager; | 13 import org.chromium.chrome.browser.banners.AppBannerManager; |
12 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; | 14 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; |
13 import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl; | 15 import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl; |
14 import org.chromium.chrome.browser.tab.Tab; | 16 import org.chromium.chrome.browser.tab.Tab; |
15 import org.chromium.chrome.browser.tab.TabDelegateFactory; | 17 import org.chromium.chrome.browser.tab.TabDelegateFactory; |
16 import org.chromium.chrome.browser.tab.TabRedirectHandler; | 18 import org.chromium.chrome.browser.tab.TabRedirectHandler; |
17 import org.chromium.components.navigation_interception.NavigationParams; | 19 import org.chromium.components.navigation_interception.NavigationParams; |
| 20 import org.chromium.content.browser.ChildProcessCreationParams; |
18 import org.chromium.content_public.browser.LoadUrlParams; | 21 import org.chromium.content_public.browser.LoadUrlParams; |
19 import org.chromium.ui.base.PageTransition; | 22 import org.chromium.ui.base.PageTransition; |
20 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; | 23 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; |
21 | 24 |
22 /** | 25 /** |
23 * An Activity is designed for WebAPKs (native Android apps) and displays a weba
pp in a nearly | 26 * An Activity is designed for WebAPKs (native Android apps) and displays a weba
pp in a nearly |
24 * UI-less Chrome. | 27 * UI-less Chrome. |
25 */ | 28 */ |
26 public class WebApkActivity extends WebappActivity { | 29 public class WebApkActivity extends WebappActivity { |
27 @Override | 30 @Override |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 80 } |
78 }; | 81 }; |
79 } | 82 } |
80 | 83 |
81 public void onStop() { | 84 public void onStop() { |
82 super.onStop(); | 85 super.onStop(); |
83 String packageName = getWebappInfo().webApkPackageName(); | 86 String packageName = getWebappInfo().webApkPackageName(); |
84 WebApkServiceConnectionManager.getInstance().disconnect( | 87 WebApkServiceConnectionManager.getInstance().disconnect( |
85 ContextUtils.getApplicationContext(), packageName); | 88 ContextUtils.getApplicationContext(), packageName); |
86 } | 89 } |
| 90 |
| 91 @Override |
| 92 public void onResume() { |
| 93 super.onResume(); |
| 94 // WebAPK hosts Chrome's renderer processes by declaring the Chrome's re
nderer service in |
| 95 // its AndroidManifest.xml. We set {@link ChildProcessCreationParams} fo
r WebAPK's renderer |
| 96 // process so the {@link ChildProcessLauncher} knows which application's
renderer |
| 97 // service to connect. |
| 98 initializeChildProcessCreationParams(true); |
| 99 } |
| 100 |
| 101 @Override |
| 102 protected void initializeChildProcessCreationParams() { |
| 103 // TODO(hanxi): crbug.com/611842. Investigates whether this function wor
ks for multiple |
| 104 // windows or with --site-per-process enabled. |
| 105 initializeChildProcessCreationParams(true); |
| 106 } |
| 107 |
| 108 @Override |
| 109 public void onPause() { |
| 110 super.onPause(); |
| 111 initializeChildProcessCreationParams(false); |
| 112 } |
| 113 |
| 114 /** |
| 115 * Initializes {@link ChildProcessCreationParams} as a WebAPK's renderer pro
cess if |
| 116 * {@link isForWebApk}} is true; as Chrome's child process otherwise. |
| 117 * @param isForWebApk: Whether the {@link ChildProcessCreationParams} is ini
tialized as a |
| 118 * WebAPK renderer process. |
| 119 */ |
| 120 private void initializeChildProcessCreationParams(boolean isForWebApk) { |
| 121 ChromeApplication chrome = (ChromeApplication) ContextUtils.getApplicati
onContext(); |
| 122 ChildProcessCreationParams params = chrome.getChildProcessCreationParams
(); |
| 123 if (isForWebApk) { |
| 124 int extraBindFlag = params == null ? 0 : params.getExtraBindFlags(); |
| 125 params = new ChildProcessCreationParams(getWebappInfo().webApkPackag
eName(), |
| 126 extraBindFlag, LibraryProcessType.PROCESS_CHILD); |
| 127 } |
| 128 ChildProcessCreationParams.set(params); |
| 129 } |
87 } | 130 } |
OLD | NEW |