script_context_set_iterable.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2019 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. #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_ITERABLE_H_
  5. #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_ITERABLE_H_
  6. #include <string>
  7. #include "base/callback_forward.h"
  8. namespace content {
  9. class RenderFrame;
  10. }
  11. namespace extensions {
  12. class ScriptContext;
  13. // Iterable base class to iterate over a ScriptContextSet.
  14. class ScriptContextSetIterable {
  15. public:
  16. // Synchronously runs |callback| with each ScriptContext that belongs to
  17. // |extension_id| in |render_frame|.
  18. //
  19. // An empty |extension_id| will match all extensions, and a null
  20. // |render_frame| will match all render views, but try to use the inline
  21. // variants of these methods instead.
  22. virtual void ForEach(
  23. const std::string& extension_id,
  24. content::RenderFrame* render_frame,
  25. const base::RepeatingCallback<void(ScriptContext*)>& callback) = 0;
  26. // ForEach which matches all extensions.
  27. void ForEach(content::RenderFrame* render_frame,
  28. const base::RepeatingCallback<void(ScriptContext*)>& callback);
  29. // ForEach which matches all render views.
  30. void ForEach(const std::string& extension_id,
  31. const base::RepeatingCallback<void(ScriptContext*)>& callback);
  32. virtual ~ScriptContextSetIterable() {}
  33. };
  34. } // namespace extensions
  35. #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_ITERABLE_H_