Roll leveldb from r73 to r75.
[chromium-blink-merge.git] / ppapi / cpp / dev / zoom_dev.cc
blob0b19c09935a146cff0a49c8e2eac13f16bcc7a3a
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"
13 namespace pp {
15 namespace {
17 static const char kPPPZoomInterface[] = PPP_ZOOM_DEV_INTERFACE;
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));
28 const PPP_Zoom_Dev ppp_zoom = {
29 &Zoom
32 template <> const char* interface_name<PPB_Zoom_Dev>() {
33 return PPB_ZOOM_DEV_INTERFACE;
36 } // namespace
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>())
57 return;
58 get_interface<PPB_Zoom_Dev>()->ZoomLimitsChanged(
59 associated_instance_.pp_instance(), minimum_factor, maximium_factor);
62 } // namespace pp