Pepper_56_C++_interfaces
Pepper_56_C++_interfaces
 All Classes Namespaces Files Functions Typedefs Enumerations Macros Groups
instance.h
Go to the documentation of this file.
1 // Copyright (c) 2012 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_INSTANCE_H_
6 #define PPAPI_CPP_INSTANCE_H_
7 
10 
11 #include <map>
12 #include <string>
13 
14 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/ppb_console.h"
19 #include "ppapi/cpp/view.h"
20 
21 // Windows defines 'PostMessage', so we have to undef it.
22 #ifdef PostMessage
23 #undef PostMessage
24 #endif
25 
26 struct PP_InputEvent;
27 
29 namespace pp {
30 
31 class Compositor;
32 class Graphics2D;
33 class Graphics3D;
34 class InputEvent;
35 class InstanceHandle;
36 class MessageHandler;
37 class MessageLoop;
38 class Rect;
39 class URLLoader;
40 class Var;
41 
42 class Instance {
43  public:
52  explicit Instance(PP_Instance instance);
53 
71  virtual ~Instance();
72 
77  PP_Instance pp_instance() const { return pp_instance_; }
78 
99  virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
100 
103 
113  virtual void DidChangeView(const View& view);
114 
147  virtual void DidChangeView(const Rect& position, const Rect& clip);
148 
171  virtual void DidChangeFocus(bool has_focus);
172 
220  virtual bool HandleInputEvent(const pp::InputEvent& event);
221 
242  virtual bool HandleDocumentLoad(const URLLoader& url_loader);
243 
280  virtual void HandleMessage(const Var& message);
281 
283 
286 
309  bool BindGraphics(const Graphics2D& graphics);
310 
320  bool BindGraphics(const Graphics3D& graphics);
321 
331  bool BindGraphics(const Compositor& compositor);
332 
340  bool IsFullFrame();
341 
384  int32_t RequestInputEvents(uint32_t event_classes);
385 
423  int32_t RequestFilteringInputEvents(uint32_t event_classes);
424 
444  void ClearInputEventRequest(uint32_t event_classes);
445 
498  void PostMessage(const Var& message);
499 
534  int32_t RegisterMessageHandler(MessageHandler* message_handler,
535  const MessageLoop& message_loop);
536 
548 
550 
553 
558  void LogToConsole(PP_LogLevel level, const Var& value);
559 
568  void LogToConsoleWithSource(PP_LogLevel level,
569  const Var& source,
570  const Var& value);
571 
573 
602  void AddPerInstanceObject(const std::string& interface_name, void* object);
603 
604  // {PENDING: summarize Remove method here}
611  void RemovePerInstanceObject(const std::string& interface_name, void* object);
612 
616  static void RemovePerInstanceObject(const InstanceHandle& instance,
617  const std::string& interface_name,
618  void* object);
619 
629  static void* GetPerInstanceObject(PP_Instance instance,
630  const std::string& interface_name);
631 
632  private:
633  PP_Instance pp_instance_;
634 
635  typedef std::map<std::string, void*> InterfaceNameToObjectMap;
636  InterfaceNameToObjectMap interface_name_to_objects_;
637 };
638 
639 } // namespace pp
640 
641 #endif // PPAPI_CPP_INSTANCE_H_
static void * GetPerInstanceObject(PP_Instance instance, const std::string &interface_name)
virtual void HandleMessage(const Var &message)
int32_t RequestInputEvents(uint32_t event_classes)
void PostMessage(const Var &message)
int32_t RequestFilteringInputEvents(uint32_t event_classes)
Definition: rect.h:21
Definition: message_handler.h:15
virtual void DidChangeView(const View &view)
Instance(PP_Instance instance)
void ClearInputEventRequest(uint32_t event_classes)
virtual bool HandleDocumentLoad(const URLLoader &url_loader)
Definition: graphics_2d.h:23
This class represents a 3D rendering context in the browser.
Definition: graphics_3d.h:21
void RemovePerInstanceObject(const std::string &interface_name, void *object)
Definition: input_event.h:48
int32_t RegisterMessageHandler(MessageHandler *message_handler, const MessageLoop &message_loop)
virtual void DidChangeFocus(bool has_focus)
Definition: url_loader.h:23
Definition: instance_handle.h:44
bool BindGraphics(const Graphics2D &graphics)
void AddPerInstanceObject(const std::string &interface_name, void *object)
PP_Instance pp_instance() const
Definition: instance.h:77
void LogToConsole(PP_LogLevel level, const Var &value)
Definition: view.h:20
virtual bool HandleInputEvent(const pp::InputEvent &event)
Definition: message_loop.h:135
void UnregisterMessageHandler()
void LogToConsoleWithSource(PP_LogLevel level, const Var &source, const Var &value)
A generic type used for passing data types between the module and the page.
Definition: var.h:23
virtual ~Instance()
Definition: instance.h:42
Definition: compositor.h:24
virtual bool Init(uint32_t argc, const char *argn[], const char *argv[])
bool IsFullFrame()