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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.content.pm.PackageManager.NameNotFoundException; 15 import android.content.pm.PackageManager.NameNotFoundException;
16 import android.net.Uri; 16 import android.net.Uri;
17 import android.os.Build; 17 import android.os.Build;
18 import android.os.Looper; 18 import android.os.Looper;
19 import android.os.Process; 19 import android.os.Process;
20 import android.os.StrictMode; 20 import android.os.StrictMode;
21 import android.os.UserManager;
21 import android.provider.Settings; 22 import android.provider.Settings;
22 import android.util.Log; 23 import android.util.Log;
23 import android.webkit.CookieManager; 24 import android.webkit.CookieManager;
24 import android.webkit.GeolocationPermissions; 25 import android.webkit.GeolocationPermissions;
25 import android.webkit.ServiceWorkerController; 26 import android.webkit.ServiceWorkerController;
26 import android.webkit.TokenBindingService; 27 import android.webkit.TokenBindingService;
27 import android.webkit.WebStorage; 28 import android.webkit.WebStorage;
28 import android.webkit.WebView; 29 import android.webkit.WebView;
29 import android.webkit.WebViewDatabase; 30 import android.webkit.WebViewDatabase;
30 import android.webkit.WebViewFactory; 31 import android.webkit.WebViewFactory;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 /** 192 /**
192 * 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.
193 */ 194 */
194 public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegat e) { 195 public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegat e) {
195 initialize(WebViewDelegateFactory.createProxyDelegate(delegate)); 196 initialize(WebViewDelegateFactory.createProxyDelegate(delegate));
196 } 197 }
197 198
198 @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") 199 @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
199 private void initialize(WebViewDelegate webViewDelegate) { 200 private void initialize(WebViewDelegate webViewDelegate) {
200 mWebViewDelegate = webViewDelegate; 201 mWebViewDelegate = webViewDelegate;
202 Context ctx = mWebViewDelegate.getApplication().getApplicationContext();
201 203
202 checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication()); 204 // If the application context is DE, but we have credentials, use a CE c ontext instead
205 try {
206 checkStorageIsNotDeviceProtected(mWebViewDelegate.getApplication());
207 } catch (IllegalArgumentException e) {
208 if (!ctx.getSystemService(UserManager.class).isUserUnlocked()) {
209 throw e;
210 }
211 ctx = ctx.createCredentialProtectedStorageContext();
212 }
203 213
204 // WebView needs to make sure to always use the wrapped application cont ext. 214 // WebView needs to make sure to always use the wrapped application cont ext.
205 ContextUtils.initApplicationContext( 215 ContextUtils.initApplicationContext(ResourcesContextWrapperFactory.get(c tx));
206 ResourcesContextWrapperFactory.get(
207 mWebViewDelegate.getApplication().getApplicationContext( )));
208 216
209 if (isBuildDebuggable()) { 217 if (isBuildDebuggable()) {
210 // Suppress the StrictMode violation as this codepath is only hit on debuggable builds. 218 // Suppress the StrictMode violation as this codepath is only hit on debuggable builds.
211 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( ); 219 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( );
212 CommandLine.initFromFile(COMMAND_LINE_FILE); 220 CommandLine.initFromFile(COMMAND_LINE_FILE);
213 StrictMode.setThreadPolicy(oldPolicy); 221 StrictMode.setThreadPolicy(oldPolicy);
214 } else { 222 } else {
215 CommandLine.init(null); 223 CommandLine.init(null);
216 } 224 }
217 225
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 mWebViewDatabase = new WebViewDatabaseAdapter(this, awDatabase); 654 mWebViewDatabase = new WebViewDatabaseAdapter(this, awDatabase);
647 } 655 }
648 } 656 }
649 return mWebViewDatabase; 657 return mWebViewDatabase;
650 } 658 }
651 659
652 WebViewDelegate getWebViewDelegate() { 660 WebViewDelegate getWebViewDelegate() {
653 return mWebViewDelegate; 661 return mWebViewDelegate;
654 } 662 }
655 } 663 }
OLDNEW
« 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