summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2009-09-22 14:59:46 -0400
committerDerek Sollenberger <djsollen@google.com>2009-09-22 16:07:58 -0400
commite23a6d30242a5dbcdce40e708e0f97b21d06c2af (patch)
tree1b1d6a8340d902c0ee79be227c2afbb330eb03e0
parentc6fbc06882c120f5f51090203775eb0421550d13 (diff)
downloadexternal_webkit-e23a6d30242a5dbcdce40e708e0f97b21d06c2af.zip
external_webkit-e23a6d30242a5dbcdce40e708e0f97b21d06c2af.tar.gz
external_webkit-e23a6d30242a5dbcdce40e708e0f97b21d06c2af.tar.bz2
adding API to enable plugins to request full screen mode
Change-Id: Ib3373af6ff127399d1d0846ba30a4275da5b3133
-rw-r--r--WebKit/android/jni/WebViewCore.cpp21
-rw-r--r--WebKit/android/jni/WebViewCore.h8
-rw-r--r--WebKit/android/plugins/ANPWindowInterface.cpp6
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp54
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h6
-rw-r--r--WebKit/android/plugins/android_npapi.h5
6 files changed, 62 insertions, 38 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 07e7633..0885c07 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -183,6 +183,7 @@ struct WebViewCore::JavaGlue {
jmethodID m_geolocationPermissionsShowPrompt;
jmethodID m_geolocationPermissionsHidePrompt;
jmethodID m_addMessageToConsole;
+ jmethodID m_startFullScreenPluginActivity;
jmethodID m_createSurface;
jmethodID m_destroySurface;
AutoJObject object(JNIEnv* env) {
@@ -257,6 +258,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_geolocationPermissionsShowPrompt = GetJMethod(env, clazz, "geolocationPermissionsShowPrompt", "(Ljava/lang/String;)V");
m_javaGlue->m_geolocationPermissionsHidePrompt = GetJMethod(env, clazz, "geolocationPermissionsHidePrompt", "()V");
m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;)V");
+ m_javaGlue->m_startFullScreenPluginActivity = GetJMethod(env, clazz, "startFullScreenPluginActivity", "(Ljava/lang/String;Ljava/lang/String;I)V");
m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(Ljava/lang/String;Ljava/lang/String;IIIII)Landroid/webkit/ViewManager$ChildView;");
m_javaGlue->m_destroySurface = GetJMethod(env, clazz, "destroySurface", "(Landroid/webkit/ViewManager$ChildView;)V");
@@ -2189,15 +2191,28 @@ void WebViewCore::setBackgroundColor(SkColor c)
view->setBaseBackgroundColor(bcolor);
}
-jobject WebViewCore::createSurface(const char* packageName, const char* className,
+void WebViewCore::startFullScreenPluginActivity(const char* libName,
+ const char* className, NPP npp)
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+
+ jstring libString = env->NewStringUTF(libName);
+ jstring classString = env->NewStringUTF(className);
+ env->CallVoidMethod(m_javaGlue->object(env).get(),
+ m_javaGlue->m_startFullScreenPluginActivity,
+ libString, classString, (int) npp);
+ checkException(env);
+}
+
+jobject WebViewCore::createSurface(const char* libName, const char* className,
NPP npp, int x, int y, int width, int height)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
- jstring packageString = env->NewStringUTF(packageName);
+ jstring libString = env->NewStringUTF(libName);
jstring classString = env->NewStringUTF(className);
jobject result = env->CallObjectMethod(m_javaGlue->object(env).get(),
- m_javaGlue->m_createSurface, packageString,
+ m_javaGlue->m_createSurface, libString,
classString,(int) npp, x, y, width, height);
checkException(env);
return result;
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index cf1d21f..7dd8763 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -365,8 +365,12 @@ namespace android {
// Notify the Java side that webkit is requesting a keyboard
void requestKeyboard(bool);
- // Creates a SurfaceView for a plugin
- jobject createSurface(const char* packageName, const char* className,
+ // Creates a full screen surface (i.e. View on an Activity) for a plugin
+ void startFullScreenPluginActivity(const char* libName,
+ const char* className, NPP npp);
+
+ // Creates a Surface (i.e. View) for a plugin
+ jobject createSurface(const char* libName, const char* className,
NPP npp, int x, int y, int width, int height);
// Destroys a SurfaceView for a plugin
diff --git a/WebKit/android/plugins/ANPWindowInterface.cpp b/WebKit/android/plugins/ANPWindowInterface.cpp
index 41e00e9..7a2f94c 100644
--- a/WebKit/android/plugins/ANPWindowInterface.cpp
+++ b/WebKit/android/plugins/ANPWindowInterface.cpp
@@ -73,6 +73,11 @@ static void anp_showKeyboard(NPP instance, bool value) {
core->requestKeyboard(value);
}
+static void anp_requestFullScreen(NPP instance) {
+ PluginView* pluginView = pluginViewForInstance(instance);
+ pluginView->platformPluginWidget()->requestFullScreenMode();
+}
+
///////////////////////////////////////////////////////////////////////////////
#define ASSIGN(obj, name) (obj)->name = anp_##name
@@ -86,5 +91,6 @@ void ANPWindowInterfaceV0_Init(ANPInterface* value) {
ASSIGN(i, clearVisibleRects);
ASSIGN(i, showKeyboard);
ASSIGN(i, unlock);
+ ASSIGN(i, requestFullScreen);
}
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 81e9650..fdc4016 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -34,6 +34,7 @@
#include "ScrollView.h"
#include "SkANP.h"
#include "SkFlipPixelRef.h"
+#include "SkString.h"
#include "WebViewCore.h"
PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
@@ -75,48 +76,21 @@ static SkBitmap::Config computeConfig(bool isTransparent) {
: SkBitmap::kRGB_565_Config;
}
-/*
- * Returns the name of the apk that contains this plugin. The caller is
- * responsible for calling free(...) on the char* that is returned.
- */
-static char* getPackageName(PluginPackage* pluginPackage) {
-
- // get the directory where the plugin library is stored. The structure of
- // the path looks like /data/app/plugin.package.name/lib.
- const char* pluginDir = pluginPackage->parentDirectory().latin1().data();
-
- // trim "/lib" off the directory name and store in tempString
- int length = strlen(pluginDir) - 4; // -4 for "/lib"
- char* tempString = (char*) malloc(length + 1); // +1 for null termination
- strncpy(tempString, pluginDir, length);
- tempString[length] = '\0';
-
- // find the final '/' in tempString
- char* result = strrchr(tempString, '/');
-
- char* packageName = NULL;
- if (result) {
- // duplicate the tempString without the leading '/'
- packageName = strdup(result+1);
- }
-
- // free extra memory and return the package name
- free(tempString);
- return packageName;
-}
-
void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
m_pluginWindow = window;
if (m_drawingModel == kSurface_ANPDrawingModel) {
if (!m_childView) {
IntPoint docPoint = frameToDocumentCoords(window->x, window->y);
- char* packageName = getPackageName(m_pluginView->plugin());
- m_childView = m_core->createSurface(packageName, m_javaClassName,
+
+ const String& libName = m_pluginView->plugin()->path();
+ SkString skLibName;
+ skLibName.setUTF16(libName.characters(), libName.length());
+
+ m_childView = m_core->createSurface(skLibName.c_str(), m_javaClassName,
m_pluginView->instance(),
docPoint.x(), docPoint.y(),
window->width, window->height);
- free(packageName);
}
} else {
m_flipPixelRef->safeUnref();
@@ -142,6 +116,20 @@ bool PluginWidgetAndroid::setPluginStubJavaClassName(const char* className) {
return (m_javaClassName != NULL);
}
+void PluginWidgetAndroid::requestFullScreenMode() {
+
+ if (!m_javaClassName) {
+ return;
+ }
+
+ const String& libName = m_pluginView->plugin()->path();
+ SkString skLibName;
+ skLibName.setUTF16(libName.characters(), libName.length());
+
+ m_core->startFullScreenPluginActivity(skLibName.c_str(), m_javaClassName,
+ m_pluginView->instance());
+}
+
bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) {
// disallow the surface drawing model if no java class name has been given
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index aaf6f96..9fc2209 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -131,6 +131,12 @@ struct PluginWidgetAndroid {
*/
void setVisibleRects(const ANPRectI rects[], int32_t count);
+ /** Called when a plugin wishes to enter into full screen mode. The plugin's
+ Java class (set using setPluginStubJavaClassName(...)) will be called
+ asynchronously to provide a View to be displayed in full screen.
+ */
+ void requestFullScreenMode();
+
private:
WebCore::IntPoint frameToDocumentCoords(int frameX, int frameY) const;
void computeVisibleFrameRect();
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 5218031..95ab889 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -659,6 +659,11 @@ struct ANPWindowInterfaceV0 : ANPInterface {
physical keyboard is active.
*/
void (*showKeyboard)(NPP instance, bool value);
+ /** Called when a plugin wishes to enter into full screen mode. The plugin's
+ Java class (set using kSetPluginStubJavaClassName_ANPSetValue) will be
+ called asynchronously to provide a View object to be displayed full screen.
+ */
+ void (*requestFullScreen)(NPP instance);
};
///////////////////////////////////////////////////////////////////////////////