OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/private/find_private.h" | 5 #include "ppapi/cpp/private/find_private.h" |
6 | 6 |
7 #include "ppapi/c/private/ppb_find_private.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 #include "ppapi/cpp/rect.h" | 11 #include "ppapi/cpp/rect.h" |
12 | 12 |
13 namespace pp { | 13 namespace pp { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 template <> const char* interface_name<PPB_Find_Private>() { | 17 template <> const char* interface_name<PPB_Find_Private>() { |
18 return PPB_FIND_PRIVATE_INTERFACE; | 18 return PPB_FIND_PRIVATE_INTERFACE; |
19 } | 19 } |
20 | 20 |
21 static const char kPPPFindInterface[] = PPP_FIND_PRIVATE_INTERFACE; | 21 static const char kPPPFindInterface[] = PPP_FIND_PRIVATE_INTERFACE; |
22 | 22 |
23 PP_Bool StartFind(PP_Instance instance, | 23 PP_Bool StartFind(PP_Instance instance, |
24 const char* text, | 24 const char* text, |
25 PP_Bool case_sensitive) { | 25 PP_Bool case_sensitive) { |
26 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); | 26 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); |
27 if (!object) | 27 if (!object) |
28 return PP_FALSE; | 28 return PP_FALSE; |
| 29 if (!text || text[0] == '\0') { |
| 30 PP_NOTREACHED(); |
| 31 return PP_FALSE; |
| 32 } |
29 bool return_value = static_cast<Find_Private*>(object)->StartFind( | 33 bool return_value = static_cast<Find_Private*>(object)->StartFind( |
30 text, PP_ToBool(case_sensitive)); | 34 text, PP_ToBool(case_sensitive)); |
31 return PP_FromBool(return_value); | 35 return PP_FromBool(return_value); |
32 } | 36 } |
33 | 37 |
34 void SelectFindResult(PP_Instance instance, PP_Bool forward) { | 38 void SelectFindResult(PP_Instance instance, PP_Bool forward) { |
35 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); | 39 void* object = Instance::GetPerInstanceObject(instance, kPPPFindInterface); |
36 if (object) | 40 if (object) |
37 static_cast<Find_Private*>(object)->SelectFindResult(PP_ToBool(forward)); | 41 static_cast<Find_Private*>(object)->SelectFindResult(PP_ToBool(forward)); |
38 } | 42 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 tickmarks.end()); | 94 tickmarks.end()); |
91 PP_Rect* array = | 95 PP_Rect* array = |
92 tickmarks_converted.empty() ? NULL : &tickmarks_converted[0]; | 96 tickmarks_converted.empty() ? NULL : &tickmarks_converted[0]; |
93 get_interface<PPB_Find_Private>()->SetTickmarks( | 97 get_interface<PPB_Find_Private>()->SetTickmarks( |
94 associated_instance_.pp_instance(), array, | 98 associated_instance_.pp_instance(), array, |
95 static_cast<uint32_t>(tickmarks.size())); | 99 static_cast<uint32_t>(tickmarks.size())); |
96 } | 100 } |
97 } | 101 } |
98 | 102 |
99 } // namespace pp | 103 } // namespace pp |
OLD | NEW |