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

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

Issue 2893693002: Remove NOTIFICATION_EXTENSION_ENABLED. (Closed)
Patch Set: connect devtools 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;
236 void OnExtensionUnloaded(content::BrowserContext* browser_context, 230 void OnExtensionUnloaded(content::BrowserContext* browser_context,
237 const Extension* extension, 231 const Extension* extension,
238 UnloadedExtensionReason reason) override; 232 UnloadedExtensionReason reason) override;
239 233
240 // Shared by all event dispatch methods. If |restrict_to_extension_id| is 234 // 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 235 // empty, the event is broadcast. An event that just came off the pending
242 // list may not be delayed again. 236 // list may not be delayed again.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 base::TerminationStatus status, 314 base::TerminationStatus status,
321 int exit_code) override; 315 int exit_code) override;
322 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; 316 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
323 317
324 content::BrowserContext* browser_context_; 318 content::BrowserContext* browser_context_;
325 319
326 // The ExtensionPrefs associated with |browser_context_|. May be NULL in 320 // The ExtensionPrefs associated with |browser_context_|. May be NULL in
327 // tests. 321 // tests.
328 ExtensionPrefs* extension_prefs_; 322 ExtensionPrefs* extension_prefs_;
329 323
330 content::NotificationRegistrar registrar_;
331
332 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 324 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
333 extension_registry_observer_; 325 extension_registry_observer_;
334 326
335 EventListenerMap listeners_; 327 EventListenerMap listeners_;
336 328
337 // Map from base event name to observer. 329 // Map from base event name to observer.
338 typedef base::hash_map<std::string, Observer*> ObserverMap; 330 typedef base::hash_map<std::string, Observer*> ObserverMap;
339 ObserverMap observers_; 331 ObserverMap observers_;
340 332
341 std::set<content::RenderProcessHost*> observed_process_set_; 333 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; 414 const std::string event_name;
423 415
424 const std::string extension_id; 416 const std::string extension_id;
425 const GURL listener_url; 417 const GURL listener_url;
426 content::BrowserContext* browser_context; 418 content::BrowserContext* browser_context;
427 }; 419 };
428 420
429 } // namespace extensions 421 } // namespace extensions
430 422
431 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_ 423 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698