// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef EXTENSIONS_RENDERER_BINDINGS_API_EVENT_LISTENERS_H_ #define EXTENSIONS_RENDERER_BINDINGS_API_EVENT_LISTENERS_H_ #include <string> #include <vector> #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/values.h" #include "extensions/common/mojom/event_dispatcher.mojom-forward.h" #include "extensions/renderer/bindings/api_binding_types.h" #include "v8/include/v8.h" namespace extensions { class ListenerTracker; // A base class to hold listeners for a given event. This allows for adding, // removing, and querying listeners in the list, and calling a callback when // transitioning from 0 -> 1 or 1 -> 0 listeners. class APIEventListeners { … }; // A listener list implementation that doesn't support filtering. Each event // dispatched is dispatched to all the associated listeners. class UnfilteredEventListeners final : public APIEventListeners { … }; // A listener list implementation that supports filtering. Events should only // be dispatched to those listeners whose filters match. Additionally, the // updated callback is triggered any time a listener with a new filter is // added, or the last listener with a given filter is removed. class FilteredEventListeners final : public APIEventListeners { … }; } // namespace extensions #endif // EXTENSIONS_RENDERER_BINDINGS_API_EVENT_LISTENERS_H_