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

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

Issue 2076623002: 🍳 Fix and clean up application context in webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wrap context. Created 4 years, 6 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 | android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java » ('j') | 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 78d1bdcabeb8e39be0ff8ac08e014620d0efb23a..99381b28ff88e9ac77f1467db6b1505f5eaa08a3 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
@@ -118,10 +118,11 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
// WebView needs to make sure to always use the wrapped application context.
ContextUtils.initApplicationContext(
- ResourcesContextWrapperFactory.get(mWebViewDelegate.getApplication()));
+ ResourcesContextWrapperFactory.get(
+ mWebViewDelegate.getApplication().getApplicationContext()));
if (isBuildDebuggable()) {
- // Suppress the StrictMode violation as this codepath is only hit on debugglable builds.
+ // Suppress the StrictMode violation as this codepath is only hit on debuggable builds.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
CommandLine.initFromFile(COMMAND_LINE_FILE);
StrictMode.setThreadPolicy(oldPolicy);
@@ -131,7 +132,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
ThreadUtils.setWillOverrideUiThread();
// Load chromium library.
- AwBrowserProcess.loadLibrary(ContextUtils.getApplicationContext());
+ AwBrowserProcess.loadLibrary();
final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo();
@@ -139,14 +140,14 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
System.loadLibrary("webviewchromium_plat_support");
// Use shared preference to check for package downgrade.
- mWebViewPrefs = mWebViewDelegate.getApplication().getSharedPreferences(
+ mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE);
int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0);
int currentVersion = packageInfo.versionCode;
if (!versionCodeGE(currentVersion, lastVersion)) {
// The WebView package has been downgraded since we last ran in this application.
// Delete the WebView data directory's contents.
- String dataDir = PathUtils.getDataDirectory(mWebViewDelegate.getApplication());
+ String dataDir = PathUtils.getDataDirectory(ContextUtils.getApplicationContext());
Log.i(TAG, "WebView package downgraded from " + lastVersion + " to " + currentVersion
+ "; deleting contents of " + dataDir);
deleteContents(new File(dataDir));
@@ -286,7 +287,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
initNetworkChangeNotifier(context);
final int extraBindFlags = 0;
AwBrowserProcess.configureChildProcessLauncher(webViewPackageName, extraBindFlags);
- AwBrowserProcess.start(context);
+ AwBrowserProcess.start();
if (isBuildDebuggable()) {
setWebContentsDebuggingEnabled(true);
@@ -313,7 +314,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
// Start listening for data reduction proxy setting changes.
mProxyManager = new AwDataReductionProxyManager();
- mProxyManager.start(mWebViewDelegate.getApplication());
+ mProxyManager.start(ContextUtils.getApplicationContext());
}
boolean hasStarted() {
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698