Chromium Code Reviews| 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; |
| 11 import android.content.Intent; | 11 import android.content.Intent; |
| 12 import android.content.SharedPreferences; | 12 import android.content.SharedPreferences; |
| 13 import android.content.pm.PackageInfo; | 13 import android.content.pm.PackageInfo; |
| 14 import android.content.pm.PackageManager; | 14 import android.content.pm.PackageManager; |
| 15 import android.net.Uri; | 15 import android.net.Uri; |
| 16 import android.os.Build; | 16 import android.os.Build; |
| 17 import android.os.Looper; | 17 import android.os.Looper; |
| 18 import android.os.Process; | 18 import android.os.Process; |
| 19 import android.os.StrictMode; | 19 import android.os.StrictMode; |
| 20 import android.os.UserManager; | 20 import android.os.UserManager; |
| 21 import android.provider.Settings; | |
| 22 import android.util.Log; | 21 import android.util.Log; |
| 23 import android.webkit.CookieManager; | 22 import android.webkit.CookieManager; |
| 24 import android.webkit.GeolocationPermissions; | 23 import android.webkit.GeolocationPermissions; |
| 25 import android.webkit.ServiceWorkerController; | 24 import android.webkit.ServiceWorkerController; |
| 26 import android.webkit.TokenBindingService; | 25 import android.webkit.TokenBindingService; |
| 27 import android.webkit.ValueCallback; | 26 import android.webkit.ValueCallback; |
| 28 import android.webkit.WebStorage; | 27 import android.webkit.WebStorage; |
| 29 import android.webkit.WebView; | 28 import android.webkit.WebView; |
| 30 import android.webkit.WebViewDatabase; | 29 import android.webkit.WebViewDatabase; |
| 31 import android.webkit.WebViewFactory; | 30 import android.webkit.WebViewFactory; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 initialize(WebViewDelegateFactory.createApi21CompatibilityDelegate()); | 189 initialize(WebViewDelegateFactory.createApi21CompatibilityDelegate()); |
| 191 } | 190 } |
| 192 | 191 |
| 193 /** | 192 /** |
| 194 * Constructor called by the API 22 version of {@link WebViewFactory} and la ter. | 193 * Constructor called by the API 22 version of {@link WebViewFactory} and la ter. |
| 195 */ | 194 */ |
| 196 public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegat e) { | 195 public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegat e) { |
| 197 initialize(WebViewDelegateFactory.createProxyDelegate(delegate)); | 196 initialize(WebViewDelegateFactory.createProxyDelegate(delegate)); |
| 198 } | 197 } |
| 199 | 198 |
| 199 /** | |
| 200 * Constructor for internal use when a proxy delegate has already been creat ed. | |
| 201 */ | |
| 202 WebViewChromiumFactoryProvider(WebViewDelegate delegate) { | |
|
Torne
2017/01/23 16:09:16
This allows the subclass version of create() to cr
boliu
2017/01/23 16:34:18
protected?
Torne
2017/01/23 17:27:30
No point; the downstream version is in the same pa
boliu
2017/01/23 17:44:04
oh.. package is actually more strict than protecte
| |
| 203 initialize(delegate); | |
| 204 } | |
| 205 | |
| 200 @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") | 206 @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") |
| 201 private void initialize(WebViewDelegate webViewDelegate) { | 207 private void initialize(WebViewDelegate webViewDelegate) { |
| 202 mWebViewDelegate = webViewDelegate; | 208 mWebViewDelegate = webViewDelegate; |
| 203 Context ctx = mWebViewDelegate.getApplication().getApplicationContext(); | 209 Context ctx = mWebViewDelegate.getApplication().getApplicationContext(); |
| 204 | 210 |
| 205 // If the application context is DE, but we have credentials, use a CE c ontext instead | 211 // If the application context is DE, but we have credentials, use a CE c ontext instead |
| 206 try { | 212 try { |
| 207 checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication()); | 213 checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication()); |
| 208 } catch (IllegalArgumentException e) { | 214 } catch (IllegalArgumentException e) { |
| 209 if (!ctx.getSystemService(UserManager.class).isUserUnlocked()) { | 215 if (!ctx.getSystemService(UserManager.class).isUserUnlocked()) { |
| 210 throw e; | 216 throw e; |
| 211 } | 217 } |
| 212 ctx = ctx.createCredentialProtectedStorageContext(); | 218 ctx = ctx.createCredentialProtectedStorageContext(); |
| 213 } | 219 } |
| 214 | 220 |
| 215 // WebView needs to make sure to always use the wrapped application cont ext. | 221 // WebView needs to make sure to always use the wrapped application cont ext. |
| 216 ContextUtils.initApplicationContext(ResourcesContextWrapperFactory.get(c tx)); | 222 ContextUtils.initApplicationContext(ResourcesContextWrapperFactory.get(c tx)); |
| 217 | 223 |
| 218 if (isBuildDebuggable()) { | 224 if (isBuildDebuggable()) { |
| 219 // Suppress the StrictMode violation as this codepath is only hit on debuggable builds. | 225 // Suppress the StrictMode violation as this codepath is only hit on debuggable builds. |
| 220 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( ); | 226 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( ); |
| 221 CommandLine.initFromFile(COMMAND_LINE_FILE); | 227 CommandLine.initFromFile(COMMAND_LINE_FILE); |
| 222 StrictMode.setThreadPolicy(oldPolicy); | 228 StrictMode.setThreadPolicy(oldPolicy); |
| 223 } else { | 229 } else { |
| 224 CommandLine.init(null); | 230 CommandLine.init(null); |
| 225 } | 231 } |
| 226 | 232 |
| 227 if (Settings.Global.getInt(ContextUtils.getApplicationContext().getConte ntResolver(), | 233 if (mWebViewDelegate.isMultiProcessEnabled()) { |
| 228 Settings.Global.WEBVIEW_MULTIPROCESS, 0) | |
| 229 == 1) { | |
| 230 CommandLine cl = CommandLine.getInstance(); | 234 CommandLine cl = CommandLine.getInstance(); |
| 231 cl.appendSwitch("webview-sandboxed-renderer"); | 235 cl.appendSwitch("webview-sandboxed-renderer"); |
| 232 } | 236 } |
| 233 | 237 |
| 234 ThreadUtils.setWillOverrideUiThread(); | 238 ThreadUtils.setWillOverrideUiThread(); |
| 235 // Load chromium library. | 239 // Load chromium library. |
| 236 AwBrowserProcess.loadLibrary(); | 240 AwBrowserProcess.loadLibrary(); |
| 237 | 241 |
| 238 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); | 242 final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo(); |
| 239 | 243 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 WebViewDelegate getWebViewDelegate() { | 673 WebViewDelegate getWebViewDelegate() { |
| 670 return mWebViewDelegate; | 674 return mWebViewDelegate; |
| 671 } | 675 } |
| 672 | 676 |
| 673 // The method to support unreleased Android. | 677 // The method to support unreleased Android. |
| 674 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV iew, | 678 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV iew, |
| 675 Context context) { | 679 Context context) { |
| 676 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega te); | 680 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega te); |
| 677 } | 681 } |
| 678 } | 682 } |
| OLD | NEW |