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

Unified Diff: extensions/browser/event_router.h

Issue 2879673002: Restrict EventRouter::Get/Set-RegisteredEvents. (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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/event_router.h
diff --git a/extensions/browser/event_router.h b/extensions/browser/event_router.h
index 303f4bef6321f86337db47af191822c76e34d7cc..e9f885a32b701a39487dd3a84bcf37b1b7cbfb98 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,12 @@ 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;
karandeepb 2017/05/12 00:34:25 The other functions don't use the ExtensionId type
lazyboy 2017/05/12 00:56:25 We started preferring ExtensionId for new code to
+
+ // Clears registered events for testing purposes.
+ void ClearRegisteredEventsForTest(const ExtensionId& extension_id);
karandeepb 2017/05/12 00:34:25 Optional nit: Both of these can be inlined.
lazyboy 2017/05/12 00:56:25 Done.
+
// Reports UMA for an event dispatched to |extension| with histogram value
// |histogram_value|. Must be called on the UI thread.
//
@@ -216,6 +216,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;

Powered by Google App Engine
This is Rietveld 408576698