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

Unified Diff: extensions/browser/event_router.cc

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 | « extensions/browser/event_router.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/event_router.cc
diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc
index 77c5316da9ba4cb0a1eddaa49f94d7ea9128b164..e76ac703ac42422e1e7a87b3c6f660a3788b6191 100644
--- a/extensions/browser/event_router.cc
+++ b/extensions/browser/event_router.cc
@@ -324,7 +324,7 @@ bool EventRouter::ExtensionHasEventListener(const std::string& extension_id,
}
std::set<std::string> EventRouter::GetRegisteredEvents(
- const std::string& extension_id) {
+ const std::string& extension_id) const {
std::set<std::string> events;
const ListValue* events_value = NULL;
@@ -342,36 +342,6 @@ std::set<std::string> EventRouter::GetRegisteredEvents(
return events;
}
-void EventRouter::SetRegisteredEvents(const std::string& extension_id,
- const std::set<std::string>& events) {
- auto events_value = base::MakeUnique<base::ListValue>();
- for (std::set<std::string>::const_iterator iter = events.begin();
- iter != events.end(); ++iter) {
- events_value->AppendString(*iter);
- }
- extension_prefs_->UpdateExtensionPref(extension_id, kRegisteredEvents,
- std::move(events_value));
-}
-
-void EventRouter::AddFilterToEvent(const std::string& event_name,
- const std::string& extension_id,
- const DictionaryValue* filter) {
- ExtensionPrefs::ScopedDictionaryUpdate update(
- extension_prefs_, extension_id, kFilteredEvents);
- DictionaryValue* filtered_events = update.Get();
- if (!filtered_events)
- filtered_events = update.Create();
-
- ListValue* filter_list = nullptr;
- if (!filtered_events->GetListWithoutPathExpansion(event_name, &filter_list)) {
- filter_list = new ListValue;
- filtered_events->SetWithoutPathExpansion(event_name,
- base::WrapUnique(filter_list));
- }
-
- filter_list->Append(filter->CreateDeepCopy());
-}
-
void EventRouter::RemoveFilterFromEvent(const std::string& event_name,
const std::string& extension_id,
const DictionaryValue* filter) {
@@ -754,6 +724,36 @@ void EventRouter::DispatchPendingEvent(const linked_ptr<Event>& event,
}
}
+void EventRouter::SetRegisteredEvents(const std::string& extension_id,
+ const std::set<std::string>& events) {
+ auto events_value = base::MakeUnique<base::ListValue>();
+ for (std::set<std::string>::const_iterator iter = events.begin();
+ iter != events.end(); ++iter) {
+ events_value->AppendString(*iter);
+ }
+ extension_prefs_->UpdateExtensionPref(extension_id, kRegisteredEvents,
+ std::move(events_value));
+}
+
+void EventRouter::AddFilterToEvent(const std::string& event_name,
+ const std::string& extension_id,
+ const DictionaryValue* filter) {
+ ExtensionPrefs::ScopedDictionaryUpdate update(extension_prefs_, extension_id,
+ kFilteredEvents);
+ DictionaryValue* filtered_events = update.Get();
+ if (!filtered_events)
+ filtered_events = update.Create();
+
+ ListValue* filter_list = nullptr;
+ if (!filtered_events->GetListWithoutPathExpansion(event_name, &filter_list)) {
+ filter_list = new ListValue;
+ filtered_events->SetWithoutPathExpansion(event_name,
+ base::WrapUnique(filter_list));
+ }
+
+ filter_list->Append(filter->CreateDeepCopy());
+}
+
void EventRouter::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
« no previous file with comments | « extensions/browser/event_router.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698