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

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: 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
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..26d9db6c20a0f125348a08bd443a82963402f046 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
@@ -199,7 +199,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
private void initialize(WebViewDelegate webViewDelegate) {
mWebViewDelegate = webViewDelegate;
- checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication());
+ switchStorageContextIfDeviceProtectedStorage(mWebViewDelegate.getApplication());
// WebView needs to make sure to always use the wrapped application context.
ContextUtils.initApplicationContext(
@@ -253,11 +253,16 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
// Now safe to use WebView data directory.
}
- static void checkStorageIsNotDeviceProtected(Context context) {
+ static void switchStorageContextIfDeviceProtectedStorage(Context context) {
if ((Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M)
&& context.isDeviceProtectedStorage()) {
- throw new IllegalArgumentException(
- "WebView cannot be used with device protected storage");
+ // Try to switch to a CE-protected context
+ try {
+ context.createCredentialProtectedStorageContext();
Torne 2016/09/15 10:15:59 This doesn't actually switch anything - you aren't
+ } catch (Exception e) {
+ throw new IllegalArgumentException(
+ "WebView cannot be used with device protected storage");
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698