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
;
15 class DictionaryValue
;
26 namespace extensions
{
29 class ObjectBackedNativeHandler
;
30 class ScriptContextSet
;
32 // Manually implements JavaScript bindings for extension messaging.
34 // TODO(aa): This should all get re-implemented using SchemaGeneratedBindings.
35 // If anything needs to be manual for some reason, it should be implemented in
37 class MessagingBindings
{
39 // Creates an instance of the extension.
40 static ObjectBackedNativeHandler
* Get(Dispatcher
* dispatcher
,
41 ScriptContext
* context
);
43 // Dispatches the onConnect content script messaging event to some contexts
44 // in |context_set|. If |restrict_to_render_view| is specified, only contexts
45 // in that render view will receive the message.
46 static void DispatchOnConnect(const ScriptContextSet
& context_set
,
48 const std::string
& channel_name
,
49 const base::DictionaryValue
& source_tab
,
50 const ExtensionMsg_ExternalConnectionInfo
& info
,
51 const std::string
& tls_channel_id
,
52 content::RenderView
* restrict_to_render_view
);
54 // Delivers a message sent using content script messaging to some of the
55 // contexts in |bindings_context_set|. If |restrict_to_render_view| is
56 // specified, only contexts in that render view will receive the message.
57 static void DeliverMessage(const ScriptContextSet
& context_set
,
59 const Message
& message
,
60 content::RenderView
* restrict_to_render_view
);
62 // Dispatches the onDisconnect event in response to the channel being closed.
63 static void DispatchOnDisconnect(
64 const ScriptContextSet
& context_set
,
66 const std::string
& error_message
,
67 content::RenderView
* restrict_to_render_view
);
70 } // namespace extensions
72 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_