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

Unified Diff: extensions/renderer/event_bindings.cc

Issue 2236133002: Ignore filtered event if an event matcher cannot be added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/event_bindings.cc
diff --git a/extensions/renderer/event_bindings.cc b/extensions/renderer/event_bindings.cc
index de99257c3824e78046708ef98c51fe8fc8ca15ed..db5fb60f428af90a3ce4ba3edcfee6a77b1a6729 100644
--- a/extensions/renderer/event_bindings.cc
+++ b/extensions/renderer/event_bindings.cc
@@ -272,14 +272,18 @@ void EventBindings::AttachFilteredEvent(
filter = base::DictionaryValue::From(std::move(filter_value));
}
- // Hold onto a weak reference to |filter| so that it can be used after passing
- // ownership to |event_filter|.
- base::DictionaryValue* filter_weak = filter.get();
int id = g_event_filter.Get().AddEventMatcher(
event_name, ParseEventMatcher(std::move(filter)));
+ if (id == -1) {
+ args.GetReturnValue().Set(static_cast<int32_t>(-1));
+ return;
+ }
attached_matcher_ids_.insert(id);
// Only send IPCs the first time a filter gets added.
+ const EventMatcher* matcher = g_event_filter.Get().GetEventMatcher(id);
+ DCHECK(matcher);
+ base::DictionaryValue* filter_weak = matcher->value();
std::string extension_id = context()->GetExtensionID();
if (AddFilter(event_name, extension_id, *filter_weak)) {
bool lazy = ExtensionFrameHelper::IsContextForEventPage(context());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698