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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// 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/find_dev.h"
#include "ppapi/c/dev/ppb_find_dev.h"
#include "ppapi/cpp/common.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace pp {
namespace {
template <> const char* interface_name<PPB_Find_Dev>() {
return PPB_FIND_DEV_INTERFACE;
}
static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE;
PP_Bool StartFind(PP_Instance instance,
const char* text,
PP_Bool case_sensitive) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
if (!object)
return PP_FALSE;
bool return_value = static_cast<Find_Dev*>(object)->StartFind(
text, PPBoolToBool(case_sensitive));
return BoolToPPBool(return_value);
}
void SelectFindResult(PP_Instance instance, PP_Bool forward) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
if (object)
static_cast<Find_Dev*>(object)->SelectFindResult(PPBoolToBool(forward));
}
void StopFind(PP_Instance instance) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
if (object)
static_cast<Find_Dev*>(object)->StopFind();
}
const PPP_Find_Dev ppp_find = {
&StartFind,
&SelectFindResult,
&StopFind
};
} // namespace
Find_Dev::Find_Dev(Instance* instance) : associated_instance_(instance) {
pp::Module::Get()->AddPluginInterface(kPPPFindInterface, &ppp_find);
associated_instance_->AddPerInstanceObject(kPPPFindInterface, this);
}
Find_Dev::~Find_Dev() {
associated_instance_->RemovePerInstanceObject(kPPPFindInterface, this);
}
void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) {
if (has_interface<PPB_Find_Dev>()) {
get_interface<PPB_Find_Dev>()->NumberOfFindResultsChanged(
associated_instance_->pp_instance(), total, BoolToPPBool(final_result));
}
}
void Find_Dev::SelectedFindResultChanged(int32_t index) {
if (has_interface<PPB_Find_Dev>()) {
get_interface<PPB_Find_Dev>()->SelectedFindResultChanged(
associated_instance_->pp_instance(), index);
}
}
} // namespace pp
|