Commit 18dad595 authored by ntfschr's avatar ntfschr Committed by Commit bot

Android webview tries to switch to CE context

If Webview is started in an application using
defaultToDeviceProtectedStorage="true", it will first try to switch to a CE
context. If it's unable to switch contexts, it throws an exception.

BUG=645921

Review-Url: https://codereview.chromium.org/2339343002
Cr-Commit-Position: refs/heads/master@{#420730}
parent 55aecbf3
...@@ -18,6 +18,7 @@ import android.os.Build; ...@@ -18,6 +18,7 @@ import android.os.Build;
import android.os.Looper; import android.os.Looper;
import android.os.Process; import android.os.Process;
import android.os.StrictMode; import android.os.StrictMode;
import android.os.UserManager;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import android.webkit.CookieManager; import android.webkit.CookieManager;
...@@ -198,13 +199,20 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { ...@@ -198,13 +199,20 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
private void initialize(WebViewDelegate webViewDelegate) { private void initialize(WebViewDelegate webViewDelegate) {
mWebViewDelegate = 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. // WebView needs to make sure to always use the wrapped application context.
ContextUtils.initApplicationContext( ContextUtils.initApplicationContext(ResourcesContextWrapperFactory.get(ctx));
ResourcesContextWrapperFactory.get(
mWebViewDelegate.getApplication().getApplicationContext()));
if (isBuildDebuggable()) { if (isBuildDebuggable()) {
// Suppress the StrictMode violation as this codepath is only hit on debuggable builds. // Suppress the StrictMode violation as this codepath is only hit on debuggable builds.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment