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 #ifndef PPAPI_CPP_DEV_FIND_DEV_H_ | 5 #ifndef PPAPI_CPP_DEV_FIND_DEV_H_ |
6 #define PPAPI_CPP_DEV_FIND_DEV_H_ | 6 #define PPAPI_CPP_DEV_FIND_DEV_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ppapi/c/dev/ppp_find_dev.h" | 10 #include "ppapi/c/dev/ppp_find_dev.h" |
11 #include "ppapi/cpp/instance_handle.h" | 11 #include "ppapi/cpp/instance_handle.h" |
12 | 12 |
13 namespace pp { | 13 namespace pp { |
14 | 14 |
| 15 class Instance; |
| 16 |
15 // This class allows you to associate the PPP_Find and PPB_Find C-based | 17 // This class allows you to associate the PPP_Find and PPB_Find C-based |
16 // interfaces with an object. It associates itself with the given instance, and | 18 // interfaces with an object. It associates itself with the given instance, and |
17 // registers as the global handler for handling the PPP_Find interface that the | 19 // registers as the global handler for handling the PPP_Find interface that the |
18 // browser calls. | 20 // browser calls. |
19 // | 21 // |
20 // You would typically use this either via inheritance on your instance: | 22 // You would typically use this either via inheritance on your instance: |
21 // class MyInstance : public pp::Instance, public pp::Find_Dev { | 23 // class MyInstance : public pp::Instance, public pp::Find_Dev { |
22 // class MyInstance() : pp::Find_Dev(this) { | 24 // class MyInstance() : pp::Find_Dev(this) { |
23 // } | 25 // } |
24 // ... | 26 // ... |
25 // }; | 27 // }; |
26 // | 28 // |
27 // or by composition: | 29 // or by composition: |
28 // class MyFinder : public pp::Find { | 30 // class MyFinder : public pp::Find { |
29 // ... | 31 // ... |
30 // }; | 32 // }; |
31 // | 33 // |
32 // class MyInstance : public pp::Instance { | 34 // class MyInstance : public pp::Instance { |
33 // MyInstance() : finder_(this) { | 35 // MyInstance() : finder_(this) { |
34 // } | 36 // } |
35 // | 37 // |
36 // MyFinder finder_; | 38 // MyFinder finder_; |
37 // }; | 39 // }; |
38 class Find_Dev { | 40 class Find_Dev { |
39 public: | 41 public: |
40 // The instance parameter must outlive this class. | 42 // The instance parameter must outlive this class. |
41 Find_Dev(const InstanceHandle& instance); | 43 Find_Dev(Instance* instance); |
42 virtual ~Find_Dev(); | 44 virtual ~Find_Dev(); |
43 | 45 |
44 // PPP_Find_Dev functions exposed as virtual functions for you to | 46 // PPP_Find_Dev functions exposed as virtual functions for you to |
45 // override. | 47 // override. |
46 virtual bool StartFind(const std::string& text, bool case_sensitive) = 0; | 48 virtual bool StartFind(const std::string& text, bool case_sensitive) = 0; |
47 virtual void SelectFindResult(bool forward) = 0; | 49 virtual void SelectFindResult(bool forward) = 0; |
48 virtual void StopFind() = 0; | 50 virtual void StopFind() = 0; |
49 | 51 |
50 // PPB_Find_Def functions for you to call to report find results. | 52 // PPB_Find_Def functions for you to call to report find results. |
51 void NumberOfFindResultsChanged(int32_t total, bool final_result); | 53 void NumberOfFindResultsChanged(int32_t total, bool final_result); |
52 void SelectedFindResultChanged(int32_t index); | 54 void SelectedFindResultChanged(int32_t index); |
53 | 55 |
54 private: | 56 private: |
55 InstanceHandle associated_instance_; | 57 InstanceHandle associated_instance_; |
56 }; | 58 }; |
57 | 59 |
58 } // namespace pp | 60 } // namespace pp |
59 | 61 |
60 #endif // PPAPI_CPP_DEV_FIND_DEV_H_ | 62 #endif // PPAPI_CPP_DEV_FIND_DEV_H_ |
OLD | NEW |