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

Side by Side Diff: chrome/browser/extensions/extension_message_service.h

Issue 1042003: Initial version of an experimental Extensions Context Menu API.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 int render_process_id); 74 int render_process_id);
75 75
76 // Closes the message channel associated with the given port, and notifies 76 // Closes the message channel associated with the given port, and notifies
77 // the other side. 77 // the other side.
78 void CloseChannel(int port_id); 78 void CloseChannel(int port_id);
79 79
80 // Sends a message from a renderer to the given port. 80 // Sends a message from a renderer to the given port.
81 void PostMessageFromRenderer(int port_id, const std::string& message); 81 void PostMessageFromRenderer(int port_id, const std::string& message);
82 82
83 // Send an event to every registered extension renderer. 83 // Send an event to every registered extension renderer.
84 void DispatchEventToRenderers( 84 virtual void DispatchEventToRenderers(
85 const std::string& event_name, const std::string& event_args, 85 const std::string& event_name, const std::string& event_args,
86 bool has_incognito_data); 86 bool has_incognito_data);
87 87
88 // Given an extension ID, opens a channel between the given 88 // Given an extension ID, opens a channel between the given
89 // automation "port" or DevTools service and that extension. the 89 // automation "port" or DevTools service and that extension. the
90 // channel will be open to the extension process hosting the 90 // channel will be open to the extension process hosting the
91 // background page and tool strip. 91 // background page and tool strip.
92 // 92 //
93 // Returns a port ID to be used for posting messages between the 93 // Returns a port ID to be used for posting messages between the
94 // processes, or -1 if the extension doesn't exist. 94 // processes, or -1 if the extension doesn't exist.
(...skipping 30 matching lines...) Expand all
125 // are restricted to that tab, so if there are multiple tabs in that process, 125 // are restricted to that tab, so if there are multiple tabs in that process,
126 // only the targeted tab will receive messages. 126 // only the targeted tab will receive messages.
127 int OpenChannelToTab(int routing_id, int tab_id, 127 int OpenChannelToTab(int routing_id, int tab_id,
128 const std::string& extension_id, 128 const std::string& extension_id,
129 const std::string& channel_name, 129 const std::string& channel_name,
130 ResourceMessageFilter* source); 130 ResourceMessageFilter* source);
131 131
132 private: 132 private:
133 friend class ChromeThread; 133 friend class ChromeThread;
134 friend class DeleteTask<ExtensionMessageService>; 134 friend class DeleteTask<ExtensionMessageService>;
135 friend class MockExtensionMessageService;
135 136
136 // A map of channel ID to its channel object. 137 // A map of channel ID to its channel object.
137 typedef std::map<int, MessageChannel*> MessageChannelMap; 138 typedef std::map<int, MessageChannel*> MessageChannelMap;
138 139
139 ~ExtensionMessageService(); 140 virtual ~ExtensionMessageService();
140 141
141 // Allocates a pair of port ids. 142 // Allocates a pair of port ids.
142 // NOTE: this can be called from any thread. 143 // NOTE: this can be called from any thread.
143 void AllocatePortIdPair(int* port1, int* port2); 144 void AllocatePortIdPair(int* port1, int* port2);
144 145
145 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, int port_id, 146 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, int port_id,
146 bool notify_other_port); 147 bool notify_other_port);
147 148
148 // --- UI thread only: 149 // --- UI thread only:
149 150
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 int next_port_id_; 197 int next_port_id_;
197 198
198 // Protects the next_port_id_ variable, since it can be 199 // Protects the next_port_id_ variable, since it can be
199 // used on the IO thread or the UI thread. 200 // used on the IO thread or the UI thread.
200 Lock next_port_id_lock_; 201 Lock next_port_id_lock_;
201 202
202 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService); 203 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService);
203 }; 204 };
204 205
205 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ 206 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698