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

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

Issue 2893693002: Remove NOTIFICATION_EXTENSION_ENABLED. (Closed)
Patch Set: Created 3 years, 7 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
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 EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 5 #ifndef EXTENSIONS_BROWSER_EVENT_ROUTER_H_
6 #define EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 6 #define EXTENSIONS_BROWSER_EVENT_ROUTER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/scoped_observer.h" 18 #include "base/scoped_observer.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "components/keyed_service/core/keyed_service.h" 20 #include "components/keyed_service/core/keyed_service.h"
21 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/render_process_host_observer.h" 21 #include "content/public/browser/render_process_host_observer.h"
24 #include "extensions/browser/event_listener_map.h" 22 #include "extensions/browser/event_listener_map.h"
25 #include "extensions/browser/extension_event_histogram_value.h" 23 #include "extensions/browser/extension_event_histogram_value.h"
26 #include "extensions/browser/extension_registry_observer.h" 24 #include "extensions/browser/extension_registry_observer.h"
27 #include "extensions/common/event_filtering_info.h" 25 #include "extensions/common/event_filtering_info.h"
28 #include "ipc/ipc_sender.h" 26 #include "ipc/ipc_sender.h"
29 #include "url/gurl.h" 27 #include "url/gurl.h"
30 28
31 class GURL; 29 class GURL;
32 30
33 namespace content { 31 namespace content {
34 class BrowserContext; 32 class BrowserContext;
35 class RenderProcessHost; 33 class RenderProcessHost;
36 } 34 }
37 35
38 namespace extensions { 36 namespace extensions {
39 class Extension; 37 class Extension;
40 class ExtensionHost; 38 class ExtensionHost;
41 class ExtensionPrefs; 39 class ExtensionPrefs;
42 class ExtensionRegistry; 40 class ExtensionRegistry;
43 41
44 struct Event; 42 struct Event;
45 struct EventListenerInfo; 43 struct EventListenerInfo;
46 44
47 class EventRouter : public KeyedService, 45 class EventRouter : public KeyedService,
48 public content::NotificationObserver,
49 public ExtensionRegistryObserver, 46 public ExtensionRegistryObserver,
50 public EventListenerMap::Delegate, 47 public EventListenerMap::Delegate,
51 public content::RenderProcessHostObserver { 48 public content::RenderProcessHostObserver {
52 public: 49 public:
53 // These constants convey the state of our knowledge of whether we're in 50 // These constants convey the state of our knowledge of whether we're in
54 // a user-caused gesture as part of DispatchEvent. 51 // a user-caused gesture as part of DispatchEvent.
55 enum UserGestureState { 52 enum UserGestureState {
56 USER_GESTURE_UNKNOWN = 0, 53 USER_GESTURE_UNKNOWN = 0,
57 USER_GESTURE_ENABLED = 1, 54 USER_GESTURE_ENABLED = 1,
58 USER_GESTURE_NOT_ENABLED = 2, 55 USER_GESTURE_NOT_ENABLED = 2,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 UserGestureState user_gesture, 217 UserGestureState user_gesture,
221 const extensions::EventFilteringInfo& info); 218 const extensions::EventFilteringInfo& info);
222 219
223 // Returns or sets the list of events for which the given extension has 220 // Returns or sets the list of events for which the given extension has
224 // registered. 221 // registered.
225 std::set<std::string> GetRegisteredEvents( 222 std::set<std::string> GetRegisteredEvents(
226 const std::string& extension_id) const; 223 const std::string& extension_id) const;
227 void SetRegisteredEvents(const std::string& extension_id, 224 void SetRegisteredEvents(const std::string& extension_id,
228 const std::set<std::string>& events); 225 const std::set<std::string>& events);
229 226
230 void Observe(int type,
231 const content::NotificationSource& source,
232 const content::NotificationDetails& details) override;
233 // ExtensionRegistryObserver implementation. 227 // ExtensionRegistryObserver implementation.
234 void OnExtensionLoaded(content::BrowserContext* browser_context, 228 void OnExtensionLoaded(content::BrowserContext* browser_context,
235 const Extension* extension) override; 229 const Extension* extension) override;
230 void OnExtensionEnabled(content::BrowserContext* browser_context,
231 const Extension* extension) override;
236 void OnExtensionUnloaded(content::BrowserContext* browser_context, 232 void OnExtensionUnloaded(content::BrowserContext* browser_context,
237 const Extension* extension, 233 const Extension* extension,
238 UnloadedExtensionReason reason) override; 234 UnloadedExtensionReason reason) override;
239 235
240 // Shared by all event dispatch methods. If |restrict_to_extension_id| is 236 // Shared by all event dispatch methods. If |restrict_to_extension_id| is
241 // empty, the event is broadcast. An event that just came off the pending 237 // empty, the event is broadcast. An event that just came off the pending
242 // list may not be delayed again. 238 // list may not be delayed again.
243 void DispatchEventImpl(const std::string& restrict_to_extension_id, 239 void DispatchEventImpl(const std::string& restrict_to_extension_id,
244 const linked_ptr<Event>& event); 240 const linked_ptr<Event>& event);
245 241
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 base::TerminationStatus status, 316 base::TerminationStatus status,
321 int exit_code) override; 317 int exit_code) override;
322 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; 318 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
323 319
324 content::BrowserContext* browser_context_; 320 content::BrowserContext* browser_context_;
325 321
326 // The ExtensionPrefs associated with |browser_context_|. May be NULL in 322 // The ExtensionPrefs associated with |browser_context_|. May be NULL in
327 // tests. 323 // tests.
328 ExtensionPrefs* extension_prefs_; 324 ExtensionPrefs* extension_prefs_;
329 325
330 content::NotificationRegistrar registrar_;
331
332 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 326 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
333 extension_registry_observer_; 327 extension_registry_observer_;
334 328
335 EventListenerMap listeners_; 329 EventListenerMap listeners_;
336 330
337 // Map from base event name to observer. 331 // Map from base event name to observer.
338 typedef base::hash_map<std::string, Observer*> ObserverMap; 332 typedef base::hash_map<std::string, Observer*> ObserverMap;
339 ObserverMap observers_; 333 ObserverMap observers_;
340 334
341 std::set<content::RenderProcessHost*> observed_process_set_; 335 std::set<content::RenderProcessHost*> observed_process_set_;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 const std::string event_name; 416 const std::string event_name;
423 417
424 const std::string extension_id; 418 const std::string extension_id;
425 const GURL listener_url; 419 const GURL listener_url;
426 content::BrowserContext* browser_context; 420 content::BrowserContext* browser_context;
427 }; 421 };
428 422
429 } // namespace extensions 423 } // namespace extensions
430 424
431 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 425 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698