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