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

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

Issue 1917193003: Revert of 🍈 Unify application context usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/javatests/src/org/chromium/android_webview/test/AwTestBase.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 5a2dcb749deabab5ca94652ccc6999ca9c28fbe5..8770d3a777725d80ca9e4cd8be905d9fa0410ee8 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
@@ -86,6 +86,7 @@
private WebStorageAdapter mWebStorage;
private WebViewDatabaseAdapter mWebViewDatabase;
private AwDevToolsServer mDevToolsServer;
+ private Context mWrappedAppContext;
private ArrayList<WeakReference<WebViewChromium>> mWebViewsToStart =
new ArrayList<WeakReference<WebViewChromium>>();
@@ -114,11 +115,6 @@
@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
private void initialize(WebViewDelegate webViewDelegate) {
mWebViewDelegate = webViewDelegate;
-
- // WebView needs to make sure to always use the wrapped application context.
- ContextUtils.initApplicationContext(
- ResourcesContextWrapperFactory.get(mWebViewDelegate.getApplication()));
-
if (isBuildDebuggable()) {
// Suppress the StrictMode violation as this codepath is only hit on debugglable builds.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
@@ -130,7 +126,7 @@
ThreadUtils.setWillOverrideUiThread();
// Load chromium library.
- AwBrowserProcess.loadLibrary(ContextUtils.getApplicationContext());
+ AwBrowserProcess.loadLibrary(getWrappedCurrentApplicationContext());
final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo();
@@ -244,7 +240,7 @@
return;
}
- Context context = ContextUtils.getApplicationContext();
+ Context context = getWrappedCurrentApplicationContext();
try {
LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitialized(context);
} catch (ProcessInitException e) {
@@ -302,6 +298,14 @@
}
}
+ private Context getWrappedCurrentApplicationContext() {
+ if (mWrappedAppContext == null) {
+ mWrappedAppContext = ResourcesContextWrapperFactory.get(
+ mWebViewDelegate.getApplication());
+ }
+ return mWrappedAppContext;
+ }
+
AwBrowserContext getBrowserContext() {
synchronized (mLock) {
return getBrowserContextLocked();
@@ -313,7 +317,7 @@
assert mStarted;
if (mBrowserContext == null) {
mBrowserContext =
- new AwBrowserContext(mWebViewPrefs, ContextUtils.getApplicationContext());
+ new AwBrowserContext(mWebViewPrefs, getWrappedCurrentApplicationContext());
}
return mBrowserContext;
}
@@ -423,6 +427,13 @@
public CookieManager getCookieManager() {
synchronized (mLock) {
if (mCookieManager == null) {
+ if (!mStarted) {
+ // We can use CookieManager without starting Chromium; the native code
+ // will bring up just the parts it needs to make this work on a temporary
+ // basis until Chromium is started for real. The temporary cookie manager
+ // needs the application context to have been set.
+ ContextUtils.initApplicationContext(getWrappedCurrentApplicationContext());
+ }
mCookieManager = new CookieManagerAdapter(new AwCookieManager());
}
}
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698