#include "extensions/renderer/bindings/api_event_listeners.h"
#include <memory>
#include "base/containers/contains.h"
#include "base/ranges/algorithm.h"
#include "content/public/renderer/v8_value_converter.h"
#include "extensions/common/event_matcher.h"
#include "extensions/common/mojom/event_dispatcher.mojom.h"
#include "extensions/renderer/bindings/listener_tracker.h"
#include "gin/converter.h"
namespace extensions {
namespace {
const int kIgnoreRoutingId = …;
const char kErrorTooManyListeners[] = …;
bool ValidateFilter(v8::Local<v8::Context> context,
v8::Local<v8::Object> filter,
std::unique_ptr<base::Value::Dict>* filter_dict,
std::string* error) { … }
}
UnfilteredEventListeners::UnfilteredEventListeners(
ListenersUpdated listeners_updated,
const std::string& event_name,
ContextOwnerIdGetter context_owner_id_getter,
int max_listeners,
bool supports_lazy_listeners,
ListenerTracker* listener_tracker)
: … { … }
UnfilteredEventListeners::~UnfilteredEventListeners() = default;
bool UnfilteredEventListeners::AddListener(v8::Local<v8::Function> listener,
v8::Local<v8::Object> filter,
v8::Local<v8::Context> context,
std::string* error) { … }
void UnfilteredEventListeners::RemoveListener(v8::Local<v8::Function> listener,
v8::Local<v8::Context> context) { … }
bool UnfilteredEventListeners::HasListener(v8::Local<v8::Function> listener) { … }
size_t UnfilteredEventListeners::GetNumListeners() { … }
v8::LocalVector<v8::Function> UnfilteredEventListeners::GetListeners(
mojom::EventFilteringInfoPtr filter,
v8::Local<v8::Context> context) { … }
void UnfilteredEventListeners::Invalidate(v8::Local<v8::Context> context) { … }
void UnfilteredEventListeners::LazilySetContextOwner(
v8::Local<v8::Context> context) { … }
void UnfilteredEventListeners::NotifyListenersEmpty(
v8::Local<v8::Context> context,
bool update_lazy_listeners) { … }
struct FilteredEventListeners::ListenerData { … };
FilteredEventListeners::FilteredEventListeners(
ListenersUpdated listeners_updated,
const std::string& event_name,
ContextOwnerIdGetter context_owner_id_getter,
int max_listeners,
bool supports_lazy_listeners,
ListenerTracker* listener_tracker)
: … { … }
FilteredEventListeners::~FilteredEventListeners() = default;
bool FilteredEventListeners::AddListener(v8::Local<v8::Function> listener,
v8::Local<v8::Object> filter,
v8::Local<v8::Context> context,
std::string* error) { … }
void FilteredEventListeners::RemoveListener(v8::Local<v8::Function> listener,
v8::Local<v8::Context> context) { … }
bool FilteredEventListeners::HasListener(v8::Local<v8::Function> listener) { … }
size_t FilteredEventListeners::GetNumListeners() { … }
v8::LocalVector<v8::Function> FilteredEventListeners::GetListeners(
mojom::EventFilteringInfoPtr filter,
v8::Local<v8::Context> context) { … }
void FilteredEventListeners::Invalidate(v8::Local<v8::Context> context) { … }
void FilteredEventListeners::LazilySetContextOwner(
v8::Local<v8::Context> context) { … }
void FilteredEventListeners::InvalidateListener(
const ListenerData& listener,
bool was_manual,
v8::Local<v8::Context> context) { … }
}