Standardize usage of virtual/override/final specifiers.
[chromium-blink-merge.git] / extensions / renderer / messaging_bindings.h
blob422dcae7ae9356f208f1cedea3471a3d7c142dda
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_
8 #include <string>
10 #include "extensions/renderer/script_context_set.h"
12 struct ExtensionMsg_ExternalConnectionInfo;
14 namespace base {
15 class DictionaryValue;
18 namespace content {
19 class RenderView;
22 namespace v8 {
23 class Extension;
26 namespace extensions {
27 class Dispatcher;
28 struct Message;
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
36 // its own class.
37 class MessagingBindings {
38 public:
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,
47 int target_port_id,
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,
58 int target_port_id,
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,
65 int port_id,
66 const std::string& error_message,
67 content::RenderView* restrict_to_render_view);
70 } // namespace extensions
72 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_