summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc4
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc101
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h15
3 files changed, 41 insertions, 79 deletions
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index c9f98c6..db10e7f 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -297,7 +297,7 @@ const void* GetInterface(const char* name) {
if (strcmp(name, PPB_MEMORY_DEV_INTERFACE) == 0)
return PPB_Memory_Impl::GetInterface();
if (strcmp(name, PPB_MESSAGING_INTERFACE) == 0)
- return PluginInstance::GetMessagingInterface();
+ return ::ppapi::thunk::GetPPB_Messaging_Thunk();
if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0)
return PPB_Proxy_Impl::GetInterface();
if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE_0_4) == 0)
@@ -327,7 +327,7 @@ const void* GetInterface(const char* name) {
if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_Widget_Thunk();
if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0)
- return PluginInstance::GetZoomInterface();
+ return ::ppapi::thunk::GetPPB_Zoom_Thunk();
#ifdef ENABLE_GPU
// This should really refer to switches::kDisable3DAPIs.
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index c166af0..a83bbf6 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -22,7 +22,6 @@
#include "ppapi/c/pp_var.h"
#include "ppapi/c/ppb_core.h"
#include "ppapi/c/ppb_instance.h"
-#include "ppapi/c/ppb_messaging.h"
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/ppp_messaging.h"
#include "ppapi/c/private/ppb_instance_private.h"
@@ -182,59 +181,6 @@ void RectToPPRect(const gfx::Rect& input, PP_Rect* output) {
input.width(), input.height());
}
-void PostMessage(PP_Instance instance_id, PP_Var message) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return;
- instance->PostMessage(message);
-}
-
-const PPB_Messaging ppb_messaging = {
- &PostMessage
-};
-
-void ZoomChanged(PP_Instance instance_id, double factor) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return;
-
- // We only want to tell the page to change its zoom if the whole page is the
- // plugin. If we're in an iframe, then don't do anything.
- if (!instance->IsFullPagePlugin())
- return;
-
- double zoom_level = WebView::zoomFactorToZoomLevel(factor);
- // The conversino from zoom level to factor, and back, can introduce rounding
- // errors. i.e. WebKit originally tells us 3.0, but by the time we tell the
- // plugin and it tells us back, the level becomes 3.000000000004. Need to
- // round or else otherwise if the user zooms out, it will go to 3.0 instead of
- // 2.0.
- int rounded =
- static_cast<int>(zoom_level + (zoom_level > 0 ? 0.001 : -0.001));
- if (abs(rounded - zoom_level) < 0.001)
- zoom_level = rounded;
- instance->container()->zoomLevelChanged(zoom_level);
-}
-
-void ZoomLimitsChanged(PP_Instance instance_id,
- double minimum_factor,
- double maximium_factor) {
- if (minimum_factor > maximium_factor) {
- NOTREACHED();
- return;
- }
-
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return;
- instance->delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor);
-}
-
-const PPB_Zoom_Dev ppb_zoom = {
- &ZoomChanged,
- &ZoomLimitsChanged
-};
-
} // namespace
// static
@@ -315,16 +261,6 @@ PluginInstance::~PluginInstance() {
ResourceTracker::Get()->InstanceDeleted(pp_instance_);
}
-// static
-const PPB_Messaging* PluginInstance::GetMessagingInterface() {
- return &ppb_messaging;
-}
-
-// static
-const PPB_Zoom_Dev* PluginInstance::GetZoomInterface() {
- return &ppb_zoom;
-}
-
// NOTE: Any of these methods that calls into the plugin needs to take into
// account that the plugin may use Var to remove the <embed> from the DOM, which
// will make the WebPluginImpl drop its reference, usually the last one. If a
@@ -466,10 +402,6 @@ bool PluginInstance::SetCursor(PP_CursorType_Dev type,
return true;
}
-void PluginInstance::PostMessage(PP_Var message) {
- message_channel_->PostMessageToJavaScript(message);
-}
-
bool PluginInstance::Initialize(WebPluginContainer* container,
const std::vector<std::string>& arg_names,
const std::vector<std::string>& arg_values,
@@ -1508,5 +1440,38 @@ PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) {
return PP_TRUE;
}
+void PluginInstance::ZoomChanged(PP_Instance instance, double factor) {
+ // We only want to tell the page to change its zoom if the whole page is the
+ // plugin. If we're in an iframe, then don't do anything.
+ if (!IsFullPagePlugin())
+ return;
+
+ double zoom_level = WebView::zoomFactorToZoomLevel(factor);
+ // The conversino from zoom level to factor, and back, can introduce rounding
+ // errors. i.e. WebKit originally tells us 3.0, but by the time we tell the
+ // plugin and it tells us back, the level becomes 3.000000000004. Need to
+ // round or else otherwise if the user zooms out, it will go to 3.0 instead of
+ // 2.0.
+ int rounded =
+ static_cast<int>(zoom_level + (zoom_level > 0 ? 0.001 : -0.001));
+ if (abs(rounded - zoom_level) < 0.001)
+ zoom_level = rounded;
+ container()->zoomLevelChanged(zoom_level);
+}
+
+void PluginInstance::ZoomLimitsChanged(PP_Instance instance,
+ double minimum_factor,
+ double maximium_factor) {
+ if (minimum_factor > maximium_factor) {
+ NOTREACHED();
+ return;
+ }
+ delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor);
+}
+
+void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) {
+ message_channel_->PostMessageToJavaScript(message);
+}
+
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 7a5487c..9d8fc5de 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -34,8 +34,6 @@
typedef struct NPObject NPObject;
struct PP_Var;
-struct PPB_Messaging;
-struct PPB_Zoom_Dev;
struct PPP_Find_Dev;
struct PPP_Instance_Private;
struct PPP_Messaging;
@@ -99,11 +97,6 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
// Delete should be called by the WebPlugin before this destructor.
virtual ~PluginInstance();
- // Returns a pointer to the interface implementing PPB_Find that is
- // exposed to the plugin.
- static const PPB_Messaging* GetMessagingInterface();
- static const PPB_Zoom_Dev* GetZoomInterface();
-
PluginDelegate* delegate() const { return delegate_; }
PluginModule* module() const { return module_.get(); }
MessageChannel& message_channel() { return *message_channel_; }
@@ -241,8 +234,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
const char* target,
bool from_user_action);
- // Implementation of PPB_Messaging and PPP_Messaging.
- void PostMessage(PP_Var message);
+ // Implementation of PPP_Messaging.
void HandleMessage(PP_Var message);
PluginDelegate::PlatformContext3D* CreateContext3D();
@@ -284,6 +276,11 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
virtual PP_Bool SetFullscreen(PP_Instance instance,
PP_Bool fullscreen) OVERRIDE;
virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE;
+ virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE;
+ virtual void ZoomLimitsChanged(PP_Instance instance,
+ double minimum_factor,
+ double maximium_factor) OVERRIDE;
+ virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE;
private:
// See the static Create functions above for creating PluginInstance objects.