| 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_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/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "chrome/common/notification_observer.h" | 14 #include "chrome/common/notification_observer.h" |
| 15 #include "chrome/common/notification_registrar.h" | 15 #include "chrome/common/notification_registrar.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 class Extension; |
| 18 class ExtensionDevToolsManager; | 19 class ExtensionDevToolsManager; |
| 19 class Profile; | 20 class Profile; |
| 20 class RenderProcessHost; | 21 class RenderProcessHost; |
| 21 | 22 |
| 22 class ExtensionEventRouter : public NotificationObserver { | 23 class ExtensionEventRouter : public NotificationObserver { |
| 23 public: | 24 public: |
| 25 // Returns true if the given extension can see events and data from another |
| 26 // sub-profile (incognito to original profile, or vice versa). |
| 27 static bool CanCrossIncognito(Profile* profile, |
| 28 const std::string& extension_id); |
| 29 static bool CanCrossIncognito(Profile* profile, const Extension* extension); |
| 30 |
| 24 explicit ExtensionEventRouter(Profile* profile); | 31 explicit ExtensionEventRouter(Profile* profile); |
| 25 ~ExtensionEventRouter(); | 32 ~ExtensionEventRouter(); |
| 26 | 33 |
| 27 // Add or remove the process/extension pair as a listener for |event_name|. | 34 // Add or remove the process/extension pair as a listener for |event_name|. |
| 28 // Note that multiple extensions can share a process due to process | 35 // Note that multiple extensions can share a process due to process |
| 29 // collapsing. Also, a single extension can have 2 processes if it is a split | 36 // collapsing. Also, a single extension can have 2 processes if it is a split |
| 30 // mode extension. | 37 // mode extension. |
| 31 void AddEventListener(const std::string& event_name, | 38 void AddEventListener(const std::string& event_name, |
| 32 RenderProcessHost* process, | 39 RenderProcessHost* process, |
| 33 const std::string& extension_id); | 40 const std::string& extension_id); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 89 |
| 83 // A map between an event name and a set of extensions that are listening | 90 // A map between an event name and a set of extensions that are listening |
| 84 // to that event. | 91 // to that event. |
| 85 typedef std::map<std::string, std::set<EventListener> > ListenerMap; | 92 typedef std::map<std::string, std::set<EventListener> > ListenerMap; |
| 86 ListenerMap listeners_; | 93 ListenerMap listeners_; |
| 87 | 94 |
| 88 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); | 95 DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); |
| 89 }; | 96 }; |
| 90 | 97 |
| 91 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ | 98 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ |
| OLD | NEW |