OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_INSTANCE_H_ | 5 #ifndef PPAPI_CPP_INSTANCE_H_ |
6 #define PPAPI_CPP_INSTANCE_H_ | 6 #define PPAPI_CPP_INSTANCE_H_ |
7 | 7 |
8 /// @file | 8 /// @file |
9 /// Defines the C++ wrapper for an instance. | 9 /// Defines the C++ wrapper for an instance. |
10 | 10 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 /// that PostMessage() in the JavaScript interface is asynchronous, meaning | 216 /// that PostMessage() in the JavaScript interface is asynchronous, meaning |
217 /// JavaScript execution will not be blocked while HandleMessage() is | 217 /// JavaScript execution will not be blocked while HandleMessage() is |
218 /// processing the message. | 218 /// processing the message. |
219 /// | 219 /// |
220 /// <strong>Example:</strong> | 220 /// <strong>Example:</strong> |
221 /// | 221 /// |
222 /// The following JavaScript code invokes <code>HandleMessage</code>, passing | 222 /// The following JavaScript code invokes <code>HandleMessage</code>, passing |
223 /// the instance on which it was invoked, with <code>message</code> being a | 223 /// the instance on which it was invoked, with <code>message</code> being a |
224 /// string <code>Var</code> containing "Hello world!" | 224 /// string <code>Var</code> containing "Hello world!" |
225 /// | 225 /// |
226 /// @code | 226 /// <code> |
227 /// | 227 /// |
228 /// <body> | 228 /// <body> |
229 /// <object id="plugin" | 229 /// <object id="plugin" |
230 /// type="application/x-ppapi-postMessage-example"/> | 230 /// type="application/x-ppapi-postMessage-example"/> |
231 /// <script type="text/javascript"> | 231 /// <script type="text/javascript"> |
232 /// document.getElementById('plugin').postMessage("Hello world!"); | 232 /// document.getElementById('plugin').postMessage("Hello world!"); |
233 /// </script> | 233 /// </script> |
234 /// </body> | 234 /// </body> |
235 /// | 235 /// |
236 /// @endcode | 236 /// </code> |
237 /// | 237 /// |
238 /// Refer to PostMessage() for sending messages to JavaScript. | 238 /// Refer to PostMessage() for sending messages to JavaScript. |
239 /// | 239 /// |
240 /// @param[in] message A <code>Var</code> containing the data sent from | 240 /// @param[in] message A <code>Var</code> containing the data sent from |
241 /// JavaScript. Message can have an int32_t, double, bool, or string value | 241 /// JavaScript. Message can have an int32_t, double, bool, or string value |
242 /// (objects are not supported). | 242 /// (objects are not supported). |
243 virtual void HandleMessage(const Var& message); | 243 virtual void HandleMessage(const Var& message); |
244 | 244 |
245 /// @} | 245 /// @} |
246 | 246 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 /// processed very quickly, may have a noticable effect on the performance of | 320 /// processed very quickly, may have a noticable effect on the performance of |
321 /// the page. | 321 /// the page. |
322 /// | 322 /// |
323 /// When requesting input events through this function, the events will be | 323 /// When requesting input events through this function, the events will be |
324 /// delivered and <em>not</em> bubbled to the page. This means that even if | 324 /// delivered and <em>not</em> bubbled to the page. This means that even if |
325 /// you aren't interested in the message, no other parts of the page will get | 325 /// you aren't interested in the message, no other parts of the page will get |
326 /// the message. | 326 /// the message. |
327 /// | 327 /// |
328 /// <strong>Example:</strong> | 328 /// <strong>Example:</strong> |
329 /// | 329 /// |
330 /// @code | 330 /// <code> |
331 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); | 331 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
332 /// RequestFilteringInputEvents( | 332 /// RequestFilteringInputEvents( |
333 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); | 333 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
334 /// | 334 /// |
335 /// @endcode | 335 /// </code> |
336 /// | 336 /// |
337 /// @param event_classes A combination of flags from | 337 /// @param event_classes A combination of flags from |
338 /// <code>PP_InputEvent_Class</code> that identifies the classes of events | 338 /// <code>PP_InputEvent_Class</code> that identifies the classes of events |
339 /// the instance is requesting. The flags are combined by logically ORing | 339 /// the instance is requesting. The flags are combined by logically ORing |
340 /// their values. | 340 /// their values. |
341 /// | 341 /// |
342 /// @return <code>PP_OK</code> if the operation succeeded, | 342 /// @return <code>PP_OK</code> if the operation succeeded, |
343 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or | 343 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
344 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were | 344 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
345 /// illegal. In the case of an invalid bit, all valid bits will be applied | 345 /// illegal. In the case of an invalid bit, all valid bits will be applied |
(...skipping 12 matching lines...) Expand all Loading... |
358 /// | 358 /// |
359 /// Filtering input events requires significantly more overhead than just | 359 /// Filtering input events requires significantly more overhead than just |
360 /// delivering them to the instance. As such, you should only request | 360 /// delivering them to the instance. As such, you should only request |
361 /// filtering in those cases where it's absolutely necessary. The reason is | 361 /// filtering in those cases where it's absolutely necessary. The reason is |
362 /// that it requires the browser to stop and block for the instance to handle | 362 /// that it requires the browser to stop and block for the instance to handle |
363 /// the input event, rather than sending the input event asynchronously. This | 363 /// the input event, rather than sending the input event asynchronously. This |
364 /// can have significant overhead. | 364 /// can have significant overhead. |
365 /// | 365 /// |
366 /// <strong>Example:</strong> | 366 /// <strong>Example:</strong> |
367 /// | 367 /// |
368 /// @code | 368 /// <code> |
369 /// | 369 /// |
370 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); | 370 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
371 /// RequestFilteringInputEvents( | 371 /// RequestFilteringInputEvents( |
372 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); | 372 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
373 /// | 373 /// |
374 /// @endcode | 374 /// </code> |
375 /// | 375 /// |
376 /// @param event_classes A combination of flags from | 376 /// @param event_classes A combination of flags from |
377 /// <code>PP_InputEvent_Class</code> that identifies the classes of events | 377 /// <code>PP_InputEvent_Class</code> that identifies the classes of events |
378 /// the instance is requesting. The flags are combined by logically ORing | 378 /// the instance is requesting. The flags are combined by logically ORing |
379 /// their values. | 379 /// their values. |
380 /// | 380 /// |
381 /// @return <code>PP_OK</code> if the operation succeeded, | 381 /// @return <code>PP_OK</code> if the operation succeeded, |
382 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or | 382 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
383 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were | 383 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
384 /// illegal. In the case of an invalid bit, all valid bits will be applied | 384 /// illegal. In the case of an invalid bit, all valid bits will be applied |
(...skipping 20 matching lines...) Expand all Loading... |
405 /// <code>PP_InputEvent_Class</code> that identifies the classes of events the | 405 /// <code>PP_InputEvent_Class</code> that identifies the classes of events the |
406 /// instance is no longer interested in. | 406 /// instance is no longer interested in. |
407 void ClearInputEventRequest(uint32_t event_classes); | 407 void ClearInputEventRequest(uint32_t event_classes); |
408 | 408 |
409 /// PostMessage() asynchronously invokes any listeners for message events on | 409 /// PostMessage() asynchronously invokes any listeners for message events on |
410 /// the DOM element for the given instance. A call to PostMessage() will | 410 /// the DOM element for the given instance. A call to PostMessage() will |
411 /// not block while the message is processed. | 411 /// not block while the message is processed. |
412 /// | 412 /// |
413 /// <strong>Example:</strong> | 413 /// <strong>Example:</strong> |
414 /// | 414 /// |
415 /// @code | 415 /// <code> |
416 /// | 416 /// |
417 /// <body> | 417 /// <body> |
418 /// <object id="plugin" | 418 /// <object id="plugin" |
419 /// type="application/x-ppapi-postMessage-example"/> | 419 /// type="application/x-ppapi-postMessage-example"/> |
420 /// <script type="text/javascript"> | 420 /// <script type="text/javascript"> |
421 /// var plugin = document.getElementById('plugin'); | 421 /// var plugin = document.getElementById('plugin'); |
422 /// plugin.AddEventListener("message", | 422 /// plugin.AddEventListener("message", |
423 /// function(message) { alert(message.data); }, | 423 /// function(message) { alert(message.data); }, |
424 /// false); | 424 /// false); |
425 /// </script> | 425 /// </script> |
426 /// </body> | 426 /// </body> |
427 /// | 427 /// |
428 /// @endcode | 428 /// </code> |
429 /// | 429 /// |
430 /// The instance then invokes PostMessage() as follows: | 430 /// The instance then invokes PostMessage() as follows: |
431 /// | 431 /// |
432 /// @code | 432 /// <code> |
433 /// | 433 /// |
434 /// PostMessage(pp::Var("Hello world!")); | 434 /// PostMessage(pp::Var("Hello world!")); |
435 /// | 435 /// |
436 /// @endcode | 436 /// </code> |
437 /// | 437 /// |
438 /// The browser will pop-up an alert saying "Hello world!" | 438 /// The browser will pop-up an alert saying "Hello world!" |
439 /// | 439 /// |
440 /// Listeners for message events in JavaScript code will receive an object | 440 /// Listeners for message events in JavaScript code will receive an object |
441 /// conforming to the HTML 5 <code>MessageEvent</code> interface. | 441 /// conforming to the HTML 5 <code>MessageEvent</code> interface. |
442 /// Specifically, the value of message will be contained as a property called | 442 /// Specifically, the value of message will be contained as a property called |
443 /// data in the received <code>MessageEvent</code>. | 443 /// data in the received <code>MessageEvent</code>. |
444 /// | 444 /// |
445 /// This messaging system is similar to the system used for listening for | 445 /// This messaging system is similar to the system used for listening for |
446 /// messages from Web Workers. Refer to | 446 /// messages from Web Workers. Refer to |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 private: | 511 private: |
512 PP_Instance pp_instance_; | 512 PP_Instance pp_instance_; |
513 | 513 |
514 typedef std::map<std::string, void*> InterfaceNameToObjectMap; | 514 typedef std::map<std::string, void*> InterfaceNameToObjectMap; |
515 InterfaceNameToObjectMap interface_name_to_objects_; | 515 InterfaceNameToObjectMap interface_name_to_objects_; |
516 }; | 516 }; |
517 | 517 |
518 } // namespace pp | 518 } // namespace pp |
519 | 519 |
520 #endif // PPAPI_CPP_INSTANCE_H_ | 520 #endif // PPAPI_CPP_INSTANCE_H_ |
OLD | NEW |