OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "content/common/notification_observer.h" | 14 #include "content/common/notification_observer.h" |
15 #include "content/common/notification_registrar.h" | 15 #include "content/common/notification_registrar.h" |
| 16 #include "ipc/ipc_message.h" |
16 | 17 |
17 class GURL; | 18 class GURL; |
18 class Extension; | 19 class Extension; |
19 class ExtensionDevToolsManager; | 20 class ExtensionDevToolsManager; |
20 class Profile; | 21 class Profile; |
21 class RenderProcessHost; | 22 class RenderProcessHost; |
22 | 23 |
23 class ExtensionEventRouter : public NotificationObserver { | 24 class ExtensionEventRouter : public NotificationObserver { |
24 public: | 25 public: |
25 // Returns true if the given extension can see events and data from another | 26 // Sends an event via ipc_sender to the given extension. Can be called on |
26 // sub-profile (incognito to original profile, or vice versa). | 27 // any thread. |
27 static bool CanCrossIncognito(Profile* profile, | 28 static void DispatchEvent(IPC::Message::Sender* ipc_sender, |
28 const std::string& extension_id); | 29 const std::string& extension_id, |
29 static bool CanCrossIncognito(Profile* profile, const Extension* extension); | 30 const std::string& event_name, |
| 31 const std::string& event_args, |
| 32 const GURL& event_url); |
30 | 33 |
31 explicit ExtensionEventRouter(Profile* profile); | 34 explicit ExtensionEventRouter(Profile* profile); |
32 virtual ~ExtensionEventRouter(); | 35 virtual ~ExtensionEventRouter(); |
33 | 36 |
34 // Add or remove the process/extension pair as a listener for |event_name|. | 37 // Add or remove the process/extension pair as a listener for |event_name|. |
35 // Note that multiple extensions can share a process due to process | 38 // Note that multiple extensions can share a process due to process |
36 // collapsing. Also, a single extension can have 2 processes if it is a split | 39 // collapsing. Also, a single extension can have 2 processes if it is a split |
37 // mode extension. | 40 // mode extension. |
38 void AddEventListener(const std::string& event_name, | 41 void AddEventListener(const std::string& event_name, |
39 RenderProcessHost* process, | 42 RenderProcessHost* process, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 92 |
90 // A map between an event name and a set of extensions that are listening | 93 // A map between an event name and a set of extensions that are listening |
91 // to that event. | 94 // to that event. |
92 typedef std::map<std::string, std::set<EventListener> > ListenerMap; | 95 typedef std::map<std::string, std::set<EventListener> > ListenerMap; |
93 ListenerMap listeners_; | 96 ListenerMap listeners_; |
94 | 97 |
95 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); | 98 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); |
96 }; | 99 }; |
97 | 100 |
98 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ | 101 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ |
OLD | NEW |