OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 bool ExtensionHasEventListener(const std::string& extension_id, | 124 bool ExtensionHasEventListener(const std::string& extension_id, |
125 const std::string& event_name); | 125 const std::string& event_name); |
126 | 126 |
127 // Broadcasts an event to every listener registered for that event. | 127 // Broadcasts an event to every listener registered for that event. |
128 virtual void BroadcastEvent(scoped_ptr<Event> event); | 128 virtual void BroadcastEvent(scoped_ptr<Event> event); |
129 | 129 |
130 // Dispatches an event to the given extension. | 130 // Dispatches an event to the given extension. |
131 virtual void DispatchEventToExtension(const std::string& extension_id, | 131 virtual void DispatchEventToExtension(const std::string& extension_id, |
132 scoped_ptr<Event> event); | 132 scoped_ptr<Event> event); |
133 | 133 |
134 // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 | |
135 // Send an event to every registered extension renderer. If | |
136 // |restrict_to_profile| is non-NULL, then the event will not be sent to other | |
137 // profiles unless the extension has permission (e.g. incognito tab update -> | |
138 // normal profile only works if extension is allowed incognito access). If | |
139 // |event_url| is not empty, the event is only sent to extension with host | |
140 // permissions for this url. | |
141 void DispatchEventToRenderers(const std::string& event_name, | |
142 scoped_ptr<base::ListValue> event_args, | |
143 Profile* restrict_to_profile, | |
144 const GURL& event_url, | |
145 EventFilteringInfo info); | |
146 | |
147 // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 | |
148 // As above, but defaults |info| to EventFilteringInfo(). | |
149 void DispatchEventToRenderers(const std::string& event_name, | |
150 scoped_ptr<base::ListValue> event_args, | |
151 Profile* restrict_to_profile, | |
152 const GURL& event_url); | |
153 | |
154 // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 | |
155 // As above, but enables sending an explicit user gesture indicator. | |
156 void DispatchEventToRenderers(const std::string& event_name, | |
157 scoped_ptr<ListValue> event_args, | |
158 Profile* restrict_to_profile, | |
159 const GURL& event_url, | |
160 UserGestureState user_gesture); | |
161 | |
162 // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 | |
163 // Same as above, except only send the event to the given extension. | |
164 virtual void DispatchEventToExtension(const std::string& extension_id, | |
165 const std::string& event_name, | |
166 scoped_ptr<base::ListValue> event_args, | |
167 Profile* restrict_to_profile, | |
168 const GURL& event_url); | |
169 | |
170 // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 | |
171 // Dispatch an event to particular extension. Also include an | |
172 // explicit user gesture indicator. | |
173 virtual void DispatchEventToExtension(const std::string& extension_id, | |
174 const std::string& event_name, | |
175 scoped_ptr<base::ListValue> event_args, | |
176 Profile* restrict_to_profile, | |
177 const GURL& event_url, | |
178 UserGestureState user_gesture); | |
179 | |
180 // Record the Event Ack from the renderer. (One less event in-flight.) | 134 // Record the Event Ack from the renderer. (One less event in-flight.) |
181 void OnEventAck(Profile* profile, const std::string& extension_id); | 135 void OnEventAck(Profile* profile, const std::string& extension_id); |
182 | 136 |
183 private: | 137 private: |
184 // The extension and process that contains the event listener for a given | 138 // The extension and process that contains the event listener for a given |
185 // event. | 139 // event. |
186 struct ListenerProcess; | 140 struct ListenerProcess; |
187 | 141 |
188 // A map between an event name and a set of extensions that are listening | 142 // A map between an event name and a set of extensions that are listening |
189 // to that event. | 143 // to that event. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 EventListenerInfo(const std::string& event_name, | 297 EventListenerInfo(const std::string& event_name, |
344 const std::string& extension_id); | 298 const std::string& extension_id); |
345 | 299 |
346 const std::string event_name; | 300 const std::string event_name; |
347 const std::string extension_id; | 301 const std::string extension_id; |
348 }; | 302 }; |
349 | 303 |
350 } // namespace extensions | 304 } // namespace extensions |
351 | 305 |
352 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ | 306 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
OLD | NEW |