OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 /// This file defines the C++ wrapper for an instance. | 9 /// This file defines the C++ wrapper for an instance. |
10 | 10 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 /// that PostMessage() in the JavaScript interface is asynchronous, meaning | 243 /// that PostMessage() in the JavaScript interface is asynchronous, meaning |
244 /// JavaScript execution will not be blocked while HandleMessage() is | 244 /// JavaScript execution will not be blocked while HandleMessage() is |
245 /// processing the message. | 245 /// processing the message. |
246 /// | 246 /// |
247 /// <strong>Example:</strong> | 247 /// <strong>Example:</strong> |
248 /// | 248 /// |
249 /// The following JavaScript code invokes <code>HandleMessage</code>, passing | 249 /// The following JavaScript code invokes <code>HandleMessage</code>, passing |
250 /// the instance on which it was invoked, with <code>message</code> being a | 250 /// the instance on which it was invoked, with <code>message</code> being a |
251 /// string <code>Var</code> containing "Hello world!" | 251 /// string <code>Var</code> containing "Hello world!" |
252 /// | 252 /// |
253 /// <code> | 253 /// @code{.html} |
254 /// | 254 /// |
255 /// <body> | 255 /// <body> |
256 /// <object id="plugin" | 256 /// <object id="plugin" |
257 /// type="application/x-ppapi-postMessage-example"/> | 257 /// type="application/x-ppapi-postMessage-example"/> |
258 /// <script type="text/javascript"> | 258 /// <script type="text/javascript"> |
259 /// document.getElementById('plugin').postMessage("Hello world!"); | 259 /// document.getElementById('plugin').postMessage("Hello world!"); |
260 /// </script> | 260 /// </script> |
261 /// </body> | 261 /// </body> |
262 /// | 262 /// |
263 /// </code> | 263 /// @endcode |
264 /// | 264 /// |
265 /// Refer to PostMessage() for sending messages to JavaScript. | 265 /// Refer to PostMessage() for sending messages to JavaScript. |
266 /// | 266 /// |
267 /// @param[in] message A <code>Var</code> containing the data sent from | 267 /// @param[in] message A <code>Var</code> containing the data sent from |
268 /// JavaScript. Message can have an int32_t, double, bool, or string value | 268 /// JavaScript. Message can have an int32_t, double, bool, or string value |
269 /// (objects are not supported). | 269 /// (objects are not supported). |
270 virtual void HandleMessage(const Var& message); | 270 virtual void HandleMessage(const Var& message); |
271 | 271 |
272 /// @} | 272 /// @} |
273 | 273 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 /// processed very quickly, may have a noticeable effect on the performance of | 336 /// processed very quickly, may have a noticeable effect on the performance of |
337 /// the page. | 337 /// the page. |
338 /// | 338 /// |
339 /// When requesting input events through this function, the events will be | 339 /// When requesting input events through this function, the events will be |
340 /// delivered and <em>not</em> bubbled to the page. This means that even if | 340 /// delivered and <em>not</em> bubbled to the page. This means that even if |
341 /// you aren't interested in the message, no other parts of the page will get | 341 /// you aren't interested in the message, no other parts of the page will get |
342 /// the message. | 342 /// the message. |
343 /// | 343 /// |
344 /// <strong>Example:</strong> | 344 /// <strong>Example:</strong> |
345 /// | 345 /// |
346 /// <code> | 346 /// @code |
347 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); | 347 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
348 /// RequestFilteringInputEvents( | 348 /// RequestFilteringInputEvents( |
349 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); | 349 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
350 /// | 350 /// |
351 /// </code> | 351 /// @endcode |
352 /// | 352 /// |
353 /// @param event_classes A combination of flags from | 353 /// @param event_classes A combination of flags from |
354 /// <code>PP_InputEvent_Class</code> that identifies the classes of events | 354 /// <code>PP_InputEvent_Class</code> that identifies the classes of events |
355 /// the instance is requesting. The flags are combined by logically ORing | 355 /// the instance is requesting. The flags are combined by logically ORing |
356 /// their values. | 356 /// their values. |
357 /// | 357 /// |
358 /// @return <code>PP_OK</code> if the operation succeeded, | 358 /// @return <code>PP_OK</code> if the operation succeeded, |
359 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or | 359 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
360 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were | 360 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
361 /// illegal. In the case of an invalid bit, all valid bits will be applied | 361 /// illegal. In the case of an invalid bit, all valid bits will be applied |
(...skipping 12 matching lines...) Expand all Loading... |
374 /// | 374 /// |
375 /// Filtering input events requires significantly more overhead than just | 375 /// Filtering input events requires significantly more overhead than just |
376 /// delivering them to the instance. As such, you should only request | 376 /// delivering them to the instance. As such, you should only request |
377 /// filtering in those cases where it's absolutely necessary. The reason is | 377 /// filtering in those cases where it's absolutely necessary. The reason is |
378 /// that it requires the browser to stop and block for the instance to handle | 378 /// that it requires the browser to stop and block for the instance to handle |
379 /// the input event, rather than sending the input event asynchronously. This | 379 /// the input event, rather than sending the input event asynchronously. This |
380 /// can have significant overhead. | 380 /// can have significant overhead. |
381 /// | 381 /// |
382 /// <strong>Example:</strong> | 382 /// <strong>Example:</strong> |
383 /// | 383 /// |
384 /// <code> | 384 /// @code |
385 /// | 385 /// |
386 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); | 386 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
387 /// RequestFilteringInputEvents( | 387 /// RequestFilteringInputEvents( |
388 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); | 388 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
389 /// | 389 /// |
390 /// </code> | 390 /// @endcode |
391 /// | 391 /// |
392 /// @param event_classes A combination of flags from | 392 /// @param event_classes A combination of flags from |
393 /// <code>PP_InputEvent_Class</code> that identifies the classes of events | 393 /// <code>PP_InputEvent_Class</code> that identifies the classes of events |
394 /// the instance is requesting. The flags are combined by logically ORing | 394 /// the instance is requesting. The flags are combined by logically ORing |
395 /// their values. | 395 /// their values. |
396 /// | 396 /// |
397 /// @return <code>PP_OK</code> if the operation succeeded, | 397 /// @return <code>PP_OK</code> if the operation succeeded, |
398 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or | 398 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
399 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were | 399 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
400 /// illegal. In the case of an invalid bit, all valid bits will be applied | 400 /// illegal. In the case of an invalid bit, all valid bits will be applied |
(...skipping 20 matching lines...) Expand all Loading... |
421 /// <code>PP_InputEvent_Class</code> that identifies the classes of events the | 421 /// <code>PP_InputEvent_Class</code> that identifies the classes of events the |
422 /// instance is no longer interested in. | 422 /// instance is no longer interested in. |
423 void ClearInputEventRequest(uint32_t event_classes); | 423 void ClearInputEventRequest(uint32_t event_classes); |
424 | 424 |
425 /// PostMessage() asynchronously invokes any listeners for message events on | 425 /// PostMessage() asynchronously invokes any listeners for message events on |
426 /// the DOM element for the given instance. A call to PostMessage() will | 426 /// the DOM element for the given instance. A call to PostMessage() will |
427 /// not block while the message is processed. | 427 /// not block while the message is processed. |
428 /// | 428 /// |
429 /// <strong>Example:</strong> | 429 /// <strong>Example:</strong> |
430 /// | 430 /// |
431 /// <code> | 431 /// @code{.html} |
432 /// | 432 /// |
433 /// <body> | 433 /// <body> |
434 /// <object id="plugin" | 434 /// <object id="plugin" |
435 /// type="application/x-ppapi-postMessage-example"/> | 435 /// type="application/x-ppapi-postMessage-example"/> |
436 /// <script type="text/javascript"> | 436 /// <script type="text/javascript"> |
437 /// var plugin = document.getElementById('plugin'); | 437 /// var plugin = document.getElementById('plugin'); |
438 /// plugin.addEventListener("message", | 438 /// plugin.addEventListener("message", |
439 /// function(message) { alert(message.data); }, | 439 /// function(message) { alert(message.data); }, |
440 /// false); | 440 /// false); |
441 /// </script> | 441 /// </script> |
442 /// </body> | 442 /// </body> |
443 /// | 443 /// |
444 /// </code> | 444 /// @endcode |
445 /// | 445 /// |
446 /// The instance then invokes PostMessage() as follows: | 446 /// The instance then invokes PostMessage() as follows: |
447 /// | 447 /// |
448 /// <code> | 448 /// @code |
449 /// | 449 /// |
450 /// PostMessage(pp::Var("Hello world!")); | 450 /// PostMessage(pp::Var("Hello world!")); |
451 /// | 451 /// |
452 /// </code> | 452 /// @endcode |
453 /// | 453 /// |
454 /// The browser will pop-up an alert saying "Hello world!" | 454 /// The browser will pop-up an alert saying "Hello world!" |
455 /// | 455 /// |
456 /// Listeners for message events in JavaScript code will receive an object | 456 /// Listeners for message events in JavaScript code will receive an object |
457 /// conforming to the HTML 5 <code>MessageEvent</code> interface. | 457 /// conforming to the HTML 5 <code>MessageEvent</code> interface. |
458 /// Specifically, the value of message will be contained as a property called | 458 /// Specifically, the value of message will be contained as a property called |
459 /// data in the received <code>MessageEvent</code>. | 459 /// data in the received <code>MessageEvent</code>. |
460 /// | 460 /// |
461 /// This messaging system is similar to the system used for listening for | 461 /// This messaging system is similar to the system used for listening for |
462 /// messages from Web Workers. Refer to | 462 /// messages from Web Workers. Refer to |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 private: | 557 private: |
558 PP_Instance pp_instance_; | 558 PP_Instance pp_instance_; |
559 | 559 |
560 typedef std::map<std::string, void*> InterfaceNameToObjectMap; | 560 typedef std::map<std::string, void*> InterfaceNameToObjectMap; |
561 InterfaceNameToObjectMap interface_name_to_objects_; | 561 InterfaceNameToObjectMap interface_name_to_objects_; |
562 }; | 562 }; |
563 | 563 |
564 } // namespace pp | 564 } // namespace pp |
565 | 565 |
566 #endif // PPAPI_CPP_INSTANCE_H_ | 566 #endif // PPAPI_CPP_INSTANCE_H_ |
OLD | NEW |