Merge "Cleanup for bug 5278763"
This commit is contained in:
@@ -88,6 +88,10 @@ public final class CookieSyncManager extends WebSyncManager {
|
|||||||
*/
|
*/
|
||||||
public static synchronized CookieSyncManager createInstance(
|
public static synchronized CookieSyncManager createInstance(
|
||||||
Context context) {
|
Context context) {
|
||||||
|
if (context == null) {
|
||||||
|
throw new IllegalArgumentException("Invalid context argument");
|
||||||
|
}
|
||||||
|
|
||||||
JniUtil.setContext(context);
|
JniUtil.setContext(context);
|
||||||
Context appContext = context.getApplicationContext();
|
Context appContext = context.getApplicationContext();
|
||||||
if (sRef == null) {
|
if (sRef == null) {
|
||||||
|
|||||||
@@ -39,25 +39,21 @@ class JniUtil {
|
|||||||
private static Boolean sUseChromiumHttpStack;
|
private static Boolean sUseChromiumHttpStack;
|
||||||
private static Context sContext;
|
private static Context sContext;
|
||||||
|
|
||||||
private static boolean initialized = false;
|
|
||||||
|
|
||||||
private static void checkInitialized() {
|
private static void checkInitialized() {
|
||||||
if (!initialized) {
|
if (sContext == null) {
|
||||||
throw new IllegalStateException("Call CookieSyncManager::createInstance() or create a webview before using this class");
|
throw new IllegalStateException("Call CookieSyncManager::createInstance() or create a webview before using this class");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static synchronized void setContext(Context context) {
|
protected static synchronized void setContext(Context context) {
|
||||||
if (initialized)
|
if (sContext != null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sContext = context.getApplicationContext();
|
sContext = context.getApplicationContext();
|
||||||
initialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static synchronized Context getContext() {
|
protected static synchronized Context getContext() {
|
||||||
if (!initialized)
|
|
||||||
return null;
|
|
||||||
return sContext;
|
return sContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +64,9 @@ class JniUtil {
|
|||||||
private static synchronized String getDatabaseDirectory() {
|
private static synchronized String getDatabaseDirectory() {
|
||||||
checkInitialized();
|
checkInitialized();
|
||||||
|
|
||||||
if (sDatabaseDirectory == null)
|
if (sDatabaseDirectory == null) {
|
||||||
sDatabaseDirectory = sContext.getDatabasePath("dummy").getParent();
|
sDatabaseDirectory = sContext.getDatabasePath("dummy").getParent();
|
||||||
|
}
|
||||||
|
|
||||||
return sDatabaseDirectory;
|
return sDatabaseDirectory;
|
||||||
}
|
}
|
||||||
@@ -81,8 +78,9 @@ class JniUtil {
|
|||||||
private static synchronized String getCacheDirectory() {
|
private static synchronized String getCacheDirectory() {
|
||||||
checkInitialized();
|
checkInitialized();
|
||||||
|
|
||||||
if (sCacheDirectory == null)
|
if (sCacheDirectory == null) {
|
||||||
sCacheDirectory = sContext.getCacheDir().getAbsolutePath();
|
sCacheDirectory = sContext.getCacheDir().getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
return sCacheDirectory;
|
return sCacheDirectory;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1055,6 +1055,10 @@ public class WebView extends AbsoluteLayout
|
|||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
checkThread();
|
checkThread();
|
||||||
|
|
||||||
|
if (context == null) {
|
||||||
|
throw new IllegalArgumentException("Invalid context argument");
|
||||||
|
}
|
||||||
|
|
||||||
// Used by the chrome stack to find application paths
|
// Used by the chrome stack to find application paths
|
||||||
JniUtil.setContext(context);
|
JniUtil.setContext(context);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user