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