[email protected] | c33a932 | 2012-02-04 16:49:00 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 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 | |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 8 | /// @file |
[email protected] | 0325ee3 | 2011-11-10 18:35:10 | [diff] [blame] | 9 | /// This file defines the C++ wrapper for an instance. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 10 | |
| 11 | #include <map> |
| 12 | #include <string> |
| 13 | |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 14 | #include "ppapi/c/pp_instance.h" |
| 15 | #include "ppapi/c/pp_resource.h" |
| 16 | #include "ppapi/c/pp_stdint.h" |
[email protected] | 598816ad | 2012-12-13 01:34:32 | [diff] [blame] | 17 | #include "ppapi/c/ppb_console.h" |
[email protected] | 09af0f7 | 2012-02-27 20:23:19 | [diff] [blame] | 18 | #include "ppapi/cpp/instance_handle.h" |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 19 | #include "ppapi/cpp/view.h" |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 20 | |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 21 | // Windows defines 'PostMessage', so we have to undef it. |
| 22 | #ifdef PostMessage |
| 23 | #undef PostMessage |
| 24 | #endif |
| 25 | |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 26 | /// The C++ interface to the Pepper API. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 27 | namespace pp { |
| 28 | |
| 29 | class Graphics2D; |
[email protected] | fae0e94 | 2011-09-07 17:10:46 | [diff] [blame] | 30 | class Graphics3D; |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 31 | class InputEvent; |
[email protected] | 09af0f7 | 2012-02-27 20:23:19 | [diff] [blame] | 32 | class InstanceHandle; |
dmichael | b873791 | 2014-09-18 18:00:29 | [diff] [blame] | 33 | class MessageHandler; |
| 34 | class MessageLoop; |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 35 | class Rect; |
[email protected] | 5a3f6285 | 2010-11-10 21:43:01 | [diff] [blame] | 36 | class URLLoader; |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 37 | class Var; |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 38 | |
| 39 | class Instance { |
| 40 | public: |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 41 | /// Default constructor. Construction of an instance should only be done in |
| 42 | /// response to a browser request in <code>Module::CreateInstance</code>. |
| 43 | /// Otherwise, the instance will lack the proper bookkeeping in the browser |
| 44 | /// and in the C++ wrapper. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 45 | /// |
| 46 | /// Init() will be called immediately after the constructor. This allows you |
| 47 | /// to perform initialization tasks that can fail and to report that failure |
| 48 | /// to the browser. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 49 | explicit Instance(PP_Instance instance); |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 50 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 51 | /// Destructor. When the instance is removed from the web page, |
| 52 | /// the <code>pp::Instance</code> object will be deleted. You should never |
| 53 | /// delete the <code>Instance</code> object yourself since the lifetime is |
| 54 | /// handled by the C++ wrapper and is controlled by the browser's calls to |
| 55 | /// the <code>PPP_Instance</code> interface. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 56 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 57 | /// The <code>PP_Instance</code> identifier will still be valid during this |
| 58 | /// call so the instance can perform cleanup-related tasks. Once this function |
| 59 | /// returns, the <code>PP_Instance</code> handle will be invalid. This means |
| 60 | /// that you can't do any asynchronous operations such as network requests or |
| 61 | /// file writes from this destructor since they will be immediately canceled. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 62 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 63 | /// <strong>Note:</strong> This function may be skipped in certain |
| 64 | /// call so the instance can perform cleanup-related tasks. Once this function |
| 65 | /// returns, the <code>PP_Instance</code> handle will be invalid. This means |
| 66 | /// that you can't do any asynchronous operations such as network requests or |
| 67 | /// file writes from this destructor since they will be immediately canceled. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 68 | virtual ~Instance(); |
| 69 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 70 | /// This function returns the <code>PP_Instance</code> identifying this |
[email protected] | 09af0f7 | 2012-02-27 20:23:19 | [diff] [blame] | 71 | /// object. |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 72 | /// |
| 73 | /// @return A <code>PP_Instance</code> identifying this object. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 74 | PP_Instance pp_instance() const { return pp_instance_; } |
| 75 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 76 | /// Init() initializes this instance with the provided arguments. This |
| 77 | /// function will be called immediately after the instance object is |
| 78 | /// constructed. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 79 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 80 | /// @param[in] argc The number of arguments contained in <code>argn</code> |
| 81 | /// and <code>argv</code>. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 82 | /// |
| 83 | /// @param[in] argn An array of argument names. These argument names are |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 84 | /// supplied in the \<embed\> tag, for example: |
| 85 | /// <code>\<embed id="nacl_module" dimensions="2"\></code> will produce two |
| 86 | /// argument names: "id" and "dimensions". |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 87 | /// |
| 88 | /// @param[in] argv An array of argument values. These are the values of the |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 89 | /// arguments listed in the \<embed\> tag, for example |
| 90 | /// <code>\<embed id="nacl_module" dimensions="2"\></code> will produce two |
| 91 | /// argument values: "nacl_module" and "2". The indices of these values |
| 92 | /// match the indices of the corresponding names in <code>argn</code>. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 93 | /// |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 94 | /// @return true on success. Returning false causes the instance to be |
[email protected] | c33a932 | 2012-02-04 16:49:00 | [diff] [blame] | 95 | /// deleted and no other functions to be called. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 96 | virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); |
| 97 | |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 98 | /// @{ |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 99 | /// @name PPP_Instance methods for the module to override: |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 100 | |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 101 | /// DidChangeView() is called when the view information for the Instance |
| 102 | /// has changed. See the <code>View</code> object for information. |
| 103 | /// |
| 104 | /// Most implementations will want to check if the size and user visibility |
| 105 | /// changed, and either resize themselves or start/stop generating updates. |
| 106 | /// |
| 107 | /// You should not call the default implementation. For |
| 108 | /// backwards-compatibility, it will call the deprecated version of |
| 109 | /// DidChangeView below. |
| 110 | virtual void DidChangeView(const View& view); |
| 111 | |
| 112 | /// Deprecated backwards-compatible version of <code>DidChangeView()</code>. |
| 113 | /// New code should derive from the version that takes a |
| 114 | /// <code>ViewChanged</code> object rather than this version. This function |
| 115 | /// is called by the default implementation of the newer |
| 116 | /// <code>DidChangeView</code> function for source compatibility with older |
| 117 | /// code. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 118 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 119 | /// A typical implementation will check the size of the <code>position</code> |
| 120 | /// argument and reallocate the graphics context when a different size is |
| 121 | /// received. Note that this function will be called for scroll events where |
| 122 | /// the size doesn't change, so you should always check that the size is |
| 123 | /// actually different before doing any reallocations. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 124 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 125 | /// @param[in] position The location on the page of the instance. The |
| 126 | /// position is relative to the top left corner of the viewport, which changes |
| 127 | /// as the page is scrolled. Generally the size of this value will be used to |
| 128 | /// create a graphics device, and the position is ignored (most things are |
| 129 | /// relative to the instance so the absolute position isn't useful in most |
| 130 | /// cases). |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 131 | /// |
| 132 | /// @param[in] clip The visible region of the instance. This is relative to |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 133 | /// the top left of the instance's coordinate system (not the page). If the |
| 134 | /// instance is invisible, <code>clip</code> will be (0, 0, 0, 0). |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 135 | /// |
| 136 | /// It's recommended to check for invisible instances and to stop |
| 137 | /// generating graphics updates in this case to save system resources. It's |
| 138 | /// not usually worthwhile, however, to generate partial updates according to |
| 139 | /// the clip when the instance is partially visible. Instead, update the |
| 140 | /// entire region. The time saved doing partial paints is usually not |
| 141 | /// significant and it can create artifacts when scrolling (this notification |
[email protected] | 935d00fd | 2013-03-29 22:26:15 | [diff] [blame] | 142 | /// is sent asynchronously from scrolling so there can be flashes of old |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 143 | /// content in the exposed regions). |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 144 | virtual void DidChangeView(const Rect& position, const Rect& clip); |
| 145 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 146 | /// DidChangeFocus() is called when an instance has gained or lost focus. |
| 147 | /// Having focus means that keyboard events will be sent to the instance. |
| 148 | /// An instance's default condition is that it will not have focus. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 149 | /// |
[email protected] | a01da568 | 2012-06-30 00:37:31 | [diff] [blame] | 150 | /// The focus flag takes into account both browser tab and window focus as |
| 151 | /// well as focus of the plugin element on the page. In order to be deemed |
| 152 | /// to have focus, the browser window must be topmost, the tab must be |
| 153 | /// selected in the window, and the instance must be the focused element on |
| 154 | /// the page. |
| 155 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 156 | /// <strong>Note:</strong>Clicks on instances will give focus only if you |
[email protected] | a01da568 | 2012-06-30 00:37:31 | [diff] [blame] | 157 | /// handle the click event. Return <code>true</code> from |
| 158 | /// <code>HandleInputEvent</code> in <code>PPP_InputEvent</code> (or use |
| 159 | /// unfiltered events) to signal that the click event was handled. Otherwise, |
| 160 | /// the browser will bubble the event and give focus to the element on the |
| 161 | /// page that actually did end up consuming it. If you're not getting focus, |
| 162 | /// check to make sure you're either requesting them via |
| 163 | /// <code>RequestInputEvents()<code> (which implicitly marks all input events |
| 164 | /// as consumed) or via <code>RequestFilteringInputEvents()</code> and |
| 165 | /// returning true from your event handler. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 166 | /// |
| 167 | /// @param[in] has_focus Indicates the new focused state of the instance. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 168 | virtual void DidChangeFocus(bool has_focus); |
| 169 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 170 | /// HandleInputEvent() handles input events from the browser. The default |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 171 | /// implementation does nothing and returns false. |
| 172 | /// |
| 173 | /// In order to receive input events, you must register for them by calling |
| 174 | /// RequestInputEvents() or RequestFilteringInputEvents(). By |
| 175 | /// default, no events are delivered. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 176 | /// |
[email protected] | 8327722 | 2014-04-10 18:40:07 | [diff] [blame] | 177 | /// If the event was handled, it will not be forwarded to any default |
| 178 | /// handlers. If it was not handled, it may be dispatched to a default |
| 179 | /// handler. So it is important that an instance respond accurately with |
| 180 | /// whether event propagation should continue. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 181 | /// |
| 182 | /// Event propagation also controls focus. If you handle an event like a mouse |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 183 | /// event, typically the instance will be given focus. Returning false from |
| 184 | /// a filtered event handler or not registering for an event type means that |
| 185 | /// the click will be given to a lower part of the page and your instance will |
| 186 | /// not receive focus. This allows an instance to be partially transparent, |
| 187 | /// where clicks on the transparent areas will behave like clicks to the |
| 188 | /// underlying page. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 189 | /// |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 190 | /// In general, you should try to keep input event handling short. Especially |
| 191 | /// for filtered input events, the browser or page may be blocked waiting for |
| 192 | /// you to respond. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 193 | /// |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 194 | /// The caller of this function will maintain a reference to the input event |
| 195 | /// resource during this call. Unless you take a reference to the resource |
| 196 | /// to hold it for later, you don't need to release it. |
| 197 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 198 | /// <strong>Note: </strong>If you're not receiving input events, make sure |
| 199 | /// you register for the event classes you want by calling |
| 200 | /// <code>RequestInputEvents</code> or |
| 201 | /// <code>RequestFilteringInputEvents</code>. If you're still not receiving |
| 202 | /// keyboard input events, make sure you're returning true (or using a |
| 203 | /// non-filtered event handler) for mouse events. Otherwise, the instance will |
| 204 | /// not receive focus and keyboard events will not be sent. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 205 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 206 | /// Refer to <code>RequestInputEvents</code> and |
| 207 | /// <code>RequestFilteringInputEvents</code> for further information. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 208 | /// |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 209 | /// @param[in] event The event to handle. |
| 210 | /// |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 211 | /// @return true if the event was handled, false if not. If you have |
| 212 | /// registered to filter this class of events by calling |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 213 | /// <code>RequestFilteringInputEvents</code>, and you return false, |
| 214 | /// the event will be forwarded to the page (and eventually the browser) |
| 215 | /// for the default handling. For non-filtered events, the return value |
| 216 | /// will be ignored. |
[email protected] | 13a8f49 | 2011-07-20 19:55:39 | [diff] [blame] | 217 | virtual bool HandleInputEvent(const pp::InputEvent& event); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 218 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 219 | /// HandleDocumentLoad() is called after Init() for a full-frame |
| 220 | /// instance that was instantiated based on the MIME type of a DOMWindow |
| 221 | /// navigation. This situation only applies to modules that are |
| 222 | /// pre-registered to handle certain MIME types. If you haven't specifically |
| 223 | /// registered to handle a MIME type or aren't positive this applies to you, |
| 224 | /// your implementation of this function can just return false. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 225 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 226 | /// The given url_loader corresponds to a <code>URLLoader</code> object that |
| 227 | /// is already opened. Its response headers may be queried using |
| 228 | /// GetResponseInfo(). If you want to use the <code>URLLoader</code> to read |
| 229 | /// data, you will need to save a copy of it or the underlying resource will |
| 230 | /// be freed when this function returns and the load will be canceled. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 231 | /// |
| 232 | /// This method returns false if the module cannot handle the data. In |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 233 | /// response to this method, the module should call ReadResponseBody() to read |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 234 | /// the incoming data. |
| 235 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 236 | /// @param[in] url_loader An open <code>URLLoader</code> instance. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 237 | /// |
| 238 | /// @return true if the data was handled, false otherwise. |
[email protected] | 5a3f6285 | 2010-11-10 21:43:01 | [diff] [blame] | 239 | virtual bool HandleDocumentLoad(const URLLoader& url_loader); |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 240 | |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 241 | /// HandleMessage() is a function that the browser calls when PostMessage() |
| 242 | /// is invoked on the DOM element for the instance in JavaScript. Note |
| 243 | /// that PostMessage() in the JavaScript interface is asynchronous, meaning |
| 244 | /// JavaScript execution will not be blocked while HandleMessage() is |
| 245 | /// processing the message. |
| 246 | /// |
[email protected] | b3e3595a9d | 2013-06-19 03:10:36 | [diff] [blame] | 247 | /// When converting JavaScript arrays, any object properties whose name |
| 248 | /// is not an array index are ignored. When passing arrays and objects, the |
| 249 | /// entire reference graph will be converted and transferred. If the reference |
| 250 | /// graph has cycles, the message will not be sent and an error will be logged |
| 251 | /// to the console. |
| 252 | /// |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 253 | /// <strong>Example:</strong> |
| 254 | /// |
| 255 | /// The following JavaScript code invokes <code>HandleMessage</code>, passing |
| 256 | /// the instance on which it was invoked, with <code>message</code> being a |
| 257 | /// string <code>Var</code> containing "Hello world!" |
| 258 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 259 | /// @code{.html} |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 260 | /// |
| 261 | /// <body> |
| 262 | /// <object id="plugin" |
| 263 | /// type="application/x-ppapi-postMessage-example"/> |
| 264 | /// <script type="text/javascript"> |
| 265 | /// document.getElementById('plugin').postMessage("Hello world!"); |
| 266 | /// </script> |
| 267 | /// </body> |
| 268 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 269 | /// @endcode |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 270 | /// |
| 271 | /// Refer to PostMessage() for sending messages to JavaScript. |
| 272 | /// |
[email protected] | b3e3595a9d | 2013-06-19 03:10:36 | [diff] [blame] | 273 | /// @param[in] message A <code>Var</code> which has been converted from a |
| 274 | /// JavaScript value. JavaScript array/object types are supported from Chrome |
| 275 | /// M29 onward. All JavaScript values are copied when passing them to the |
| 276 | /// plugin. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 277 | virtual void HandleMessage(const Var& message); |
| 278 | |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 279 | /// @} |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 280 | |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 281 | /// @{ |
| 282 | /// @name PPB_Instance methods for querying the browser: |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 283 | |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 284 | /// BindGraphics() binds the given graphics as the current display surface. |
| 285 | /// The contents of this device is what will be displayed in the instance's |
| 286 | /// area on the web page. The device must be a 2D or a 3D device. |
| 287 | /// |
| 288 | /// You can pass an <code>is_null()</code> (default constructed) Graphics2D |
| 289 | /// as the device parameter to unbind all devices from the given instance. |
| 290 | /// The instance will then appear transparent. Re-binding the same device |
| 291 | /// will return <code>true</code> and will do nothing. |
| 292 | /// |
| 293 | /// Any previously-bound device will be released. It is an error to bind |
| 294 | /// a device when it is already bound to another instance. If you want |
| 295 | /// to move a device between instances, first unbind it from the old one, and |
| 296 | /// then rebind it to the new one. |
| 297 | /// |
| 298 | /// Binding a device will invalidate that portion of the web page to flush the |
| 299 | /// contents of the new device to the screen. |
| 300 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 301 | /// @param[in] graphics A <code>Graphics2D</code> to bind. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 302 | /// |
| 303 | /// @return true if bind was successful or false if the device was not the |
| 304 | /// correct type. On success, a reference to the device will be held by the |
| 305 | /// instance, so the caller can release its reference if it chooses. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 306 | bool BindGraphics(const Graphics2D& graphics); |
| 307 | |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 308 | /// Binds the given Graphics3D as the current display surface. |
[email protected] | 44f4f31 | 2011-08-23 15:01:06 | [diff] [blame] | 309 | /// Refer to <code>BindGraphics(const Graphics2D& graphics)</code> for |
| 310 | /// further information. |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 311 | /// |
[email protected] | fae0e94 | 2011-09-07 17:10:46 | [diff] [blame] | 312 | /// @param[in] graphics A <code>Graphics3D</code> to bind. |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 313 | /// |
| 314 | /// @return true if bind was successful or false if the device was not the |
| 315 | /// correct type. On success, a reference to the device will be held by the |
| 316 | /// instance, so the caller can release its reference if it chooses. |
[email protected] | fae0e94 | 2011-09-07 17:10:46 | [diff] [blame] | 317 | bool BindGraphics(const Graphics3D& graphics); |
[email protected] | bd78a64 | 2011-07-19 20:31:44 | [diff] [blame] | 318 | |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 319 | /// IsFullFrame() determines if the instance is full-frame (repr). |
| 320 | /// Such an instance represents the entire document in a frame rather than an |
| 321 | /// embedded resource. This can happen if the user does a top-level |
| 322 | /// navigation or the page specifies an iframe to a resource with a MIME |
| 323 | /// type registered by the module. |
| 324 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 325 | /// @return true if the instance is full-frame, false if not. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 326 | bool IsFullFrame(); |
| 327 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 328 | /// RequestInputEvents() requests that input events corresponding to the |
| 329 | /// given input events are delivered to the instance. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 330 | /// |
| 331 | /// By default, no input events are delivered. Call this function with the |
| 332 | /// classes of events you are interested in to have them be delivered to |
| 333 | /// the instance. Calling this function will override any previous setting for |
| 334 | /// each specified class of input events (for example, if you previously |
| 335 | /// called RequestFilteringInputEvents(), this function will set those events |
| 336 | /// to non-filtering mode). |
| 337 | /// |
| 338 | /// Input events may have high overhead, so you should only request input |
| 339 | /// events that your plugin will actually handle. For example, the browser may |
| 340 | /// do optimizations for scroll or touch events that can be processed |
| 341 | /// substantially faster if it knows there are no non-default receivers for |
| 342 | /// that message. Requesting that such messages be delivered, even if they are |
[email protected] | 935d00fd | 2013-03-29 22:26:15 | [diff] [blame] | 343 | /// processed very quickly, may have a noticeable effect on the performance of |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 344 | /// the page. |
| 345 | /// |
| 346 | /// When requesting input events through this function, the events will be |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 347 | /// delivered and <em>not</em> bubbled to the page. This means that even if |
| 348 | /// you aren't interested in the message, no other parts of the page will get |
| 349 | /// the message. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 350 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 351 | /// <strong>Example:</strong> |
| 352 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 353 | /// @code |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 354 | /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
| 355 | /// RequestFilteringInputEvents( |
| 356 | /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
| 357 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 358 | /// @endcode |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 359 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 360 | /// @param event_classes A combination of flags from |
| 361 | /// <code>PP_InputEvent_Class</code> that identifies the classes of events |
| 362 | /// the instance is requesting. The flags are combined by logically ORing |
| 363 | /// their values. |
| 364 | /// |
| 365 | /// @return <code>PP_OK</code> if the operation succeeded, |
| 366 | /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
| 367 | /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 368 | /// illegal. In the case of an invalid bit, all valid bits will be applied |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 369 | /// and only the illegal bits will be ignored. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 370 | int32_t RequestInputEvents(uint32_t event_classes); |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 371 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 372 | /// RequestFilteringInputEvents() requests that input events corresponding |
| 373 | /// to the given input events are delivered to the instance for filtering. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 374 | /// |
| 375 | /// By default, no input events are delivered. In most cases you would |
| 376 | /// register to receive events by calling RequestInputEvents(). In some cases, |
| 377 | /// however, you may wish to filter events such that they can be bubbled up |
| 378 | /// to the DOM. In this case, register for those classes of events using |
| 379 | /// this function instead of RequestInputEvents(). Keyboard events must always |
| 380 | /// be registered in filtering mode. |
| 381 | /// |
| 382 | /// Filtering input events requires significantly more overhead than just |
| 383 | /// delivering them to the instance. As such, you should only request |
| 384 | /// filtering in those cases where it's absolutely necessary. The reason is |
| 385 | /// that it requires the browser to stop and block for the instance to handle |
| 386 | /// the input event, rather than sending the input event asynchronously. This |
| 387 | /// can have significant overhead. |
| 388 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 389 | /// <strong>Example:</strong> |
| 390 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 391 | /// @code |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 392 | /// |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 393 | /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
| 394 | /// RequestFilteringInputEvents( |
| 395 | /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
| 396 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 397 | /// @endcode |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 398 | /// |
| 399 | /// @param event_classes A combination of flags from |
| 400 | /// <code>PP_InputEvent_Class</code> that identifies the classes of events |
| 401 | /// the instance is requesting. The flags are combined by logically ORing |
| 402 | /// their values. |
| 403 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 404 | /// @return <code>PP_OK</code> if the operation succeeded, |
| 405 | /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
| 406 | /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 407 | /// illegal. In the case of an invalid bit, all valid bits will be applied |
| 408 | /// and only the illegal bits will be ignored. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 409 | int32_t RequestFilteringInputEvents(uint32_t event_classes); |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 410 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 411 | /// ClearInputEventRequest() requests that input events corresponding to the |
| 412 | /// given input classes no longer be delivered to the instance. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 413 | /// |
| 414 | /// By default, no input events are delivered. If you have previously |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 415 | /// requested input events using RequestInputEvents() or |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 416 | /// RequestFilteringInputEvents(), this function will unregister handling |
| 417 | /// for the given instance. This will allow greater browser performance for |
| 418 | /// those events. |
| 419 | /// |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 420 | /// <strong>Note: </strong> You may still get some input events after |
| 421 | /// clearing the flag if they were dispatched before the request was cleared. |
| 422 | /// For example, if there are 3 mouse move events waiting to be delivered, |
| 423 | /// and you clear the mouse event class during the processing of the first |
| 424 | /// one, you'll still receive the next two. You just won't get more events |
| 425 | /// generated. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 426 | /// |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 427 | /// @param[in] event_classes A combination of flags from |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 428 | /// <code>PP_InputEvent_Class</code> that identifies the classes of events the |
| 429 | /// instance is no longer interested in. |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 430 | void ClearInputEventRequest(uint32_t event_classes); |
| 431 | |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 432 | /// PostMessage() asynchronously invokes any listeners for message events on |
| 433 | /// the DOM element for the given instance. A call to PostMessage() will |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 434 | /// not block while the message is processed. |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 435 | /// |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 436 | /// <strong>Example:</strong> |
| 437 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 438 | /// @code{.html} |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 439 | /// |
| 440 | /// <body> |
| 441 | /// <object id="plugin" |
| 442 | /// type="application/x-ppapi-postMessage-example"/> |
| 443 | /// <script type="text/javascript"> |
| 444 | /// var plugin = document.getElementById('plugin'); |
[email protected] | 9071a3c | 2012-04-27 00:46:32 | [diff] [blame] | 445 | /// plugin.addEventListener("message", |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 446 | /// function(message) { alert(message.data); }, |
| 447 | /// false); |
| 448 | /// </script> |
| 449 | /// </body> |
| 450 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 451 | /// @endcode |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 452 | /// |
| 453 | /// The instance then invokes PostMessage() as follows: |
| 454 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 455 | /// @code |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 456 | /// |
| 457 | /// PostMessage(pp::Var("Hello world!")); |
| 458 | /// |
[email protected] | febbb9c | 2013-04-09 18:40:17 | [diff] [blame] | 459 | /// @endcode |
[email protected] | d912c698 | 2011-07-20 22:04:32 | [diff] [blame] | 460 | /// |
| 461 | /// The browser will pop-up an alert saying "Hello world!" |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 462 | /// |
[email protected] | b3e3595a9d | 2013-06-19 03:10:36 | [diff] [blame] | 463 | /// When passing array or dictionary <code>PP_Var</code>s, the entire |
| 464 | /// reference graph will be converted and transferred. If the reference graph |
| 465 | /// has cycles, the message will not be sent and an error will be logged to |
| 466 | /// the console. |
| 467 | /// |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 468 | /// Listeners for message events in JavaScript code will receive an object |
| 469 | /// conforming to the HTML 5 <code>MessageEvent</code> interface. |
| 470 | /// Specifically, the value of message will be contained as a property called |
| 471 | /// data in the received <code>MessageEvent</code>. |
| 472 | /// |
| 473 | /// This messaging system is similar to the system used for listening for |
| 474 | /// messages from Web Workers. Refer to |
| 475 | /// <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for |
| 476 | /// further information. |
| 477 | /// |
| 478 | /// Refer to HandleMessage() for receiving events from JavaScript. |
| 479 | /// |
| 480 | /// @param[in] message A <code>Var</code> containing the data to be sent to |
[email protected] | b3e3595a9d | 2013-06-19 03:10:36 | [diff] [blame] | 481 | /// JavaScript. Message can have a numeric, boolean, or string value. |
| 482 | /// Array/Dictionary types are supported from Chrome M29 onward. |
| 483 | /// All var types are copied when passing them to JavaScript. |
[email protected] | 9888f13 | 2011-03-23 21:07:15 | [diff] [blame] | 484 | void PostMessage(const Var& message); |
| 485 | |
dmichael | b873791 | 2014-09-18 18:00:29 | [diff] [blame] | 486 | /// Dev-Channel Only |
| 487 | /// |
| 488 | /// Registers a handler for receiving messages from JavaScript. If a handler |
| 489 | /// is registered this way, it will replace the Instance's HandleMessage |
| 490 | /// method, and all messages sent from JavaScript via postMessage and |
| 491 | /// postMessageAndAwaitResponse will be dispatched to |
| 492 | /// <code>message_handler</code>. |
| 493 | /// |
| 494 | /// The function calls will be dispatched via <code>message_loop</code>. This |
| 495 | /// means that the functions will be invoked on the thread to which |
| 496 | /// <code>message_loop</code> is attached, when <code>message_loop</code> is |
| 497 | /// run. It is illegal to pass the main thread message loop; |
| 498 | /// RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. |
| 499 | /// If you quit <code>message_loop</code> before calling Unregister(), |
| 500 | /// the browser will not be able to call functions in the plugin's message |
| 501 | /// handler any more. That could mean missing some messages or could cause a |
| 502 | /// leak if you depend on Destroy() to free hander data. So you should, |
| 503 | /// whenever possible, Unregister() the handler prior to quitting its event |
| 504 | /// loop. |
| 505 | /// |
| 506 | /// Attempting to register a message handler when one is already registered |
| 507 | /// will cause the current MessageHandler to be unregistered and replaced. In |
| 508 | /// that case, no messages will be sent to the "default" message handler |
| 509 | /// (pp::Instance::HandleMessage()). Messages will stop arriving at the prior |
| 510 | /// message handler and will begin to be dispatched at the new message |
| 511 | /// handler. |
| 512 | /// |
| 513 | /// @param[in] message_handler The plugin-provided object for handling |
| 514 | /// messages. The instance does not take ownership of the pointer; it is up |
| 515 | /// to the plugin to ensure that |message_handler| lives until its |
| 516 | /// WasUnregistered() function is invoked. |
| 517 | /// @param[in] message_loop Represents the message loop on which |
| 518 | /// MessageHandler's functions should be invoked. |
| 519 | /// @return PP_OK on success, or an error from pp_errors.h. |
| 520 | int32_t RegisterMessageHandler(MessageHandler* message_handler, |
| 521 | const MessageLoop& message_loop); |
| 522 | |
| 523 | /// Unregisters the current message handler for this instance if one is |
| 524 | /// registered. After this call, the message handler (if one was |
| 525 | /// registered) will have "WasUnregistered" called on it and will receive no |
| 526 | /// further messages. After that point, all messages sent from JavaScript |
| 527 | /// using postMessage() will be dispatched to pp::Instance::HandleMessage() |
| 528 | /// on the main thread. Attempts to call postMessageAndAwaitResponse() from |
| 529 | /// JavaScript after that point will fail. |
| 530 | /// |
| 531 | /// Attempting to unregister a message handler when none is registered has no |
| 532 | /// effect. |
| 533 | void UnregisterMessageHandler(); |
| 534 | |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 535 | /// @} |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 536 | |
[email protected] | 598816ad | 2012-12-13 01:34:32 | [diff] [blame] | 537 | /// @{ |
| 538 | /// @name PPB_Console methods for logging to the console: |
| 539 | |
| 540 | /// Logs the given message to the JavaScript console associated with the |
| 541 | /// given plugin instance with the given logging level. The name of the plugin |
| 542 | /// issuing the log message will be automatically prepended to the message. |
| 543 | /// The value may be any type of Var. |
| 544 | void LogToConsole(PP_LogLevel level, const Var& value); |
| 545 | |
| 546 | /// Logs a message to the console with the given source information rather |
| 547 | /// than using the internal PPAPI plugin name. The name must be a string var. |
| 548 | /// |
| 549 | /// The regular log function will automatically prepend the name of your |
| 550 | /// plugin to the message as the "source" of the message. Some plugins may |
| 551 | /// wish to override this. For example, if your plugin is a Python |
| 552 | /// interpreter, you would want log messages to contain the source .py file |
| 553 | /// doing the log statement rather than have "python" show up in the console. |
| 554 | void LogToConsoleWithSource(PP_LogLevel level, |
| 555 | const Var& source, |
| 556 | const Var& value); |
| 557 | |
| 558 | /// @} |
| 559 | |
[email protected] | 8d64cf39 | 2011-08-09 22:17:15 | [diff] [blame] | 560 | /// AddPerInstanceObject() associates an instance with an interface, |
[email protected] | f1a0afd | 2012-02-16 19:33:07 | [diff] [blame] | 561 | /// creating an object. |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 562 | /// |
| 563 | /// Many optional interfaces are associated with a plugin instance. For |
| 564 | /// example, the find in PPP_Find interface receives updates on a per-instance |
| 565 | /// basis. This "per-instance" tracking allows such objects to associate |
| 566 | /// themselves with an instance as "the" handler for that interface name. |
| 567 | /// |
| 568 | /// In the case of the find example, the find object registers with its |
| 569 | /// associated instance in its constructor and unregisters in its destructor. |
| 570 | /// Then whenever it gets updates with a PP_Instance parameter, it can |
| 571 | /// map back to the find object corresponding to that given PP_Instance by |
| 572 | /// calling GetPerInstanceObject. |
| 573 | /// |
| 574 | /// This lookup is done on a per-interface-name basis. This means you can |
| 575 | /// only have one object of a given interface name associated with an |
| 576 | /// instance. |
| 577 | /// |
| 578 | /// If you are adding a handler for an additional interface, be sure to |
| 579 | /// register with the module (AddPluginInterface) for your interface name to |
| 580 | /// get the C calls in the first place. |
| 581 | /// |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 582 | /// Refer to RemovePerInstanceObject() and GetPerInstanceObject() for further |
| 583 | /// information. |
| 584 | /// |
| 585 | /// @param[in] interface_name The name of the interface to associate with the |
| 586 | /// instance |
| 587 | /// @param[in] object |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 588 | void AddPerInstanceObject(const std::string& interface_name, void* object); |
| 589 | |
[email protected] | f1a0afd | 2012-02-16 19:33:07 | [diff] [blame] | 590 | // {PENDING: summarize Remove method here} |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 591 | /// |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 592 | /// Refer to AddPerInstanceObject() for further information. |
| 593 | /// |
| 594 | /// @param[in] interface_name The name of the interface to associate with the |
| 595 | /// instance |
| 596 | /// @param[in] object |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 597 | void RemovePerInstanceObject(const std::string& interface_name, void* object); |
| 598 | |
[email protected] | 09af0f7 | 2012-02-27 20:23:19 | [diff] [blame] | 599 | /// Static version of AddPerInstanceObject that takes an InstanceHandle. As |
| 600 | /// with all other instance functions, this must only be called on the main |
| 601 | /// thread. |
| 602 | static void RemovePerInstanceObject(const InstanceHandle& instance, |
| 603 | const std::string& interface_name, |
| 604 | void* object); |
| 605 | |
[email protected] | 25d6efe | 2011-06-15 15:39:58 | [diff] [blame] | 606 | /// Look up an object previously associated with an instance. Returns NULL |
| 607 | /// if the instance is invalid or there is no object for the given interface |
| 608 | /// name on the instance. |
| 609 | /// |
[email protected] | 63e627d | 2011-08-16 19:15:31 | [diff] [blame] | 610 | /// Refer to AddPerInstanceObject() for further information. |
| 611 | /// |
| 612 | /// @param[in] instance |
| 613 | /// @param[in] interface_name The name of the interface to associate with the |
| 614 | /// instance. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 615 | static void* GetPerInstanceObject(PP_Instance instance, |
| 616 | const std::string& interface_name); |
| 617 | |
| 618 | private: |
| 619 | PP_Instance pp_instance_; |
| 620 | |
| 621 | typedef std::map<std::string, void*> InterfaceNameToObjectMap; |
| 622 | InterfaceNameToObjectMap interface_name_to_objects_; |
| 623 | }; |
| 624 | |
| 625 | } // namespace pp |
| 626 | |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 627 | #endif // PPAPI_CPP_INSTANCE_H_ |