OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 com.android.webview.chromium; | 5 package com.android.webview.chromium; |
6 | 6 |
7 import android.Manifest; | 7 import android.Manifest; |
8 import android.app.ActivityManager; | 8 import android.app.ActivityManager; |
9 import android.content.ComponentCallbacks2; | 9 import android.content.ComponentCallbacks2; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 import org.chromium.android_webview.AwDevToolsServer; | 43 import org.chromium.android_webview.AwDevToolsServer; |
44 import org.chromium.android_webview.AwMetricsServiceClient; | 44 import org.chromium.android_webview.AwMetricsServiceClient; |
45 import org.chromium.android_webview.AwNetworkChangeNotifierRegistrationPolicy; | 45 import org.chromium.android_webview.AwNetworkChangeNotifierRegistrationPolicy; |
46 import org.chromium.android_webview.AwQuotaManagerBridge; | 46 import org.chromium.android_webview.AwQuotaManagerBridge; |
47 import org.chromium.android_webview.AwResource; | 47 import org.chromium.android_webview.AwResource; |
48 import org.chromium.android_webview.AwSettings; | 48 import org.chromium.android_webview.AwSettings; |
49 import org.chromium.android_webview.HttpAuthDatabase; | 49 import org.chromium.android_webview.HttpAuthDatabase; |
50 import org.chromium.android_webview.PlatformServiceBridge; | 50 import org.chromium.android_webview.PlatformServiceBridge; |
51 import org.chromium.android_webview.ResourcesContextWrapperFactory; | 51 import org.chromium.android_webview.ResourcesContextWrapperFactory; |
52 import org.chromium.base.BuildConfig; | 52 import org.chromium.base.BuildConfig; |
| 53 import org.chromium.base.BuildInfo; |
53 import org.chromium.base.CommandLine; | 54 import org.chromium.base.CommandLine; |
54 import org.chromium.base.ContextUtils; | 55 import org.chromium.base.ContextUtils; |
55 import org.chromium.base.MemoryPressureListener; | 56 import org.chromium.base.MemoryPressureListener; |
56 import org.chromium.base.PackageUtils; | 57 import org.chromium.base.PackageUtils; |
57 import org.chromium.base.PathService; | 58 import org.chromium.base.PathService; |
58 import org.chromium.base.PathUtils; | 59 import org.chromium.base.PathUtils; |
59 import org.chromium.base.ThreadUtils; | 60 import org.chromium.base.ThreadUtils; |
60 import org.chromium.base.TraceEvent; | 61 import org.chromium.base.TraceEvent; |
61 import org.chromium.base.annotations.SuppressFBWarnings; | 62 import org.chromium.base.annotations.SuppressFBWarnings; |
62 import org.chromium.base.library_loader.LibraryLoader; | 63 import org.chromium.base.library_loader.LibraryLoader; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 initialize(WebViewDelegateFactory.createApi21CompatibilityDelegate()); | 192 initialize(WebViewDelegateFactory.createApi21CompatibilityDelegate()); |
192 } | 193 } |
193 | 194 |
194 /** | 195 /** |
195 * Constructor called by the API 22 version of {@link WebViewFactory} and la
ter. | 196 * Constructor called by the API 22 version of {@link WebViewFactory} and la
ter. |
196 */ | 197 */ |
197 public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegat
e) { | 198 public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegat
e) { |
198 initialize(WebViewDelegateFactory.createProxyDelegate(delegate)); | 199 initialize(WebViewDelegateFactory.createProxyDelegate(delegate)); |
199 } | 200 } |
200 | 201 |
| 202 /** |
| 203 * Constructor for internal use when a proxy delegate has already been creat
ed. |
| 204 */ |
| 205 WebViewChromiumFactoryProvider(WebViewDelegate delegate) { |
| 206 initialize(delegate); |
| 207 } |
| 208 |
201 @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") | 209 @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") |
202 private void initialize(WebViewDelegate webViewDelegate) { | 210 private void initialize(WebViewDelegate webViewDelegate) { |
203 mWebViewDelegate = webViewDelegate; | 211 mWebViewDelegate = webViewDelegate; |
204 Context ctx = mWebViewDelegate.getApplication().getApplicationContext(); | 212 Context ctx = mWebViewDelegate.getApplication().getApplicationContext(); |
205 | 213 |
206 // If the application context is DE, but we have credentials, use a CE c
ontext instead | 214 // If the application context is DE, but we have credentials, use a CE c
ontext instead |
207 try { | 215 try { |
208 checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication()); | 216 checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication()); |
209 } catch (IllegalArgumentException e) { | 217 } catch (IllegalArgumentException e) { |
210 if (!ctx.getSystemService(UserManager.class).isUserUnlocked()) { | 218 if (!ctx.getSystemService(UserManager.class).isUserUnlocked()) { |
211 throw e; | 219 throw e; |
212 } | 220 } |
213 ctx = ctx.createCredentialProtectedStorageContext(); | 221 ctx = ctx.createCredentialProtectedStorageContext(); |
214 } | 222 } |
215 | 223 |
216 // WebView needs to make sure to always use the wrapped application cont
ext. | 224 // WebView needs to make sure to always use the wrapped application cont
ext. |
217 ContextUtils.initApplicationContext(ResourcesContextWrapperFactory.get(c
tx)); | 225 ContextUtils.initApplicationContext(ResourcesContextWrapperFactory.get(c
tx)); |
218 | 226 |
219 if (isBuildDebuggable()) { | 227 if (isBuildDebuggable()) { |
220 // Suppress the StrictMode violation as this codepath is only hit on
debuggable builds. | 228 // Suppress the StrictMode violation as this codepath is only hit on
debuggable builds. |
221 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(
); | 229 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(
); |
222 CommandLine.initFromFile(COMMAND_LINE_FILE); | 230 CommandLine.initFromFile(COMMAND_LINE_FILE); |
223 StrictMode.setThreadPolicy(oldPolicy); | 231 StrictMode.setThreadPolicy(oldPolicy); |
224 } else { | 232 } else { |
225 CommandLine.init(null); | 233 CommandLine.init(null); |
226 } | 234 } |
227 | 235 |
228 if (Settings.Global.getInt(ContextUtils.getApplicationContext().getConte
ntResolver(), | 236 boolean multiProcess = false; |
229 Settings.Global.WEBVIEW_MULTIPROCESS, 0) | 237 if (BuildInfo.isAtLeastO()) { |
230 == 1) { | 238 // Ask the system if multiprocess should be enabled on O+. |
| 239 multiProcess = mWebViewDelegate.isMultiProcessEnabled(); |
| 240 } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| 241 // Check the multiprocess developer setting directly on N. |
| 242 multiProcess = Settings.Global.getInt( |
| 243 ContextUtils.getApplicationContext().getContentResolver(), |
| 244 Settings.Global.WEBVIEW_MULTIPROCESS, 0) == 1; |
| 245 } |
| 246 if (multiProcess) { |
231 CommandLine cl = CommandLine.getInstance(); | 247 CommandLine cl = CommandLine.getInstance(); |
232 cl.appendSwitch("webview-sandboxed-renderer"); | 248 cl.appendSwitch("webview-sandboxed-renderer"); |
233 } | 249 } |
234 | 250 |
235 ThreadUtils.setWillOverrideUiThread(); | 251 ThreadUtils.setWillOverrideUiThread(); |
236 // Load chromium library. | 252 // Load chromium library. |
237 AwBrowserProcess.loadLibrary(); | 253 AwBrowserProcess.loadLibrary(); |
238 | 254 |
239 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); | 255 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); |
240 | 256 |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 WebViewDelegate getWebViewDelegate() { | 687 WebViewDelegate getWebViewDelegate() { |
672 return mWebViewDelegate; | 688 return mWebViewDelegate; |
673 } | 689 } |
674 | 690 |
675 // The method to support unreleased Android. | 691 // The method to support unreleased Android. |
676 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV
iew, | 692 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV
iew, |
677 Context context) { | 693 Context context) { |
678 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega
te); | 694 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega
te); |
679 } | 695 } |
680 } | 696 } |
OLD | NEW |