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

Unified Diff: extensions/browser/event_router.h

Issue 2879673002: Restrict EventRouter::Get/Set-RegisteredEvents. (Closed)
Patch Set: address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/installed_loader.cc ('k') | extensions/browser/event_router.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/event_router.h
diff --git a/extensions/browser/event_router.h b/extensions/browser/event_router.h
index 303f4bef6321f86337db47af191822c76e34d7cc..48bc266980cce4ce121f64a3402d8afbc5926e8a 100644
--- a/extensions/browser/event_router.h
+++ b/extensions/browser/event_router.h
@@ -163,12 +163,6 @@ class EventRouter : public KeyedService,
virtual bool ExtensionHasEventListener(const std::string& extension_id,
const std::string& event_name);
- // Return or set the list of events for which the given extension has
- // registered.
- std::set<std::string> GetRegisteredEvents(const std::string& extension_id);
- void SetRegisteredEvents(const std::string& extension_id,
- const std::set<std::string>& events);
-
// Broadcasts an event to every listener registered for that event.
virtual void BroadcastEvent(std::unique_ptr<Event> event);
@@ -187,6 +181,16 @@ class EventRouter : public KeyedService,
void OnEventAck(content::BrowserContext* context,
const std::string& extension_id);
+ // Returns whether or not the given extension has any registered events.
+ bool HasRegisteredEvents(const ExtensionId& extension_id) const {
+ return !GetRegisteredEvents(extension_id).empty();
+ }
+
+ // Clears registered events for testing purposes.
+ void ClearRegisteredEventsForTest(const ExtensionId& extension_id) {
+ SetRegisteredEvents(extension_id, std::set<std::string>());
+ }
+
// Reports UMA for an event dispatched to |extension| with histogram value
// |histogram_value|. Must be called on the UI thread.
//
@@ -216,6 +220,13 @@ class EventRouter : public KeyedService,
UserGestureState user_gesture,
const extensions::EventFilteringInfo& info);
+ // Returns or sets the list of events for which the given extension has
+ // registered.
+ std::set<std::string> GetRegisteredEvents(
+ const std::string& extension_id) const;
+ void SetRegisteredEvents(const std::string& extension_id,
+ const std::set<std::string>& events);
+
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
« no previous file with comments | « chrome/browser/extensions/installed_loader.cc ('k') | extensions/browser/event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698