Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/browser/extensions/event_router.h

Issue 10941003: Reset registered events and dispatch runtime.onInstalled to all extensions when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ? Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 12 matching lines...) Expand all
23 class ExtensionDevToolsManager; 23 class ExtensionDevToolsManager;
24 class Profile; 24 class Profile;
25 25
26 namespace content { 26 namespace content {
27 class RenderProcessHost; 27 class RenderProcessHost;
28 } 28 }
29 29
30 namespace extensions { 30 namespace extensions {
31 class Extension; 31 class Extension;
32 class ExtensionHost; 32 class ExtensionHost;
33 class ExtensionPrefs;
33 34
34 struct Event; 35 struct Event;
35 36
36 class EventRouter : public content::NotificationObserver, 37 class EventRouter : public content::NotificationObserver,
37 public EventListenerMap::Delegate { 38 public EventListenerMap::Delegate {
38 public: 39 public:
39 // These constants convey the state of our knowledge of whether we're in 40 // These constants convey the state of our knowledge of whether we're in
40 // a user-caused gesture as part of DispatchEvent. 41 // a user-caused gesture as part of DispatchEvent.
41 enum UserGestureState { 42 enum UserGestureState {
42 USER_GESTURE_UNKNOWN = 0, 43 USER_GESTURE_UNKNOWN = 0,
43 USER_GESTURE_ENABLED = 1, 44 USER_GESTURE_ENABLED = 1,
44 USER_GESTURE_NOT_ENABLED = 2, 45 USER_GESTURE_NOT_ENABLED = 2,
45 }; 46 };
46 47
47 // Sends an event via ipc_sender to the given extension. Can be called on any 48 // Sends an event via ipc_sender to the given extension. Can be called on any
48 // thread. 49 // thread.
49 static void DispatchEvent(IPC::Sender* ipc_sender, 50 static void DispatchEvent(IPC::Sender* ipc_sender,
50 const std::string& extension_id, 51 const std::string& extension_id,
51 const std::string& event_name, 52 const std::string& event_name,
52 scoped_ptr<base::ListValue> event_args, 53 scoped_ptr<base::ListValue> event_args,
53 const GURL& event_url, 54 const GURL& event_url,
54 UserGestureState user_gesture, 55 UserGestureState user_gesture,
55 const EventFilteringInfo& info); 56 const EventFilteringInfo& info);
56 57
57 explicit EventRouter(Profile* profile); 58 EventRouter(Profile* profile, ExtensionPrefs* extension_prefs);
58 virtual ~EventRouter(); 59 virtual ~EventRouter();
59 60
60 // Add or remove the process/extension pair as a listener for |event_name|. 61 // Add or remove the process/extension pair as a listener for |event_name|.
61 // Note that multiple extensions can share a process due to process 62 // Note that multiple extensions can share a process due to process
62 // collapsing. Also, a single extension can have 2 processes if it is a split 63 // collapsing. Also, a single extension can have 2 processes if it is a split
63 // mode extension. 64 // mode extension.
64 void AddEventListener(const std::string& event_name, 65 void AddEventListener(const std::string& event_name,
65 content::RenderProcessHost* process, 66 content::RenderProcessHost* process,
66 const std::string& extension_id); 67 const std::string& extension_id);
67 void RemoveEventListener(const std::string& event_name, 68 void RemoveEventListener(const std::string& event_name,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 virtual void OnListenerRemoved(const EventListener* listener) OVERRIDE; 235 virtual void OnListenerRemoved(const EventListener* listener) OVERRIDE;
235 236
236 Profile* profile_; 237 Profile* profile_;
237 238
238 content::NotificationRegistrar registrar_; 239 content::NotificationRegistrar registrar_;
239 240
240 scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_; 241 scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_;
241 242
242 EventListenerMap listeners_; 243 EventListenerMap listeners_;
243 244
245 // True if we should dispatch the event signalling that Chrome was updated
246 // upon loading an extension.
247 bool dispatch_chrome_updated_event_;
248
244 DISALLOW_COPY_AND_ASSIGN(EventRouter); 249 DISALLOW_COPY_AND_ASSIGN(EventRouter);
245 }; 250 };
246 251
247 struct Event { 252 struct Event {
248 std::string event_name; 253 std::string event_name;
249 scoped_ptr<base::ListValue> event_args; 254 scoped_ptr<base::ListValue> event_args;
250 GURL event_url; 255 GURL event_url;
251 Profile* restrict_to_profile; 256 Profile* restrict_to_profile;
252 scoped_ptr<base::ListValue> cross_incognito_args; 257 scoped_ptr<base::ListValue> cross_incognito_args;
253 EventRouter::UserGestureState user_gesture; 258 EventRouter::UserGestureState user_gesture;
(...skipping 13 matching lines...) Expand all
267 Profile* restrict_to_profile, 272 Profile* restrict_to_profile,
268 EventRouter::UserGestureState user_gesture, 273 EventRouter::UserGestureState user_gesture,
269 const EventFilteringInfo& info); 274 const EventFilteringInfo& info);
270 275
271 ~Event(); 276 ~Event();
272 }; 277 };
273 278
274 } // namespace extensions 279 } // namespace extensions
275 280
276 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ 281 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698