Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / renderer / messaging_bindings.h
bloba7a1c6fef80704a7449403763e32ddfd9f409d7f
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;
13 struct ExtensionMsg_TabConnectionInfo;
15 namespace base {
16 class DictionaryValue;
19 namespace content {
20 class RenderFrame;
23 namespace v8 {
24 class Extension;
27 namespace extensions {
28 class Dispatcher;
29 struct Message;
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
37 // its own class.
38 class MessagingBindings {
39 public:
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,
48 int target_port_id,
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,
59 int target_port_id,
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,
66 int port_id,
67 const std::string& error_message,
68 content::RenderFrame* restrict_to_render_frame);
71 } // namespace extensions
73 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_