Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: extensions/renderer/messaging_bindings.h

Issue 709933002: Add frameId to MessageSender (extension messaging API) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test: sender.tab.status = 'complete' Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/extension_helper.cc ('k') | extensions/renderer/messaging_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ 5 #ifndef EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_
6 #define EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ 6 #define EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "extensions/renderer/script_context_set.h" 10 #include "extensions/renderer/script_context_set.h"
11 11
12 struct ExtensionMsg_ExternalConnectionInfo; 12 struct ExtensionMsg_ExternalConnectionInfo;
13 struct ExtensionMsg_TabConnectionInfo;
13 14
14 namespace base { 15 namespace base {
15 class DictionaryValue; 16 class DictionaryValue;
16 } 17 }
17 18
18 namespace content { 19 namespace content {
19 class RenderView; 20 class RenderFrame;
20 } 21 }
21 22
22 namespace v8 { 23 namespace v8 {
23 class Extension; 24 class Extension;
24 } 25 }
25 26
26 namespace extensions { 27 namespace extensions {
27 class Dispatcher; 28 class Dispatcher;
28 struct Message; 29 struct Message;
29 class ObjectBackedNativeHandler; 30 class ObjectBackedNativeHandler;
30 class ScriptContextSet; 31 class ScriptContextSet;
31 32
32 // Manually implements JavaScript bindings for extension messaging. 33 // Manually implements JavaScript bindings for extension messaging.
33 // 34 //
34 // TODO(aa): This should all get re-implemented using SchemaGeneratedBindings. 35 // 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 // If anything needs to be manual for some reason, it should be implemented in
36 // its own class. 37 // its own class.
37 class MessagingBindings { 38 class MessagingBindings {
38 public: 39 public:
39 // Creates an instance of the extension. 40 // Creates an instance of the extension.
40 static ObjectBackedNativeHandler* Get(Dispatcher* dispatcher, 41 static ObjectBackedNativeHandler* Get(Dispatcher* dispatcher,
41 ScriptContext* context); 42 ScriptContext* context);
42 43
43 // Dispatches the onConnect content script messaging event to some contexts 44 // 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 |context_set|. If |restrict_to_render_frame| is specified, only contexts
45 // in that render view will receive the message. 46 // in that render frame will receive the message.
46 static void DispatchOnConnect(const ScriptContextSet& context_set, 47 static void DispatchOnConnect(const ScriptContextSet& context_set,
47 int target_port_id, 48 int target_port_id,
48 const std::string& channel_name, 49 const std::string& channel_name,
49 const base::DictionaryValue& source_tab, 50 const ExtensionMsg_TabConnectionInfo& source,
50 const ExtensionMsg_ExternalConnectionInfo& info, 51 const ExtensionMsg_ExternalConnectionInfo& info,
51 const std::string& tls_channel_id, 52 const std::string& tls_channel_id,
52 content::RenderView* restrict_to_render_view); 53 content::RenderFrame* restrict_to_render_frame);
53 54
54 // Delivers a message sent using content script messaging to some of the 55 // 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 // contexts in |bindings_context_set|. If |restrict_to_render_frame| is
56 // specified, only contexts in that render view will receive the message. 57 // specified, only contexts in that render view will receive the message.
57 static void DeliverMessage(const ScriptContextSet& context_set, 58 static void DeliverMessage(const ScriptContextSet& context_set,
58 int target_port_id, 59 int target_port_id,
59 const Message& message, 60 const Message& message,
60 content::RenderView* restrict_to_render_view); 61 content::RenderFrame* restrict_to_render_frame);
61 62
62 // Dispatches the onDisconnect event in response to the channel being closed. 63 // Dispatches the onDisconnect event in response to the channel being closed.
63 static void DispatchOnDisconnect( 64 static void DispatchOnDisconnect(
64 const ScriptContextSet& context_set, 65 const ScriptContextSet& context_set,
65 int port_id, 66 int port_id,
66 const std::string& error_message, 67 const std::string& error_message,
67 content::RenderView* restrict_to_render_view); 68 content::RenderFrame* restrict_to_render_frame);
68 }; 69 };
69 70
70 } // namespace extensions 71 } // namespace extensions
71 72
72 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ 73 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_
OLDNEW
« no previous file with comments | « extensions/renderer/extension_helper.cc ('k') | extensions/renderer/messaging_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698