OLD | NEW |
1 // Copyright (c) 2010 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> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 explicit ExtensionMessageService(Profile* profile); | 67 explicit ExtensionMessageService(Profile* profile); |
68 | 68 |
69 // Notification that our owning profile is going away. | 69 // Notification that our owning profile is going away. |
70 void ProfileDestroyed(); | 70 void ProfileDestroyed(); |
71 | 71 |
72 // Add or remove |render_process_pid| as a listener for |event_name|. | 72 // Add or remove |render_process_pid| as a listener for |event_name|. |
73 void AddEventListener(const std::string& event_name, int render_process_id); | 73 void AddEventListener(const std::string& event_name, int render_process_id); |
74 void RemoveEventListener(const std::string& event_name, | 74 void RemoveEventListener(const std::string& event_name, |
75 int render_process_id); | 75 int render_process_id); |
76 | 76 |
| 77 // Returns true if there is at least one listener for the given event. |
| 78 bool HasEventListener(const std::string& event_name); |
| 79 |
77 // Closes the message channel associated with the given port, and notifies | 80 // Closes the message channel associated with the given port, and notifies |
78 // the other side. | 81 // the other side. |
79 void CloseChannel(int port_id); | 82 void CloseChannel(int port_id); |
80 | 83 |
81 // Sends a message from a renderer to the given port. | 84 // Sends a message from a renderer to the given port. |
82 void PostMessageFromRenderer(int port_id, const std::string& message); | 85 void PostMessageFromRenderer(int port_id, const std::string& message); |
83 | 86 |
84 // Send an event to every registered extension renderer. If | 87 // Send an event to every registered extension renderer. If |
85 // |has_incognito_data| is true, the event is only sent to extension with the | 88 // |has_incognito_data| is true, the event is only sent to extension with the |
86 // permission to access incognito data. If |event_url| is not empty, the | 89 // permission to access incognito data. If |event_url| is not empty, the |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 int next_port_id_; | 204 int next_port_id_; |
202 | 205 |
203 // Protects the next_port_id_ variable, since it can be | 206 // Protects the next_port_id_ variable, since it can be |
204 // used on the IO thread or the UI thread. | 207 // used on the IO thread or the UI thread. |
205 Lock next_port_id_lock_; | 208 Lock next_port_id_lock_; |
206 | 209 |
207 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService); | 210 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService); |
208 }; | 211 }; |
209 | 212 |
210 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ | 213 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ |
OLD | NEW |