diff options
author | Derek Sollenberger <djsollen@google.com> | 2011-01-27 17:28:03 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2011-01-27 18:09:44 -0500 |
commit | 9bd15c56f90a9621fccfd28b9017ef1c3dba5ad7 (patch) | |
tree | 5914a7b6c1555e09c56a58d2c861103dabc3e595 /WebKit/android/plugins | |
parent | 00e7bdac2cb1be80a07ab5f78d2fa4b7210e8026 (diff) | |
download | external_webkit-9bd15c56f90a9621fccfd28b9017ef1c3dba5ad7.zip external_webkit-9bd15c56f90a9621fccfd28b9017ef1c3dba5ad7.tar.gz external_webkit-9bd15c56f90a9621fccfd28b9017ef1c3dba5ad7.tar.bz2 |
Add Plugin API for controling the device power states
This is an initial API that will allow the plugin to request to
keep the screen on.
companion change is in frameworks/base
bug: 3331493
Change-Id: Id807dc3a3e5aaf12fc63558edeceee0d35561768
Diffstat (limited to 'WebKit/android/plugins')
-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 |
5 files changed, 57 insertions, 0 deletions
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. |