summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2009-08-04 17:50:26 -0700
committerGrace Kloba <klobag@google.com>2009-08-05 10:04:35 -0700
commit0a2bed53555947aea37912d694f9c7c376490808 (patch)
tree2158bd03d8a4210f6c31df9a934eda22d3cfee28 /WebKit
parentf1c0bbb9bf698154c206e842f94b72d277a96094 (diff)
downloadexternal_webkit-0a2bed53555947aea37912d694f9c7c376490808.zip
external_webkit-0a2bed53555947aea37912d694f9c7c376490808.tar.gz
external_webkit-0a2bed53555947aea37912d694f9c7c376490808.tar.bz2
Add SystemInterface to the android_npapi so that we can expose system related
properties. Currently it only has getApplicationDataDirectory.
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/Android.mk1
-rw-r--r--WebKit/android/jni/JavaBridge.cpp16
-rw-r--r--WebKit/android/plugins/ANPSystemInterface.cpp72
-rw-r--r--WebKit/android/plugins/android_npapi.h11
4 files changed, 100 insertions, 0 deletions
diff --git a/WebKit/Android.mk b/WebKit/Android.mk
index 5e8bdbb..784326c 100644
--- a/WebKit/Android.mk
+++ b/WebKit/Android.mk
@@ -64,6 +64,7 @@ LOCAL_SRC_FILES := \
android/plugins/ANPPathInterface.cpp \
android/plugins/ANPSoundInterface.cpp \
android/plugins/ANPSurfaceInterface.cpp \
+ android/plugins/ANPSystemInterface.cpp \
android/plugins/ANPTypefaceInterface.cpp \
android/plugins/ANPWindowInterface.cpp \
android/plugins/PluginSurface.cpp \
diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp
index 7c4636f..3f9a056 100644
--- a/WebKit/android/jni/JavaBridge.cpp
+++ b/WebKit/android/jni/JavaBridge.cpp
@@ -76,6 +76,7 @@ public:
virtual bool cookiesEnabled();
virtual WTF::Vector<WebCore::String> getPluginDirectories();
+ virtual WebCore::String getPluginSharedDataDirectory();
virtual WTF::Vector<String> getSupportedKeyStrengthList();
virtual WebCore::String getSignedPublicKeyAndChallengeString(unsigned index,
@@ -107,6 +108,7 @@ private:
jmethodID mCookies;
jmethodID mCookiesEnabled;
jmethodID mGetPluginDirectories;
+ jmethodID mGetPluginSharedDataDirectory;
jmethodID mSignalFuncPtrQueue;
jmethodID mGetKeyStrengthList;
jmethodID mGetSignedPublicKey;
@@ -125,6 +127,7 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj)
mCookies = env->GetMethodID(clazz, "cookies", "(Ljava/lang/String;)Ljava/lang/String;");
mCookiesEnabled = env->GetMethodID(clazz, "cookiesEnabled", "()Z");
mGetPluginDirectories = env->GetMethodID(clazz, "getPluginDirectories", "()[Ljava/lang/String;");
+ mGetPluginSharedDataDirectory = env->GetMethodID(clazz, "getPluginSharedDataDirectory", "()Ljava/lang/String;");
mSignalFuncPtrQueue = env->GetMethodID(clazz, "signalServiceFuncPtrQueue", "()V");
mGetKeyStrengthList = env->GetMethodID(clazz, "getKeyStrengthList", "()[Ljava/lang/String;");
mGetSignedPublicKey = env->GetMethodID(clazz, "getSignedPublicKey", "(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
@@ -134,6 +137,8 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj)
LOG_ASSERT(mSetCookies, "Could not find method setCookies");
LOG_ASSERT(mCookies, "Could not find method cookies");
LOG_ASSERT(mCookiesEnabled, "Could not find method cookiesEnabled");
+ LOG_ASSERT(mGetPluginDirectories, "Could not find method getPluginDirectories");
+ LOG_ASSERT(mGetPluginSharedDataDirectory, "Could not find method getPluginSharedDataDirectory");
LOG_ASSERT(mGetKeyStrengthList, "Could not find method getKeyStrengthList");
LOG_ASSERT(mGetSignedPublicKey, "Could not find method getSignedPublicKey");
@@ -231,6 +236,17 @@ JavaBridge::getPluginDirectories()
return directories;
}
+WebCore::String
+JavaBridge::getPluginSharedDataDirectory()
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ AutoJObject obj = getRealObject(env, mJavaObject);
+ jstring ret = (jstring)env->CallObjectMethod(obj.get(), mGetPluginSharedDataDirectory);
+ WebCore::String path = to_string(env, ret);
+ checkException(env);
+ return path;
+}
+
void
JavaBridge::setSharedTimerCallback(void (*f)())
{
diff --git a/WebKit/android/plugins/ANPSystemInterface.cpp b/WebKit/android/plugins/ANPSystemInterface.cpp
new file mode 100644
index 0000000..a5b9bcb
--- /dev/null
+++ b/WebKit/android/plugins/ANPSystemInterface.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// must include config.h first for webkit to fiddle with new/delete
+#include "config.h"
+
+#include "android_npapi.h"
+#include "CString.h"
+#include "JavaSharedClient.h"
+#include "PluginClient.h"
+
+static const char* gApplicationDataDir = NULL;
+
+using namespace android;
+
+static const char* anp_getApplicationDataDirectory() {
+ if (NULL == gApplicationDataDir) {
+ PluginClient* client = JavaSharedClient::GetPluginClient();
+ if (!client)
+ return NULL;
+
+ WebCore::String path = client->getPluginSharedDataDirectory();
+ int length = path.length();
+ if (length == 0)
+ return NULL;
+
+ char* storage = (char*) malloc(length + 1);
+ if (NULL == storage)
+ return NULL;
+
+ memcpy(storage, path.utf8().data(), length);
+ storage[length] = '\0';
+
+ // save this assignment for last, so that if multiple threads call us
+ // (which should never happen), we never return an incomplete global.
+ // At worst, we would allocate storage for the path twice.
+ gApplicationDataDir = storage;
+ }
+ return gApplicationDataDir;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define ASSIGN(obj, name) (obj)->name = anp_##name
+
+void ANPSystemInterfaceV0_Init(ANPInterface* v) {
+ ANPSystemInterfaceV0* i = reinterpret_cast<ANPSystemInterfaceV0*>(v);
+
+ ASSIGN(i, getApplicationDataDirectory);
+}
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 0425e8e..47a7494 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -117,6 +117,7 @@ typedef uint32_t ANPMatrixFlag;
#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007)
#define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008)
#define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009)
+#define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010)
/* queries for which drawing model is desired (for the draw event)
@@ -871,5 +872,15 @@ struct ANPEvent {
} data;
};
+///////////////////////////////////////////////////////////////////////////////
+// System properties
+
+struct ANPSystemInterfaceV0 : ANPInterface {
+ /** Return the path name for the current Application's plugin data directory,
+ * or NULL if not supported
+ */
+ const char* (*getApplicationDataDirectory)();
+};
+
#endif