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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 }; | 50 }; |
51 | 51 |
52 // Observers register interest in events with a particular name and are | 52 // Observers register interest in events with a particular name and are |
53 // notified when a listener is added or removed for that |event_name|. | 53 // notified when a listener is added or removed for that |event_name|. |
54 class Observer { | 54 class Observer { |
55 public: | 55 public: |
56 // Called when a listener is added. | 56 // Called when a listener is added. |
57 virtual void OnListenerAdded(const EventListenerInfo& details) {} | 57 virtual void OnListenerAdded(const EventListenerInfo& details) {} |
58 // Called when a listener is removed. | 58 // Called when a listener is removed. |
59 virtual void OnListenerRemoved(const EventListenerInfo& details) {} | 59 virtual void OnListenerRemoved(const EventListenerInfo& details) {} |
| 60 |
| 61 protected: |
| 62 virtual ~Observer() {} |
60 }; | 63 }; |
61 | 64 |
62 // Sends an event via ipc_sender to the given extension. Can be called on any | 65 // Sends an event via ipc_sender to the given extension. Can be called on any |
63 // thread. | 66 // thread. |
64 static void DispatchEvent(IPC::Sender* ipc_sender, | 67 static void DispatchEvent(IPC::Sender* ipc_sender, |
65 const std::string& extension_id, | 68 const std::string& extension_id, |
66 const std::string& event_name, | 69 const std::string& event_name, |
67 scoped_ptr<base::ListValue> event_args, | 70 scoped_ptr<base::ListValue> event_args, |
68 const GURL& event_url, | 71 const GURL& event_url, |
69 UserGestureState user_gesture, | 72 UserGestureState user_gesture, |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 EventListenerInfo(const std::string& event_name, | 293 EventListenerInfo(const std::string& event_name, |
291 const std::string& extension_id); | 294 const std::string& extension_id); |
292 | 295 |
293 const std::string event_name; | 296 const std::string event_name; |
294 const std::string extension_id; | 297 const std::string extension_id; |
295 }; | 298 }; |
296 | 299 |
297 } // namespace extensions | 300 } // namespace extensions |
298 | 301 |
299 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ | 302 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
OLD | NEW |