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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 virtual void OnListenerRemoved(const EventListenerInfo& details) {} | 64 virtual void OnListenerRemoved(const EventListenerInfo& details) {} |
65 }; | 65 }; |
66 | 66 |
67 // Sends an event via ipc_sender to the given extension. Can be called on any | 67 // Sends an event via ipc_sender to the given extension. Can be called on any |
68 // thread. | 68 // thread. |
69 static void DispatchEvent(IPC::Sender* ipc_sender, | 69 static void DispatchEvent(IPC::Sender* ipc_sender, |
70 void* profile_id, | 70 void* profile_id, |
71 const std::string& extension_id, | 71 const std::string& extension_id, |
72 const std::string& event_name, | 72 const std::string& event_name, |
73 scoped_ptr<base::ListValue> event_args, | 73 scoped_ptr<base::ListValue> event_args, |
74 const GURL& event_url, | |
75 UserGestureState user_gesture, | 74 UserGestureState user_gesture, |
76 const EventFilteringInfo& info); | 75 const EventFilteringInfo& info); |
77 | 76 |
78 EventRouter(Profile* profile, ExtensionPrefs* extension_prefs); | 77 EventRouter(Profile* profile, ExtensionPrefs* extension_prefs); |
79 virtual ~EventRouter(); | 78 virtual ~EventRouter(); |
80 | 79 |
81 // Add or remove the process/extension pair as a listener for |event_name|. | 80 // Add or remove the process/extension pair as a listener for |event_name|. |
82 // Note that multiple extensions can share a process due to process | 81 // Note that multiple extensions can share a process due to process |
83 // collapsing. Also, a single extension can have 2 processes if it is a split | 82 // collapsing. Also, a single extension can have 2 processes if it is a split |
84 // mode extension. | 83 // mode extension. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 const std::string& event_name, | 167 const std::string& event_name, |
169 scoped_ptr<ListValue> event_args); | 168 scoped_ptr<ListValue> event_args); |
170 | 169 |
171 // TODO(gdk): Document this. | 170 // TODO(gdk): Document this. |
172 static void DispatchExtensionMessage( | 171 static void DispatchExtensionMessage( |
173 IPC::Sender* ipc_sender, | 172 IPC::Sender* ipc_sender, |
174 void* profile_id, | 173 void* profile_id, |
175 const std::string& extension_id, | 174 const std::string& extension_id, |
176 const std::string& event_name, | 175 const std::string& event_name, |
177 base::ListValue* event_args, | 176 base::ListValue* event_args, |
178 const GURL& event_url, | |
179 UserGestureState user_gesture, | 177 UserGestureState user_gesture, |
180 const extensions::EventFilteringInfo& info); | 178 const extensions::EventFilteringInfo& info); |
181 | 179 |
182 virtual void Observe(int type, | 180 virtual void Observe(int type, |
183 const content::NotificationSource& source, | 181 const content::NotificationSource& source, |
184 const content::NotificationDetails& details) OVERRIDE; | 182 const content::NotificationDetails& details) OVERRIDE; |
185 | 183 |
186 // Returns true if the given listener map contains a event listeners for | 184 // Returns true if the given listener map contains a event listeners for |
187 // the given event. If |extension_id| is non-empty, we also check that that | 185 // the given event. If |extension_id| is non-empty, we also check that that |
188 // extension is one of the listeners. | 186 // extension is one of the listeners. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 EventListenerInfo(const std::string& event_name, | 334 EventListenerInfo(const std::string& event_name, |
337 const std::string& extension_id); | 335 const std::string& extension_id); |
338 | 336 |
339 const std::string event_name; | 337 const std::string event_name; |
340 const std::string extension_id; | 338 const std::string extension_id; |
341 }; | 339 }; |
342 | 340 |
343 } // namespace extensions | 341 } // namespace extensions |
344 | 342 |
345 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ | 343 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
OLD | NEW |