summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/jni')
-rw-r--r--WebKit/android/jni/WebSettings.cpp18
-rw-r--r--WebKit/android/jni/WebViewCore.cpp21
-rw-r--r--WebKit/android/jni/WebViewCore.h4
3 files changed, 38 insertions, 5 deletions
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp
index 91ed8cc..70ecded 100644
--- a/WebKit/android/jni/WebSettings.cpp
+++ b/WebKit/android/jni/WebSettings.cpp
@@ -83,7 +83,8 @@ struct FieldIds {
mBlockNetworkImage = env->GetFieldID(clazz, "mBlockNetworkImage", "Z");
#endif
mJavaScriptEnabled = env->GetFieldID(clazz, "mJavaScriptEnabled", "Z");
- mPluginsEnabled = env->GetFieldID(clazz, "mPluginsEnabled", "Z");
+ mPluginState = env->GetFieldID(clazz, "mPluginState",
+ "Landroid/webkit/WebSettings$PluginState;");
#if ENABLE(DATABASE)
mDatabaseEnabled = env->GetFieldID(clazz, "mDatabaseEnabled", "Z");
#endif
@@ -133,7 +134,7 @@ struct FieldIds {
LOG_ASSERT(mBlockNetworkImage, "Could not find field mBlockNetworkImage");
#endif
LOG_ASSERT(mJavaScriptEnabled, "Could not find field mJavaScriptEnabled");
- LOG_ASSERT(mPluginsEnabled, "Could not find field mPluginsEnabled");
+ LOG_ASSERT(mPluginState, "Could not find field mPluginState");
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
LOG_ASSERT(mAppCacheEnabled, "Could not find field mAppCacheEnabled");
LOG_ASSERT(mAppCachePath, "Could not find field mAppCachePath");
@@ -179,7 +180,7 @@ struct FieldIds {
jfieldID mBlockNetworkImage;
#endif
jfieldID mJavaScriptEnabled;
- jfieldID mPluginsEnabled;
+ jfieldID mPluginState;
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
jfieldID mAppCacheEnabled;
jfieldID mAppCachePath;
@@ -313,8 +314,15 @@ public:
flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptEnabled);
s->setJavaScriptEnabled(flag);
- flag = env->GetBooleanField(obj, gFieldIds->mPluginsEnabled);
- s->setPluginsEnabled(flag);
+ // ON = 0
+ // ON_DEMAND = 1
+ // OFF = 2
+ jobject pluginState = env->GetObjectField(obj, gFieldIds->mPluginState);
+ int state = env->CallIntMethod(pluginState, gFieldIds->mOrdinal);
+ s->setPluginsEnabled(state < 2);
+#ifdef ANDROID_PLUGINS
+ s->setPluginsOnDemand(state == 1);
+#endif
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled);
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index a0e4642..00ac725 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -168,6 +168,27 @@ bool WebViewCore::isInstance(WebViewCore* inst) {
return gInstanceList.find(inst) >= 0;
}
+jobject WebViewCore::getApplicationContext() {
+
+ // check to see if there is a valid webviewcore object
+ if (gInstanceList.isEmpty())
+ return 0;
+
+ // get the context from the webview
+ jobject context = gInstanceList[0]->getContext();
+
+ if (!context)
+ return 0;
+
+ // get the application context using JNI
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ jclass contextClass = env->GetObjectClass(context);
+ jmethodID appContextMethod = env->GetMethodID(contextClass, "getApplicationContext", "()Landroid/content/Context;");
+ jobject result = env->CallObjectMethod(context, appContextMethod);
+ checkException(env);
+ return result;
+}
+
// ----------------------------------------------------------------------------
#define GET_NATIVE_VIEW(env, obj) ((WebViewCore*)env->GetIntField(obj, gWebViewCoreFields.m_nativeClass))
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index abe0d8d..8c885e6 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -569,6 +569,10 @@ namespace android {
// call only from webkit thread (like add/remove), return true if inst
// is still alive
static bool isInstance(WebViewCore*);
+
+ // if there exists at least on WebViewCore instance then we return the
+ // application context, otherwise NULL is returned.
+ static jobject getApplicationContext();
};
} // namespace android