1 // Copyright 2014 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.
5 #ifndef EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_
6 #define EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_
10 #include "extensions/renderer/script_context_set.h"
12 struct ExtensionMsg_ExternalConnectionInfo
;
13 struct ExtensionMsg_TabConnectionInfo
;
16 class DictionaryValue
;
27 namespace extensions
{
30 class ObjectBackedNativeHandler
;
31 class ScriptContextSet
;
33 // Manually implements JavaScript bindings for extension messaging.
35 // TODO(aa): This should all get re-implemented using SchemaGeneratedBindings.
36 // If anything needs to be manual for some reason, it should be implemented in
38 class MessagingBindings
{
40 // Creates an instance of the extension.
41 static ObjectBackedNativeHandler
* Get(Dispatcher
* dispatcher
,
42 ScriptContext
* context
);
44 // Dispatches the onConnect content script messaging event to some contexts
45 // in |context_set|. If |restrict_to_render_frame| is specified, only contexts
46 // in that render frame will receive the message.
47 static void DispatchOnConnect(const ScriptContextSet
& context_set
,
49 const std::string
& channel_name
,
50 const ExtensionMsg_TabConnectionInfo
& source
,
51 const ExtensionMsg_ExternalConnectionInfo
& info
,
52 const std::string
& tls_channel_id
,
53 content::RenderFrame
* restrict_to_render_frame
);
55 // Delivers a message sent using content script messaging to some of the
56 // contexts in |bindings_context_set|. If |restrict_to_render_frame| is
57 // specified, only contexts in that render view will receive the message.
58 static void DeliverMessage(const ScriptContextSet
& context_set
,
60 const Message
& message
,
61 content::RenderFrame
* restrict_to_render_frame
);
63 // Dispatches the onDisconnect event in response to the channel being closed.
64 static void DispatchOnDisconnect(
65 const ScriptContextSet
& context_set
,
67 const std::string
& error_message
,
68 content::RenderFrame
* restrict_to_render_frame
);
71 } // namespace extensions
73 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_