Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2847)

Unified Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java

Issue 2339343002: Android webview tries to switch to CE context (Closed)
Patch Set: Minor formatting changes Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
index 2ef597bfab1af55fa202d279a6c2850544ddf6dd..dc6d6bea05832d53f40b0c279467f9aca1d268dc 100644
--- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
+++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
@@ -18,6 +18,7 @@ import android.os.Build;
import android.os.Looper;
import android.os.Process;
import android.os.StrictMode;
+import android.os.UserManager;
import android.provider.Settings;
import android.util.Log;
import android.webkit.CookieManager;
@@ -198,13 +199,20 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
private void initialize(WebViewDelegate webViewDelegate) {
mWebViewDelegate = webViewDelegate;
+ Context ctx = mWebViewDelegate.getApplication().getApplicationContext();
- checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication());
+ // If the application context is DE, but we have credentials, use a CE context instead
+ try {
+ checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication());
+ } catch (IllegalArgumentException e) {
+ if (!ctx.getSystemService(UserManager.class).isUserUnlocked()) {
+ throw e;
+ }
+ ctx = ctx.createCredentialProtectedStorageContext();
+ }
// WebView needs to make sure to always use the wrapped application context.
- ContextUtils.initApplicationContext(
- ResourcesContextWrapperFactory.get(
- mWebViewDelegate.getApplication().getApplicationContext()));
+ ContextUtils.initApplicationContext(ResourcesContextWrapperFactory.get(ctx));
if (isBuildDebuggable()) {
// Suppress the StrictMode violation as this codepath is only hit on debuggable builds.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698