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; |
| 13 import org.chromium.content.browser.ChildProcessCreationParams; |
11 import org.chromium.content_public.browser.LoadUrlParams; | 14 import org.chromium.content_public.browser.LoadUrlParams; |
12 import org.chromium.ui.base.PageTransition; | 15 import org.chromium.ui.base.PageTransition; |
13 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; | 16 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; |
14 | 17 |
15 /** | 18 /** |
16 * An Activity is designed for WebAPKs (native Android apps) and displays a weba
pp in a nearly | 19 * An Activity is designed for WebAPKs (native Android apps) and displays a weba
pp in a nearly |
17 * UI-less Chrome. | 20 * UI-less Chrome. |
18 */ | 21 */ |
19 public class WebApkActivity extends WebappActivity { | 22 public class WebApkActivity extends WebappActivity { |
20 @Override | 23 @Override |
(...skipping 21 matching lines...) Expand all Loading... |
42 initializeSplashScreenWidgets(backgroundColor, null); | 45 initializeSplashScreenWidgets(backgroundColor, null); |
43 } | 46 } |
44 | 47 |
45 @Override | 48 @Override |
46 public void onStop() { | 49 public void onStop() { |
47 super.onStop(); | 50 super.onStop(); |
48 String packageName = getWebappInfo().webApkPackageName(); | 51 String packageName = getWebappInfo().webApkPackageName(); |
49 WebApkServiceConnectionManager.getInstance().disconnect( | 52 WebApkServiceConnectionManager.getInstance().disconnect( |
50 ContextUtils.getApplicationContext(), packageName); | 53 ContextUtils.getApplicationContext(), packageName); |
51 } | 54 } |
| 55 |
| 56 @Override |
| 57 public void onResume() { |
| 58 super.onResume(); |
| 59 // WebAPK hosts Chrome's renderer processes by declaring the Chrome's re
nderer service in |
| 60 // its AndroidManifest.xml. We set {@link ChildProcessCreationParams} fo
r WebAPK's renderer |
| 61 // process so the {@link ChildProcessLauncher} knows which application's
renderer |
| 62 // service to connect. |
| 63 initializeChildProcessCreationParams(true); |
| 64 } |
| 65 |
| 66 @Override |
| 67 protected void initializeChildProcessCreationParams() { |
| 68 // TODO(hanxi): crbug.com/611842. Investigates whether this function wor
ks for multiple |
| 69 // windows or with --site-per-process enabled. |
| 70 initializeChildProcessCreationParams(true); |
| 71 } |
| 72 |
| 73 @Override |
| 74 public void onPause() { |
| 75 super.onPause(); |
| 76 initializeChildProcessCreationParams(false); |
| 77 } |
| 78 |
| 79 /** |
| 80 * Initializes {@link ChildProcessCreationParams} as a WebAPK's renderer pro
cess if |
| 81 * {@link isForWebApk}} is true; as Chrome's child process otherwise. |
| 82 * @param isForWebApk: Whether the {@link ChildProcessCreationParams} is ini
tialized as a |
| 83 * WebAPK renderer process. |
| 84 */ |
| 85 private void initializeChildProcessCreationParams(boolean isForWebApk) { |
| 86 ChromeApplication chrome = (ChromeApplication) ContextUtils.getApplicati
onContext(); |
| 87 ChildProcessCreationParams params = chrome.getChildProcessCreationParams
(); |
| 88 if (isForWebApk) { |
| 89 int extraBindFlag = params == null ? 0 : params.getExtraBindFlags(); |
| 90 params = new ChildProcessCreationParams(getWebappInfo().webApkPackag
eName(), |
| 91 extraBindFlag, LibraryProcessType.PROCESS_WEBAPK_CHILD); |
| 92 } |
| 93 ChildProcessCreationParams.set(params); |
| 94 } |
52 } | 95 } |
OLD | NEW |