event_dispatcher.mojom 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. module extensions.mojom;
  5. import "mojo/public/mojom/base/values.mojom";
  6. import "url/mojom/url.mojom";
  7. // EventDispatch is a one-per-renderer-processs interface that is responsible
  8. // for triggering API events that extensions have registered listeners for in
  9. // the renderer (either the extension process renderer, for extension-origin
  10. // pages, or a web renderer, for content script listeners).
  11. // The interface is implemented in //extensions/renderer code, and is
  12. // called on the browser side by the EventRouter.
  13. interface EventDispatcher {
  14. // Sent to the renderer to dispatch an event to a listener.
  15. DispatchEvent(DispatchEventParams params,
  16. mojo_base.mojom.ListValue event_args);
  17. };
  18. struct EventFilteringInfo {
  19. url.mojom.Url? url;
  20. string? service_type;
  21. // TODO(yoichio): Use nullable when https://crbug.com/657632 is fixed.
  22. bool has_instance_id;
  23. int32 instance_id;
  24. string? window_type;
  25. // TODO(yoichio): Use nullable when https://crbug.com/657632 is fixed.
  26. bool has_window_exposed_by_default;
  27. bool window_exposed_by_default;
  28. };
  29. struct DispatchEventParams {
  30. // If this event is for a service worker, then this is the worker thread
  31. // id. Otherwise, this is 0.
  32. int32 worker_thread_id;
  33. // The id of the extension to dispatch the event to.
  34. string extension_id;
  35. // The name of the event to dispatch.
  36. string event_name;
  37. // The id of the event for use in the EventAck response message.
  38. int32 event_id;
  39. // Whether or not the event is part of a user gesture.
  40. bool is_user_gesture;
  41. // Additional filtering info for the event.
  42. EventFilteringInfo filtering_info;
  43. };