summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2009-09-21 09:13:10 -0400
committerDerek Sollenberger <djsollen@google.com>2009-09-21 10:54:50 -0400
commit19d8bd10cbc60aee378a8762c27b264a4813445b (patch)
tree7f415c798ddb6d04e3a038135c2d58551e2df9d0
parent0a7f28613ad5aaf5cfda9454b2dc4c95cf53c3d0 (diff)
downloadexternal_webkit-19d8bd10cbc60aee378a8762c27b264a4813445b.zip
external_webkit-19d8bd10cbc60aee378a8762c27b264a4813445b.tar.gz
external_webkit-19d8bd10cbc60aee378a8762c27b264a4813445b.tar.bz2
renaming setJavaClass_ANPSetValue and ensuring memory is freed on subsequent calls
Change-Id: I7881e711af7ec905e5c120e8e2fd4b0b7ba5e840
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp4
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp14
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h5
-rw-r--r--WebKit/android/plugins/android_npapi.h12
4 files changed, 27 insertions, 8 deletions
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 1815a9e..d98ccef 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -482,9 +482,9 @@ NPError PluginView::platformSetValue(NPPVariable variable, void* value)
NPError error = NPERR_GENERIC_ERROR;
switch (variable) {
- case kSetJavaClassName_ANPSetValue: {
+ case kSetPluginStubJavaClassName_ANPSetValue: {
char* className = reinterpret_cast<char*>(value);
- if (m_window->setJavaClassName(className))
+ if (m_window->setPluginStubJavaClassName(className))
error = NPERR_NO_ERROR;
break;
}
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 6318276..81e9650 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -125,7 +125,19 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
}
}
-bool PluginWidgetAndroid::setJavaClassName(const char* className) {
+bool PluginWidgetAndroid::setPluginStubJavaClassName(const char* className) {
+
+ if (m_javaClassName) {
+ free(m_javaClassName);
+ }
+
+ // don't call strdup() if the className is to be set to NULL
+ if (!className) {
+ m_javaClassName = NULL;
+ return true;
+ }
+
+ // make a local copy of the className
m_javaClassName = strdup(className);
return (m_javaClassName != NULL);
}
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index af77aa9..aaf6f96 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -68,9 +68,10 @@ struct PluginWidgetAndroid {
void setWindow(NPWindow* window, bool isTransparent);
/* Called to notify us of the plugin's java class that implements the
- * PluginStub interface.
+ * PluginStub interface. A local copy is made of the className so the caller
+ * can safely free the memory as soon as the function returns.
*/
- bool setJavaClassName(const char* className);
+ bool setPluginStubJavaClassName(const char* className);
/* Called whenever the plugin itself requests a new drawing model. If the
hardware does not support the requested model then false is returned,
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 6688d00..5218031 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -139,11 +139,17 @@ typedef uint32_t ANPMatrixFlag;
/** Set the name of the Java class found in the plugin's apk that implements the
PluginStub interface. The value provided must be a null terminated char*
- that contains the fully qualified class name (e.g., your.package.className)
+ that contains the fully qualified class name (e.g., your.package.className).
+ A local copy is made of the char* so the caller can safely free the memory
+ as soon as the function returns.
- NPN_SetValue(inst, kSetJavaClassName_ANPSetValue, (void*)nullTerminatedChar*)
+ This value must be set prior to selecting the Surface_ANPDrawingModel or
+ requesting to enter full-screen mode.
+
+ NPN_SetValue(inst, kSetPluginStubJavaClassName_ANPSetValue,
+ (void*)nullTerminatedChar*)
*/
-#define kSetJavaClassName_ANPSetValue ((NPPVariable)1001)
+#define kSetPluginStubJavaClassName_ANPSetValue ((NPPVariable)1001)
/** These are used as bitfields in ANPSupportedDrawingModels_EnumValue,
and as-is in ANPRequestDrawingModel_EnumValue. The drawing model determines