Chromium Code Reviews| 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; | 10 import org.chromium.base.library_loader.LibraryProcessType; |
| 11 import org.chromium.chrome.browser.ChromeApplication; | 11 import org.chromium.chrome.browser.ChromeApplication; |
| 12 import org.chromium.chrome.browser.ShortcutHelper; | 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.tab.InterceptNavigationDelegateImpl; | 14 import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl; |
| 15 import org.chromium.chrome.browser.tab.Tab; | 15 import org.chromium.chrome.browser.tab.Tab; |
| 16 import org.chromium.chrome.browser.tab.TabDelegateFactory; | 16 import org.chromium.chrome.browser.tab.TabDelegateFactory; |
| 17 import org.chromium.chrome.browser.tab.TabRedirectHandler; | 17 import org.chromium.chrome.browser.tab.TabRedirectHandler; |
| 18 import org.chromium.components.navigation_interception.NavigationParams; | 18 import org.chromium.components.navigation_interception.NavigationParams; |
| 19 import org.chromium.content.browser.ChildProcessCreationParams; | 19 import org.chromium.content.browser.ChildProcessCreationParams; |
| 20 import org.chromium.content.browser.ScreenOrientationProvider; | 20 import org.chromium.content.browser.ScreenOrientationProvider; |
| 21 import org.chromium.content_public.browser.LoadUrlParams; | 21 import org.chromium.content_public.browser.LoadUrlParams; |
| 22 import org.chromium.ui.base.PageTransition; | 22 import org.chromium.ui.base.PageTransition; |
| 23 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; | 23 import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * 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 |
| 27 * UI-less Chrome. | 27 * UI-less Chrome. |
| 28 */ | 28 */ |
| 29 public class WebApkActivity extends WebappActivity { | 29 public class WebApkActivity extends WebappActivity { |
| 30 /** Detects whether the associated Web Manifest changes. */ | 30 /** Manages whether to check update for the WebAPK, and starts update check if needed. */ |
| 31 private ManifestUpgradeDetector mManifestUpgradeDetector = null; | 31 private WebApkUpdateManager mUpdateManager; |
| 32 | |
| 33 @Override | 32 @Override |
| 34 protected void onNewIntent(Intent intent) { | 33 protected void onNewIntent(Intent intent) { |
| 35 super.onNewIntent(intent); | 34 super.onNewIntent(intent); |
| 36 // We could bring a WebAPK hosted WebappActivity to foreground and navig ate it to a | 35 // We could bring a WebAPK hosted WebappActivity to foreground and navig ate it to a |
| 37 // different URL. For example, WebAPK "foo" is launched and navigates to | 36 // different URL. For example, WebAPK "foo" is launched and navigates to |
| 38 // "www.foo.com/foo". In Chrome, user clicks a link "www.foo.com/bar" in Google search | 37 // "www.foo.com/foo". In Chrome, user clicks a link "www.foo.com/bar" in Google search |
| 39 // results. After clicking the link, WebAPK "foo" is brought to foregrou nd, and | 38 // results. After clicking the link, WebAPK "foo" is brought to foregrou nd, and |
| 40 // loads the page of "www.foo.com/bar" at the same time. | 39 // loads the page of "www.foo.com/bar" at the same time. |
| 41 // The extra {@link ShortcutHelper.EXTRA_URL} provides the URL that the WebAPK will | 40 // The extra {@link ShortcutHelper.EXTRA_URL} provides the URL that the WebAPK will |
| 42 // navigate to. | 41 // navigate to. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 } | 138 } |
| 140 | 139 |
| 141 @Override | 140 @Override |
| 142 protected void initializeChildProcessCreationParams() { | 141 protected void initializeChildProcessCreationParams() { |
| 143 // TODO(hanxi): crbug.com/611842. Investigates whether this function wor ks for multiple | 142 // TODO(hanxi): crbug.com/611842. Investigates whether this function wor ks for multiple |
| 144 // windows or with --site-per-process enabled. | 143 // windows or with --site-per-process enabled. |
| 145 initializeChildProcessCreationParams(true); | 144 initializeChildProcessCreationParams(true); |
| 146 } | 145 } |
| 147 | 146 |
| 148 @Override | 147 @Override |
| 149 public void finishNativeInitialization() { | 148 public void onDeferredStartup() { |
| 150 super.finishNativeInitialization(); | 149 super.onDeferredStartup(); |
| 151 | 150 |
| 152 // TODO(hanxi): Ask WebApk's update manager whether to check resource up dates. | 151 mUpdateManager = new WebApkUpdateManager(); |
| 153 if (mManifestUpgradeDetector == null) { | 152 mUpdateManager.checkIfUpdateNeeded(getActivityTab(), mWebappInfo); |
|
pkotwicz
2016/08/11 22:02:43
Nit: The method name is deceiving. This method not
Xi Han
2016/08/15 21:38:44
Done.
| |
| 154 mManifestUpgradeDetector = | |
| 155 new ManifestUpgradeDetector(getActivityTab(), mWebappInfo); | |
| 156 } | |
| 157 mManifestUpgradeDetector.start(); | |
| 158 } | 153 } |
| 159 | 154 |
| 160 @Override | 155 @Override |
| 161 public void onPause() { | 156 public void onPause() { |
| 162 super.onPause(); | 157 super.onPause(); |
| 163 initializeChildProcessCreationParams(false); | 158 initializeChildProcessCreationParams(false); |
| 164 } | 159 } |
| 165 | 160 |
| 166 /** | 161 /** |
| 167 * Initializes {@link ChildProcessCreationParams} as a WebAPK's renderer pro cess if | 162 * Initializes {@link ChildProcessCreationParams} as a WebAPK's renderer pro cess if |
| 168 * {@link isForWebApk}} is true; as Chrome's child process otherwise. | 163 * {@link isForWebApk}} is true; as Chrome's child process otherwise. |
| 169 * @param isForWebApk: Whether the {@link ChildProcessCreationParams} is ini tialized as a | 164 * @param isForWebApk: Whether the {@link ChildProcessCreationParams} is ini tialized as a |
| 170 * WebAPK renderer process. | 165 * WebAPK renderer process. |
| 171 */ | 166 */ |
| 172 private void initializeChildProcessCreationParams(boolean isForWebApk) { | 167 private void initializeChildProcessCreationParams(boolean isForWebApk) { |
| 173 ChromeApplication chrome = (ChromeApplication) ContextUtils.getApplicati onContext(); | 168 ChromeApplication chrome = (ChromeApplication) ContextUtils.getApplicati onContext(); |
| 174 ChildProcessCreationParams params = chrome.getChildProcessCreationParams (); | 169 ChildProcessCreationParams params = chrome.getChildProcessCreationParams (); |
| 175 if (isForWebApk) { | 170 if (isForWebApk) { |
| 176 int extraBindFlag = params == null ? 0 : params.getExtraBindFlags(); | 171 int extraBindFlag = params == null ? 0 : params.getExtraBindFlags(); |
| 177 params = new ChildProcessCreationParams(getWebappInfo().webApkPackag eName(), | 172 params = new ChildProcessCreationParams(getWebappInfo().webApkPackag eName(), |
| 178 extraBindFlag, LibraryProcessType.PROCESS_CHILD); | 173 extraBindFlag, LibraryProcessType.PROCESS_CHILD); |
| 179 } | 174 } |
| 180 ChildProcessCreationParams.set(params); | 175 ChildProcessCreationParams.set(params); |
| 181 } | 176 } |
| 182 | 177 |
| 183 @Override | 178 @Override |
| 184 protected void onDestroyInternal() { | 179 protected void onDestroyInternal() { |
| 185 if (mManifestUpgradeDetector != null) { | 180 if (mUpdateManager != null) { |
| 186 mManifestUpgradeDetector.destroy(); | 181 mUpdateManager.destroy(); |
| 187 } | 182 } |
| 188 super.onDestroyInternal(); | 183 super.onDestroyInternal(); |
| 189 } | 184 } |
| 190 } | 185 } |
| OLD | NEW |