| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/cpp/dev/zoom_dev.h" | |
| 6 | |
| 7 #include "ppapi/c/dev/ppb_zoom_dev.h" | |
| 8 #include "ppapi/cpp/instance.h" | |
| 9 #include "ppapi/cpp/instance_handle.h" | |
| 10 #include "ppapi/cpp/module.h" | |
| 11 #include "ppapi/cpp/module_impl.h" | |
| 12 | |
| 13 namespace pp { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 static const char kPPPZoomInterface[] = PPP_ZOOM_DEV_INTERFACE; | |
| 18 | |
| 19 void Zoom(PP_Instance instance, | |
| 20 double factor, | |
| 21 PP_Bool text_only) { | |
| 22 void* object = Instance::GetPerInstanceObject(instance, kPPPZoomInterface); | |
| 23 if (!object) | |
| 24 return; | |
| 25 static_cast<Zoom_Dev*>(object)->Zoom(factor, PP_ToBool(text_only)); | |
| 26 } | |
| 27 | |
| 28 const PPP_Zoom_Dev ppp_zoom = { | |
| 29 &Zoom | |
| 30 }; | |
| 31 | |
| 32 template <> const char* interface_name<PPB_Zoom_Dev>() { | |
| 33 return PPB_ZOOM_DEV_INTERFACE; | |
| 34 } | |
| 35 | |
| 36 } // namespace | |
| 37 | |
| 38 Zoom_Dev::Zoom_Dev(Instance* instance) : associated_instance_(instance) { | |
| 39 Module::Get()->AddPluginInterface(kPPPZoomInterface, &ppp_zoom); | |
| 40 instance->AddPerInstanceObject(kPPPZoomInterface, this); | |
| 41 } | |
| 42 | |
| 43 Zoom_Dev::~Zoom_Dev() { | |
| 44 Instance::RemovePerInstanceObject(associated_instance_, | |
| 45 kPPPZoomInterface, this); | |
| 46 } | |
| 47 | |
| 48 void Zoom_Dev::ZoomChanged(double factor) { | |
| 49 if (has_interface<PPB_Zoom_Dev>()) | |
| 50 get_interface<PPB_Zoom_Dev>()->ZoomChanged( | |
| 51 associated_instance_.pp_instance(), factor); | |
| 52 } | |
| 53 | |
| 54 void Zoom_Dev::ZoomLimitsChanged(double minimum_factor, | |
| 55 double maximium_factor) { | |
| 56 if (!has_interface<PPB_Zoom_Dev>()) | |
| 57 return; | |
| 58 get_interface<PPB_Zoom_Dev>()->ZoomLimitsChanged( | |
| 59 associated_instance_.pp_instance(), minimum_factor, maximium_factor); | |
| 60 } | |
| 61 | |
| 62 } // namespace pp | |
| OLD | NEW |