extern void ANPWindowInterfaceV0_Init(ANPInterface* value);
extern void ANPWindowInterfaceV1_Init(ANPInterface* value);
extern void ANPSystemInterfaceV0_Init(ANPInterface* value);
+extern void ANPSystemInterfaceV1_Init(ANPInterface* value);
extern void ANPOpenGLInterfaceV0_Init(ANPInterface* value);
extern void ANPVideoInterfaceV0_Init(ANPInterface* value);
{ VARPROCLINE(WindowInterfaceV0) },
{ VARPROCLINE(WindowInterfaceV1) },
{ VARPROCLINE(SystemInterfaceV0) },
+ { VARPROCLINE(SystemInterfaceV1) },
{ VARPROCLINE(OpenGLInterfaceV0) },
{ VARPROCLINE(VideoInterfaceV0) },
};
jmethodID m_updateSurface;
jmethodID m_destroySurface;
jmethodID m_getContext;
+ jmethodID m_keepScreenOn;
jmethodID m_sendFindAgain;
jmethodID m_showRect;
jmethodID m_centerFitRect;
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!");
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");
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)
{
// 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
void pluginInvalTimerFired(WebCore::Timer<WebViewCore>*) {
this->drawPlugins();
}
+ int m_screenOnCounter;
void doMaxScroll(CacheBuilder::Direction dir);
SkPicture* rebuildPicture(const SkIRect& inval);
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
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);
+}
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
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);
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;
+}
+
#define PluginWidgetAndroid_H
#include "android_npapi.h"
+#include "ANPSystem_npapi.h"
#include "IntPoint.h"
#include "IntRect.h"
#include "MediaLayer.h"
WebCore::MediaLayer* getLayer() const { return m_layer; }
+ void setPowerState(ANPPowerState powerState);
+
private:
void computeVisiblePluginRect();
void scrollToVisiblePluginRect();
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.
#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.