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/private/find_private.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_find_dev.h" | 7 #include "ppapi/c/private/ppb_find_private.h" |
8 #include "ppapi/cpp/instance.h" | 8 #include "ppapi/cpp/instance.h" |
9 #include "ppapi/cpp/module.h" | 9 #include "ppapi/cpp/module.h" |
10 #include "ppapi/cpp/module_impl.h" | 10 #include "ppapi/cpp/module_impl.h" |
11 | 11 |
12 namespace pp { | 12 namespace pp { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 template <> const char* interface_name<PPB_Find_Dev>() { | 16 template <> const char* interface_name<PPB_Find_Private>() { |
17 return PPB_FIND_DEV_INTERFACE; | 17 return PPB_FIND_PRIVATE_INTERFACE; |
18 } | 18 } |
19 | 19 |
20 static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE; | 20 static const char kPPPFindInterface[] = PPP_FIND_PRIVATE_INTERFACE; |
21 | 21 |
22 PP_Bool StartFind(PP_Instance instance, | 22 PP_Bool StartFind(PP_Instance instance, |
23 const char* text, | 23 const char* text, |
24 PP_Bool case_sensitive) { | 24 PP_Bool case_sensitive) { |
25 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); | 25 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); |
26 if (!object) | 26 if (!object) |
27 return PP_FALSE; | 27 return PP_FALSE; |
28 bool return_value = static_cast<Find_Dev*>(object)->StartFind( | 28 bool return_value = static_cast<Find_Private*>(object)->StartFind( |
29 text, PP_ToBool(case_sensitive)); | 29 text, PP_ToBool(case_sensitive)); |
30 return PP_FromBool(return_value); | 30 return PP_FromBool(return_value); |
31 } | 31 } |
32 | 32 |
33 void SelectFindResult(PP_Instance instance, PP_Bool forward) { | 33 void SelectFindResult(PP_Instance instance, PP_Bool forward) { |
34 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); | 34 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); |
35 if (object) | 35 if (object) |
36 static_cast<Find_Dev*>(object)->SelectFindResult(PP_ToBool(forward)); | 36 static_cast<Find_Private*>(object)->SelectFindResult(PP_ToBool(forward)); |
37 } | 37 } |
38 | 38 |
39 void StopFind(PP_Instance instance) { | 39 void StopFind(PP_Instance instance) { |
40 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); | 40 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); |
41 if (object) | 41 if (object) |
42 static_cast<Find_Dev*>(object)->StopFind(); | 42 static_cast<Find_Private*>(object)->StopFind(); |
43 } | 43 } |
44 | 44 |
45 const PPP_Find_Dev ppp_find = { | 45 const PPP_Find_Private ppp_find = { |
46 &StartFind, | 46 &StartFind, |
47 &SelectFindResult, | 47 &SelectFindResult, |
48 &StopFind | 48 &StopFind |
49 }; | 49 }; |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 Find_Dev::Find_Dev(Instance* instance) : associated_instance_(instance) { | 53 Find_Private::Find_Private(Instance* instance) |
| 54 : associated_instance_(instance) { |
54 Module::Get()->AddPluginInterface(kPPPFindInterface, &ppp_find); | 55 Module::Get()->AddPluginInterface(kPPPFindInterface, &ppp_find); |
55 instance->AddPerInstanceObject(kPPPFindInterface, this); | 56 instance->AddPerInstanceObject(kPPPFindInterface, this); |
56 } | 57 } |
57 | 58 |
58 Find_Dev::~Find_Dev() { | 59 Find_Private::~Find_Private() { |
59 Instance::RemovePerInstanceObject(associated_instance_, | 60 Instance::RemovePerInstanceObject(associated_instance_, |
60 kPPPFindInterface, this); | 61 kPPPFindInterface, this); |
61 } | 62 } |
62 | 63 |
63 void Find_Dev::SetPluginToHandleFindRequests() { | 64 void Find_Private::SetPluginToHandleFindRequests() { |
64 if (has_interface<PPB_Find_Dev>()) { | 65 if (has_interface<PPB_Find_Private>()) { |
65 get_interface<PPB_Find_Dev>()->SetPluginToHandleFindRequests( | 66 get_interface<PPB_Find_Private>()->SetPluginToHandleFindRequests( |
66 associated_instance_.pp_instance()); | 67 associated_instance_.pp_instance()); |
67 } | 68 } |
68 } | 69 } |
69 | 70 |
70 void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) { | 71 void Find_Private::NumberOfFindResultsChanged(int32_t total, |
71 if (has_interface<PPB_Find_Dev>()) { | 72 bool final_result) { |
72 get_interface<PPB_Find_Dev>()->NumberOfFindResultsChanged( | 73 if (has_interface<PPB_Find_Private>()) { |
| 74 get_interface<PPB_Find_Private>()->NumberOfFindResultsChanged( |
73 associated_instance_.pp_instance(), total, PP_FromBool(final_result)); | 75 associated_instance_.pp_instance(), total, PP_FromBool(final_result)); |
74 } | 76 } |
75 } | 77 } |
76 | 78 |
77 void Find_Dev::SelectedFindResultChanged(int32_t index) { | 79 void Find_Private::SelectedFindResultChanged(int32_t index) { |
78 if (has_interface<PPB_Find_Dev>()) { | 80 if (has_interface<PPB_Find_Private>()) { |
79 get_interface<PPB_Find_Dev>()->SelectedFindResultChanged( | 81 get_interface<PPB_Find_Private>()->SelectedFindResultChanged( |
80 associated_instance_.pp_instance(), index); | 82 associated_instance_.pp_instance(), index); |
81 } | 83 } |
82 } | 84 } |
83 | 85 |
84 } // namespace pp | 86 } // namespace pp |
OLD | NEW |