diff options
author | Mike Reed <reed@google.com> | 2009-05-26 16:35:00 -0400 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2009-05-28 08:59:58 -0400 |
commit | be9123233ec803662e74d4333c1aab0bb201bb84 (patch) | |
tree | 67ebf0636023f4f0b48b62a8681cd6e0e50ce77a | |
parent | ea2ac40c875b133ef9d88dfbbbb587364eac8e07 (diff) | |
download | external_webkit-be9123233ec803662e74d4333c1aab0bb201bb84.zip external_webkit-be9123233ec803662e74d4333c1aab0bb201bb84.tar.gz external_webkit-be9123233ec803662e74d4333c1aab0bb201bb84.tar.bz2 |
add pause/resume events for plugins
add sendEvent() api to widget
add jni pause/resume functions to be called from java
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 28 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 4 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 9 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 5 | ||||
-rw-r--r-- | WebKit/android/plugins/android_npapi.h | 10 |
5 files changed, 51 insertions, 5 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 823a30f..89013ff 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -81,6 +81,7 @@ #include "ResourceRequest.h" #include "SelectionController.h" #include "Settings.h" +#include "SkANP.h" #include "SkTemplates.h" #include "SkTypes.h" #include "SkCanvas.h" @@ -1194,6 +1195,15 @@ void WebViewCore::drawPlugins() } } +void WebViewCore::sendPluginEvent(const ANPEvent& evt) +{ + PluginWidgetAndroid** iter = m_plugins.begin(); + PluginWidgetAndroid** stop = m_plugins.end(); + for (; iter < stop; ++iter) { + (*iter)->sendEvent(evt); + } +} + /////////////////////////////////////////////////////////////////////////////// void WebViewCore::setFinalFocus(WebCore::Frame* frame, WebCore::Node* node, @@ -2568,6 +2578,20 @@ static bool PictureReady(JNIEnv* env, jobject obj) return GET_NATIVE_VIEW(env, obj)->pictureReady(); } +static void Pause(JNIEnv* env, jobject obj) +{ + ANPEvent event; + SkANP::InitEvent(&event, kPause_ANPEventType); + GET_NATIVE_VIEW(env, obj)->sendPluginEvent(event); +} + +static void Resume(JNIEnv* env, jobject obj) +{ + ANPEvent event; + SkANP::InitEvent(&event, kResume_ANPEventType); + GET_NATIVE_VIEW(env, obj)->sendPluginEvent(event); +} + // ---------------------------------------------------------------------------- /* @@ -2649,7 +2673,9 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { { "nativeDumpNavTree", "()V", (void*) DumpNavTree }, { "nativeSetDatabaseQuota", "(J)V", - (void*) SetDatabaseQuota } + (void*) SetDatabaseQuota }, + { "nativePause", "()V", (void*) Pause }, + { "nativeResume", "()V", (void*) Resume }, }; int register_webviewcore(JNIEnv* env) diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index b062ced..cd9de55 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -55,6 +55,7 @@ namespace WebCore { struct PluginWidgetAndroid; class SkPicture; class SkIRect; +struct ANPEvent; namespace android { @@ -300,6 +301,9 @@ namespace android { void invalPlugin(PluginWidgetAndroid*); void drawPlugins(); + // send this event to all of the plugins in our list + void sendPluginEvent(const ANPEvent&); + // Notify the Java side whether it needs to pass down the touch events void needTouchEvents(bool); diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 3c8c2f5..4dc361e 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -143,3 +143,12 @@ void PluginWidgetAndroid::draw(SkCanvas* canvas) { } } +bool PluginWidgetAndroid::sendEvent(const ANPEvent& evt) { + WebCore::PluginPackage* pkg = m_pluginView->plugin(); + NPP instance = m_pluginView->instance(); + // make a localCopy since the actual plugin may not respect its constness, + // and so we don't want our caller to have its param modified + ANPEvent localCopy = evt; + return pkg->pluginFuncs()->event(instance, &localCopy); +} + diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index f5e9363..e8f5e6a 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -82,6 +82,11 @@ struct PluginWidgetAndroid { */ void draw(SkCanvas* canvas = NULL); + /* Send this event to the plugin instance, and return true if the plugin + handled it. + */ + bool sendEvent(const ANPEvent&); + private: WebCore::PluginView* m_pluginView; android::WebViewCore* m_core; diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index 83fe3a9..a3ffdfb 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -602,10 +602,12 @@ struct ANPAudioTrackInterfaceV0 : ANPInterface { // HandleEvent enum ANPEventTypes { - kNull_ANPEventType = 0, - kKey_ANPEventType = 1, - kTouch_ANPEventType = 2, - kDraw_ANPEventType = 3, + kNull_ANPEventType = 0, + kKey_ANPEventType = 1, + kTouch_ANPEventType = 2, + kDraw_ANPEventType = 3, + kPause_ANPEventType = 4, // no extra data in the event + kResume_ANPEventType = 5 // no extra data in the event }; typedef int32_t ANPEventType; |