chromium/extensions/renderer/bindings/api_event_listeners.cc

// 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.

#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 {

// TODO(devlin): The EventFilter supports adding EventMatchers associated with
// an id. For now, we ignore it and add/return everything associated with this
// constant. We should rethink that.
const int kIgnoreRoutingId =;

const char kErrorTooManyListeners[] =;

// Pseudo-validates the given |filter| and converts it into a
// base::Value::Dict. Returns true on success.
// TODO(devlin): This "validation" is pretty terrible. It matches the JS
// equivalent, but it's lousy and makes it easy for users to get it wrong.
// We should generate an argument spec for it and match it exactly.
bool ValidateFilter(v8::Local<v8::Context> context,
                    v8::Local<v8::Object> filter,
                    std::unique_ptr<base::Value::Dict>* filter_dict,
                    std::string* error) {}

}  // namespace

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) {}

}  // namespace extensions