OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/cpp/dev/find_dev.h" | 5 #include "ppapi/cpp/dev/find_dev.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_find_dev.h" | 7 #include "ppapi/c/dev/ppb_find_dev.h" |
| 8 #include "ppapi/cpp/common.h" |
8 #include "ppapi/cpp/instance.h" | 9 #include "ppapi/cpp/instance.h" |
9 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
10 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
11 | 12 |
12 namespace pp { | 13 namespace pp { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE; | 17 static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE; |
17 | 18 |
18 bool StartFind(PP_Instance instance, | 19 PP_Bool StartFind(PP_Instance instance, |
19 const char* text, | 20 const char* text, |
20 bool case_sensitive) { | 21 PP_Bool case_sensitive) { |
21 void* object = | 22 void* object = |
22 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface); | 23 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface); |
23 if (!object) | 24 if (!object) |
24 return false; | 25 return PP_FALSE; |
25 return static_cast<Find_Dev*>(object)->StartFind(text, case_sensitive); | 26 bool return_value = static_cast<Find_Dev*>(object)->StartFind( |
| 27 text, PPBoolToBool(case_sensitive)); |
| 28 return BoolToPPBool(return_value); |
26 } | 29 } |
27 | 30 |
28 void SelectFindResult(PP_Instance instance, bool forward) { | 31 void SelectFindResult(PP_Instance instance, PP_Bool forward) { |
29 void* object = | 32 void* object = |
30 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface); | 33 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface); |
31 if (object) | 34 if (object) |
32 static_cast<Find_Dev*>(object)->SelectFindResult(forward); | 35 static_cast<Find_Dev*>(object)->SelectFindResult(PPBoolToBool(forward)); |
33 } | 36 } |
34 | 37 |
35 void StopFind(PP_Instance instance) { | 38 void StopFind(PP_Instance instance) { |
36 void* object = | 39 void* object = |
37 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface); | 40 pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface); |
38 if (object) | 41 if (object) |
39 static_cast<Find_Dev*>(object)->StopFind(); | 42 static_cast<Find_Dev*>(object)->StopFind(); |
40 } | 43 } |
41 | 44 |
42 const PPP_Find_Dev ppp_find = { | 45 const PPP_Find_Dev ppp_find = { |
(...skipping 11 matching lines...) Expand all Loading... |
54 associated_instance_->AddPerInstanceObject(kPPPFindInterface, this); | 57 associated_instance_->AddPerInstanceObject(kPPPFindInterface, this); |
55 } | 58 } |
56 | 59 |
57 Find_Dev::~Find_Dev() { | 60 Find_Dev::~Find_Dev() { |
58 associated_instance_->RemovePerInstanceObject(kPPPFindInterface, this); | 61 associated_instance_->RemovePerInstanceObject(kPPPFindInterface, this); |
59 } | 62 } |
60 | 63 |
61 void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) { | 64 void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) { |
62 if (ppb_find_f) { | 65 if (ppb_find_f) { |
63 ppb_find_f->NumberOfFindResultsChanged(associated_instance_->pp_instance(), | 66 ppb_find_f->NumberOfFindResultsChanged(associated_instance_->pp_instance(), |
64 total, final_result); | 67 total, |
| 68 BoolToPPBool(final_result)); |
65 } | 69 } |
66 } | 70 } |
67 | 71 |
68 void Find_Dev::SelectedFindResultChanged(int32_t index) { | 72 void Find_Dev::SelectedFindResultChanged(int32_t index) { |
69 if (ppb_find_f) { | 73 if (ppb_find_f) { |
70 ppb_find_f->SelectedFindResultChanged(associated_instance_->pp_instance(), | 74 ppb_find_f->SelectedFindResultChanged(associated_instance_->pp_instance(), |
71 index); | 75 index); |
72 } | 76 } |
73 } | 77 } |
74 | 78 |
75 } // namespace pp | 79 } // namespace pp |
OLD | NEW |