diff options
Diffstat (limited to 'Source/WebKit/android/plugins')
4 files changed, 83 insertions, 2 deletions
diff --git a/Source/WebKit/android/plugins/ANPWindowInterface.cpp b/Source/WebKit/android/plugins/ANPWindowInterface.cpp index a74616c..cac8f8c 100644 --- a/Source/WebKit/android/plugins/ANPWindowInterface.cpp +++ b/Source/WebKit/android/plugins/ANPWindowInterface.cpp @@ -79,6 +79,12 @@ static ANPRectI anp_visibleRect(NPP instance) { return pluginWidget->visibleRect(); } +static void anp_requestFullScreenOrientation(NPP instance, ANPScreenOrientation orientation) { + PluginView* pluginView = pluginViewForInstance(instance); + PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget(); + pluginWidget->setFullScreenOrientation(orientation); +} + /////////////////////////////////////////////////////////////////////////////// #define ASSIGN(obj, name) (obj)->name = anp_##name @@ -101,3 +107,11 @@ void ANPWindowInterfaceV1_Init(ANPInterface* value) { ANPWindowInterfaceV1* i = reinterpret_cast<ANPWindowInterfaceV1*>(value); ASSIGN(i, visibleRect); } + +void ANPWindowInterfaceV2_Init(ANPInterface* value) { + // initialize the functions from the previous interface + ANPWindowInterfaceV1_Init(value); + // add any new functions or override existing functions + ANPWindowInterfaceV2* i = reinterpret_cast<ANPWindowInterfaceV2*>(value); + ASSIGN(i, requestFullScreenOrientation); +} diff --git a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp index b8a10cc..19433ab 100644 --- a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -45,7 +45,7 @@ #include "android_graphics.h" #include <JNIUtility.h> -// #define PLUGIN_DEBUG_LOCAL // controls the printing of log messages +#define PLUGIN_DEBUG_LOCAL // controls the printing of log messages #define DEBUG_EVENTS 0 // logs event contents, return value, and processing time #define DEBUG_VISIBLE_RECTS 0 // temporary debug printfs and fixes @@ -73,6 +73,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_isSurfaceClippedOut = false; m_layer = 0; m_powerState = kDefault_ANPPowerState; + m_fullScreenOrientation = -1; } PluginWidgetAndroid::~PluginWidgetAndroid() { @@ -630,7 +631,8 @@ void PluginWidgetAndroid::requestFullScreen() { m_core->destroySurface(m_embeddedView); // add the full screen view - m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance()); + m_core->showFullScreenPlugin(m_embeddedView, m_fullScreenOrientation, + m_pluginView->instance()); m_isFullScreen = true; } @@ -658,6 +660,35 @@ void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) { m_isFullScreen = false; } +void PluginWidgetAndroid::setFullScreenOrientation(ANPScreenOrientation orientation) { + + int internalOrienationId; + /* We need to validate that the input is legitimate and then convert the + * value from the plugin enum to the enum used by the android view system. + * The view system values correspond to those values for the + * screenOrientation attribute in R.java (see also ActivityInfo.java). + */ + switch (orientation) { + case kFixedLandscape_ANPScreenOrientation: + internalOrienationId = 0; + break; + case kFixedPortrait_ANPScreenOrientation: + internalOrienationId = 1; + break; + case kLandscape_ANPScreenOrientation: + internalOrienationId = 6; + break; + case kPortrait_ANPScreenOrientation: + internalOrienationId = 7; + break; + default: + internalOrienationId = -1; + } + + PLUGIN_LOG("%s orientation (%d)", __FUNCTION__, internalOrienationId); + m_fullScreenOrientation = internalOrienationId; +} + void PluginWidgetAndroid::requestCenterFitZoom() { m_core->centerFitRect(m_pluginWindow->x, m_pluginWindow->y, m_pluginWindow->width, m_pluginWindow->height); diff --git a/Source/WebKit/android/plugins/PluginWidgetAndroid.h b/Source/WebKit/android/plugins/PluginWidgetAndroid.h index 5d586b1..cbebb7f 100644 --- a/Source/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/Source/WebKit/android/plugins/PluginWidgetAndroid.h @@ -150,6 +150,8 @@ struct PluginWidgetAndroid { bool inFullScreen() { return m_isFullScreen; } + void setFullScreenOrientation(ANPScreenOrientation orientation); + /** Called to check if a plugin currently has document focus, which is required for certain operations (e.g. show/hide keyboard). It returns true if the plugin currently has focus and false otherwise. @@ -204,6 +206,7 @@ private: bool m_acceptEvents; bool m_isSurfaceClippedOut; ANPPowerState m_powerState; + int m_fullScreenOrientation; /* We limit the number of rectangles to minimize storage and ensure adequate speed. diff --git a/Source/WebKit/android/plugins/android_npapi.h b/Source/WebKit/android/plugins/android_npapi.h index b0c3765..4ff45c8 100644 --- a/Source/WebKit/android/plugins/android_npapi.h +++ b/Source/WebKit/android/plugins/android_npapi.h @@ -127,6 +127,7 @@ typedef uint32_t ANPMatrixFlag; #define kSystemInterfaceV1_ANPGetValue ((NPNVariable)1016) #define kSystemInterfaceV2_ANPGetValue ((NPNVariable)1017) +#define kWindowInterfaceV2_ANPGetValue ((NPNVariable)1018) /** queries for the drawing models supported on this device. @@ -695,6 +696,38 @@ struct ANPWindowInterfaceV1 : ANPWindowInterfaceV0 { ANPRectI (*visibleRect)(NPP instance); }; +enum ANPScreenOrientations { + /** No preference specified: let the system decide the best orientation. + */ + kDefault_ANPScreenOrientation = 0, + /** Would like to have the screen in a landscape orientation, but it will + not allow for 180 degree rotations. + */ + kFixedLandscape_ANPScreenOrientation = 1, + /** Would like to have the screen in a portrait orientation, but it will + not allow for 180 degree rotations. + */ + kFixedPortrait_ANPScreenOrientation = 2, + /** Would like to have the screen in landscape orientation, but can use the + sensor to change which direction the screen is facing. + */ + kLandscape_ANPScreenOrientation = 3, + /** Would like to have the screen in portrait orientation, but can use the + sensor to change which direction the screen is facing. + */ + kPortrait_ANPScreenOrientation = 4 +}; +typedef int32_t ANPScreenOrientation; + +struct ANPWindowInterfaceV2 : ANPWindowInterfaceV1 { + /** Called when the plugin wants to specify a particular screen orientation + when entering into full screen mode. The orientation must be set prior + to entering into full screen. After entering full screen any subsequent + changes will be updated the next time the plugin goes full screen. + */ + void (*requestFullScreenOrientation)(NPP instance, ANPScreenOrientation orientation); +}; + /////////////////////////////////////////////////////////////////////////////// enum ANPSampleFormats { |