diff options
author | Ben Murdoch <benm@google.com> | 2011-09-20 10:32:28 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-20 10:32:28 -0700 |
commit | f9580d594a489aab2a3bbaf8ffc1bdbbe3aaf8b6 (patch) | |
tree | 4cff3586a9ad8b4f5030a9ae627d83ba3cb0a92a /core/java/android | |
parent | c70f6af3a9359622ecf523ea2429e2a71553b7a2 (diff) | |
parent | 87af7314d4319a0ccaaf466a25e3fe4f416cc953 (diff) | |
download | frameworks_base-f9580d594a489aab2a3bbaf8ffc1bdbbe3aaf8b6.zip frameworks_base-f9580d594a489aab2a3bbaf8ffc1bdbbe3aaf8b6.tar.gz frameworks_base-f9580d594a489aab2a3bbaf8ffc1bdbbe3aaf8b6.tar.bz2 |
Merge "Cleanup for bug 5278763"
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/webkit/CookieSyncManager.java | 4 | ||||
-rw-r--r-- | core/java/android/webkit/JniUtil.java | 16 | ||||
-rw-r--r-- | core/java/android/webkit/WebView.java | 4 |
3 files changed, 15 insertions, 9 deletions
diff --git a/core/java/android/webkit/CookieSyncManager.java b/core/java/android/webkit/CookieSyncManager.java index 313f755..a699800 100644 --- a/core/java/android/webkit/CookieSyncManager.java +++ b/core/java/android/webkit/CookieSyncManager.java @@ -88,6 +88,10 @@ public final class CookieSyncManager extends WebSyncManager { */ public static synchronized CookieSyncManager createInstance( Context context) { + if (context == null) { + throw new IllegalArgumentException("Invalid context argument"); + } + JniUtil.setContext(context); Context appContext = context.getApplicationContext(); if (sRef == null) { diff --git a/core/java/android/webkit/JniUtil.java b/core/java/android/webkit/JniUtil.java index ef1641d..7759ff3 100644 --- a/core/java/android/webkit/JniUtil.java +++ b/core/java/android/webkit/JniUtil.java @@ -39,25 +39,21 @@ class JniUtil { private static Boolean sUseChromiumHttpStack; private static Context sContext; - private static boolean initialized = false; - private static void checkInitialized() { - if (!initialized) { + if (sContext == null) { throw new IllegalStateException("Call CookieSyncManager::createInstance() or create a webview before using this class"); } } protected static synchronized void setContext(Context context) { - if (initialized) + if (sContext != null) { return; + } sContext = context.getApplicationContext(); - initialized = true; } protected static synchronized Context getContext() { - if (!initialized) - return null; return sContext; } @@ -68,8 +64,9 @@ class JniUtil { private static synchronized String getDatabaseDirectory() { checkInitialized(); - if (sDatabaseDirectory == null) + if (sDatabaseDirectory == null) { sDatabaseDirectory = sContext.getDatabasePath("dummy").getParent(); + } return sDatabaseDirectory; } @@ -81,8 +78,9 @@ class JniUtil { private static synchronized String getCacheDirectory() { checkInitialized(); - if (sCacheDirectory == null) + if (sCacheDirectory == null) { sCacheDirectory = sContext.getCacheDir().getAbsolutePath(); + } return sCacheDirectory; } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index f57c6c4..122a717 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1055,6 +1055,10 @@ public class WebView extends AbsoluteLayout super(context, attrs, defStyle); checkThread(); + if (context == null) { + throw new IllegalArgumentException("Invalid context argument"); + } + // Used by the chrome stack to find application paths JniUtil.setContext(context); |