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.
5 #include "ppapi/cpp/dev/zoom_dev.h"
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"
17 static const char kPPPZoomInterface
[] = PPP_ZOOM_DEV_INTERFACE
;
19 void Zoom(PP_Instance instance
,
22 void* object
= Instance::GetPerInstanceObject(instance
, kPPPZoomInterface
);
25 static_cast<Zoom_Dev
*>(object
)->Zoom(factor
, PP_ToBool(text_only
));
28 const PPP_Zoom_Dev ppp_zoom
= {
32 template <> const char* interface_name
<PPB_Zoom_Dev
>() {
33 return PPB_ZOOM_DEV_INTERFACE
;
38 Zoom_Dev::Zoom_Dev(Instance
* instance
) : associated_instance_(instance
) {
39 Module::Get()->AddPluginInterface(kPPPZoomInterface
, &ppp_zoom
);
40 instance
->AddPerInstanceObject(kPPPZoomInterface
, this);
43 Zoom_Dev::~Zoom_Dev() {
44 Instance::RemovePerInstanceObject(associated_instance_
,
45 kPPPZoomInterface
, this);
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
);
54 void Zoom_Dev::ZoomLimitsChanged(double minimum_factor
,
55 double maximium_factor
) {
56 if (!has_interface
<PPB_Zoom_Dev
>())
58 get_interface
<PPB_Zoom_Dev
>()->ZoomLimitsChanged(
59 associated_instance_
.pp_instance(), minimum_factor
, maximium_factor
);