diff options
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 17 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 4 | ||||
-rw-r--r-- | WebKit/android/plugins/ANPSystemInterface.cpp | 15 | ||||
-rw-r--r-- | WebKit/android/plugins/ANPSystem_npapi.h | 10 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 27 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.h | 4 | ||||
-rw-r--r-- | WebKit/android/plugins/android_npapi.h | 1 |
7 files changed, 78 insertions, 0 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 0163376..6ba8276 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -291,6 +291,7 @@ struct WebViewCore::JavaGlue { jmethodID m_updateSurface; jmethodID m_destroySurface; jmethodID m_getContext; + jmethodID m_keepScreenOn; jmethodID m_sendFindAgain; jmethodID m_showRect; jmethodID m_centerFitRect; @@ -340,6 +341,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_forwardingTouchEvents = false; #endif m_isPaused = false; + m_screenOnCounter = 0; LOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!"); @@ -387,6 +389,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_updateSurface = GetJMethod(env, clazz, "updateSurface", "(Landroid/webkit/ViewManager$ChildView;IIII)V"); m_javaGlue->m_destroySurface = GetJMethod(env, clazz, "destroySurface", "(Landroid/webkit/ViewManager$ChildView;)V"); m_javaGlue->m_getContext = GetJMethod(env, clazz, "getContext", "()Landroid/content/Context;"); + m_javaGlue->m_keepScreenOn = GetJMethod(env, clazz, "keepScreenOn", "(Z)V"); m_javaGlue->m_sendFindAgain = GetJMethod(env, clazz, "sendFindAgain", "()V"); m_javaGlue->m_showRect = GetJMethod(env, clazz, "showRect", "(IIIIIIFFFF)V"); m_javaGlue->m_centerFitRect = GetJMethod(env, clazz, "centerFitRect", "(IIII)V"); @@ -3710,6 +3713,20 @@ jobject WebViewCore::getContext() return result; } +void WebViewCore::keepScreenOn(bool screenOn) { + if ((screenOn && m_screenOnCounter == 0) || (!screenOn && m_screenOnCounter == 1)) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_keepScreenOn, screenOn); + checkException(env); + } + + // update the counter + if (screenOn) + m_screenOnCounter++; + else if (m_screenOnCounter > 0) + m_screenOnCounter--; +} + bool WebViewCore::validNodeAndBounds(Frame* frame, Node* node, const IntRect& originalAbsoluteBounds) { diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 028a0c7..4357165 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -499,6 +499,9 @@ namespace android { // Returns the context (android.content.Context) of the WebView jobject getContext(); + // Manages requests to keep the screen on while the WebView is visible + void keepScreenOn(bool screenOn); + bool validNodeAndBounds(Frame* , Node* , const IntRect& ); // Make the rect (left, top, width, height) visible. If it can be fully @@ -643,6 +646,7 @@ namespace android { void pluginInvalTimerFired(WebCore::Timer<WebViewCore>*) { this->drawPlugins(); } + int m_screenOnCounter; void doMaxScroll(CacheBuilder::Direction dir); SkPicture* rebuildPicture(const SkIRect& inval); diff --git a/WebKit/android/plugins/ANPSystemInterface.cpp b/WebKit/android/plugins/ANPSystemInterface.cpp index 959b93d..8510c2e 100644 --- a/WebKit/android/plugins/ANPSystemInterface.cpp +++ b/WebKit/android/plugins/ANPSystemInterface.cpp @@ -82,6 +82,13 @@ static jclass anp_loadJavaClass(NPP instance, const char* className) { return result; } +static void anp_setPowerState(NPP instance, ANPPowerState powerState) { + WebCore::PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + + pluginWidget->setPowerState(powerState); +} + /////////////////////////////////////////////////////////////////////////////// #define ASSIGN(obj, name) (obj)->name = anp_##name @@ -92,3 +99,11 @@ void ANPSystemInterfaceV0_Init(ANPInterface* v) { ASSIGN(i, getApplicationDataDirectory); ASSIGN(i, loadJavaClass); } + +void ANPSystemInterfaceV1_Init(ANPInterface* v) { + // initialize the functions from the previous interface + ANPSystemInterfaceV0_Init(v); + // add any new functions or override existing functions + ANPSystemInterfaceV1* i = reinterpret_cast<ANPSystemInterfaceV1*>(v); + ASSIGN(i, setPowerState); +} diff --git a/WebKit/android/plugins/ANPSystem_npapi.h b/WebKit/android/plugins/ANPSystem_npapi.h index 6a102a7..5d91cfb 100644 --- a/WebKit/android/plugins/ANPSystem_npapi.h +++ b/WebKit/android/plugins/ANPSystem_npapi.h @@ -47,4 +47,14 @@ struct ANPSystemInterfaceV0 : ANPInterface { jclass (*loadJavaClass)(NPP instance, const char* className); }; +enum ANPPowerStates { + kDefault_ANPPowerState = 0, + kScreenOn_ANPPowerState = 1 +}; +typedef int32_t ANPPowerState; + +struct ANPSystemInterfaceV1 : ANPSystemInterfaceV0 { + void (*setPowerState)(NPP instance, ANPPowerState powerState); +}; + #endif //ANPSystem_npapi_H diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 73fe18a..4dc12a3 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -72,12 +72,14 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_acceptEvents = false; m_isSurfaceClippedOut = false; m_layer = 0; + m_powerState = kDefault_ANPPowerState; } PluginWidgetAndroid::~PluginWidgetAndroid() { PLUGIN_LOG("%p Deleting Plugin", m_pluginView->instance()); m_acceptEvents = false; if (m_core) { + setPowerState(kDefault_ANPPowerState); m_core->removePlugin(this); if (m_isFullScreen) { exitFullScreen(true); @@ -635,3 +637,28 @@ void PluginWidgetAndroid::requestCenterFitZoom() { m_pluginWindow->width, m_pluginWindow->height); } +void PluginWidgetAndroid::setPowerState(ANPPowerState powerState) { + if(m_powerState == powerState) + return; + + // cleanup the old power state + switch (m_powerState) { + case kDefault_ANPPowerState: + break; + case kScreenOn_ANPPowerState: + m_core->keepScreenOn(false); + break; + } + + // setup the new power state + switch (powerState) { + case kDefault_ANPPowerState: + break; + case kScreenOn_ANPPowerState: + m_core->keepScreenOn(true); + break; + } + + m_powerState = powerState; +} + diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index fa01b41..9726a22 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -27,6 +27,7 @@ #define PluginWidgetAndroid_H #include "android_npapi.h" +#include "ANPSystem_npapi.h" #include "IntPoint.h" #include "IntRect.h" #include "MediaLayer.h" @@ -174,6 +175,8 @@ struct PluginWidgetAndroid { WebCore::MediaLayer* getLayer() const { return m_layer; } + void setPowerState(ANPPowerState powerState); + private: void computeVisiblePluginRect(); void scrollToVisiblePluginRect(); @@ -198,6 +201,7 @@ private: bool m_embeddedViewAttached; bool m_acceptEvents; bool m_isSurfaceClippedOut; + ANPPowerState m_powerState; /* We limit the number of rectangles to minimize storage and ensure adequate speed. diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index dd2dd10..fb13b43 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -124,6 +124,7 @@ typedef uint32_t ANPMatrixFlag; #define kOpenGLInterfaceV0_ANPGetValue ((NPNVariable)1013) #define kWindowInterfaceV1_ANPGetValue ((NPNVariable)1014) #define kVideoInterfaceV0_ANPGetValue ((NPNVariable)1015) +#define kSystemInterfaceV1_ANPGetValue ((NPNVariable)1016) /** queries for the drawing models supported on this device. |