summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/ppapi_plugin_instance.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 22:52:40 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 22:52:40 +0000
commit55a5a5252075df867707a521b927e5e24f9090e1 (patch)
treecb030c4a7ef0d0aa1dfeea5ea16090958c222a9b /webkit/plugins/ppapi/ppapi_plugin_instance.cc
parent3704633a280e1e834ea3959f57841ab718cbe3ec (diff)
downloadchromium_src-55a5a5252075df867707a521b927e5e24f9090e1.zip
chromium_src-55a5a5252075df867707a521b927e5e24f9090e1.tar.gz
chromium_src-55a5a5252075df867707a521b927e5e24f9090e1.tar.bz2
Move PPB_Zoom and PPB_Messageing to the thunk system. Implement PPB_Messaging
proxy. TEST=none BUG=none Review URL: http://codereview.chromium.org/7283020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/ppapi_plugin_instance.cc')
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc101
1 files changed, 33 insertions, 68 deletions
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