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