| Index: webkit/plugins/ppapi/message_channel.h
|
| ===================================================================
|
| --- webkit/plugins/ppapi/message_channel.h (revision 0)
|
| +++ webkit/plugins/ppapi/message_channel.h (revision 0)
|
| @@ -0,0 +1,81 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_
|
| +#define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_
|
| +
|
| +#include "third_party/npapi/bindings/npruntime.h"
|
| +#include "webkit/plugins/ppapi/resource.h"
|
| +
|
| +struct PP_Var;
|
| +
|
| +namespace webkit {
|
| +namespace ppapi {
|
| +
|
| +class PluginInstance;
|
| +
|
| +// MessageChannel implements bidirectional postMessage functionality, allowing
|
| +// calls from JavaScript to plugins and vice-versa. See
|
| +// PPB_Instance::PostMessage and PPP_Instance::HandleMessage for more
|
| +// information.
|
| +//
|
| +// Currently, only 1 MessageChannel can exist, to implement postMessage
|
| +// functionality for the instance interfaces. In the future, if we create a
|
| +// MessageChannel or MessagePort type in PPAPI, those may be implemented here
|
| +// as well with a small amount of refactoring.
|
| +//
|
| +class MessageChannel {
|
| + public:
|
| + // MessageChannelNPObject is a simple struct that adds a pointer back to a
|
| + // MessageChannel instance. This way, we can use an NPObject to allow
|
| + // JavaScript interactions without forcing MessageChannel to inherit from
|
| + // NPObject.
|
| + struct MessageChannelNPObject : public NPObject {
|
| + MessageChannelNPObject();
|
| + ~MessageChannelNPObject();
|
| +
|
| + MessageChannel* message_channel;
|
| + };
|
| +
|
| + explicit MessageChannel(PluginInstance* instance);
|
| + ~MessageChannel();
|
| +
|
| + void PostMessageToJavaScript(PP_Var message_data);
|
| + void PostMessageToNative(PP_Var message_data);
|
| +
|
| + // TODO(dmichael): Remove passthrough_object when PPB_Class and
|
| + // PPP_Class_Deprecated go away.
|
| + NPObject* passthrough_object() {
|
| + return passthrough_object_;
|
| + }
|
| + void set_passthrough_object(NPObject* passthrough) {
|
| + passthrough_object_ = passthrough;
|
| + }
|
| +
|
| + NPObject* np_object() { return np_object_; }
|
| +
|
| + PluginInstance* instance() {
|
| + return instance_;
|
| + }
|
| +
|
| + private:
|
| + PluginInstance* instance_;
|
| +
|
| + // To support backwards-compatibility, we pass all calls through to the
|
| + // passthrough_object_. This way, a plugin can use PPB_Class or
|
| + // PPP_Class_Deprecated and also postMessage.
|
| + // TODO(dmichael): Delete this if/when PPB_Class.* go away.
|
| + NPObject* passthrough_object_;
|
| +
|
| + // The NPObject we use to expose postMessage to JavaScript.
|
| + MessageChannelNPObject* np_object_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MessageChannel);
|
| +};
|
| +
|
| +} // namespace ppapi
|
| +} // namespace webkit
|
| +
|
| +#endif // WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_
|
| +
|
|
|
| Property changes on: webkit/plugins/ppapi/message_channel.h
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|