diff options
author | Derek Sollenberger <djsollen@google.com> | 2010-03-23 14:07:05 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2010-03-23 14:34:09 -0400 |
commit | 27a298a6476fbd78e67f35441e1428bc878a969d (patch) | |
tree | ca631f680e2bc3b4c0a8d54ec3b6c983d4c1c26c /WebKit/android/jni/WebViewCore.cpp | |
parent | 7d7e576868fe78bf1b95968ad5d6ddc395c65ec9 (diff) | |
download | external_webkit-27a298a6476fbd78e67f35441e1428bc878a969d.zip external_webkit-27a298a6476fbd78e67f35441e1428bc878a969d.tar.gz external_webkit-27a298a6476fbd78e67f35441e1428bc878a969d.tar.bz2 |
Allowing native code access to the application context as long as
there is at least one valid instance of the webviewcore class.
This change allows plugins access to the application context when
the plugin package is loaded, prior to any instances of the plugin
being created.
Change-Id: I74a58cf76cc3c2d0ef7bca19346f13f58f616830
Diffstat (limited to 'WebKit/android/jni/WebViewCore.cpp')
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
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)) |