cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ppapi / cpp / dev / find_dev.cc
blobe9640bc7e111c4751358dc3db7f0ac0db0b2158b
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/find_dev.h"
7 #include "ppapi/c/dev/ppb_find_dev.h"
8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/module_impl.h"
12 namespace pp {
14 namespace {
16 template <> const char* interface_name<PPB_Find_Dev>() {
17 return PPB_FIND_DEV_INTERFACE;
20 static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE;
22 PP_Bool StartFind(PP_Instance instance,
23 const char* text,
24 PP_Bool case_sensitive) {
25 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface);
26 if (!object)
27 return PP_FALSE;
28 bool return_value = static_cast<Find_Dev*>(object)->StartFind(
29 text, PP_ToBool(case_sensitive));
30 return PP_FromBool(return_value);
33 void SelectFindResult(PP_Instance instance, PP_Bool forward) {
34 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface);
35 if (object)
36 static_cast<Find_Dev*>(object)->SelectFindResult(PP_ToBool(forward));
39 void StopFind(PP_Instance instance) {
40 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface);
41 if (object)
42 static_cast<Find_Dev*>(object)->StopFind();
45 const PPP_Find_Dev ppp_find = {
46 &StartFind,
47 &SelectFindResult,
48 &StopFind
51 } // namespace
53 Find_Dev::Find_Dev(Instance* instance) : associated_instance_(instance) {
54 Module::Get()->AddPluginInterface(kPPPFindInterface, &ppp_find);
55 instance->AddPerInstanceObject(kPPPFindInterface, this);
58 Find_Dev::~Find_Dev() {
59 Instance::RemovePerInstanceObject(associated_instance_,
60 kPPPFindInterface, this);
63 void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) {
64 if (has_interface<PPB_Find_Dev>()) {
65 get_interface<PPB_Find_Dev>()->NumberOfFindResultsChanged(
66 associated_instance_.pp_instance(), total, PP_FromBool(final_result));
70 void Find_Dev::SelectedFindResultChanged(int32_t index) {
71 if (has_interface<PPB_Find_Dev>()) {
72 get_interface<PPB_Find_Dev>()->SelectedFindResultChanged(
73 associated_instance_.pp_instance(), index);
77 } // namespace pp