test_interaction_provider.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_BINDINGS_TEST_INTERACTION_PROVIDER_H_
  5. #define EXTENSIONS_RENDERER_BINDINGS_TEST_INTERACTION_PROVIDER_H_
  6. #include "extensions/renderer/bindings/interaction_provider.h"
  7. #include "v8/include/v8.h"
  8. namespace extensions {
  9. class TestInteractionProvider : public InteractionProvider {
  10. public:
  11. TestInteractionProvider();
  12. TestInteractionProvider(const TestInteractionProvider&) = delete;
  13. TestInteractionProvider& operator=(const TestInteractionProvider&) = delete;
  14. ~TestInteractionProvider() override;
  15. // InteractionProvider:
  16. std::unique_ptr<InteractionProvider::Token> GetCurrentToken(
  17. v8::Local<v8::Context> v8_context) const override;
  18. std::unique_ptr<InteractionProvider::Scope> CreateScopedInteraction(
  19. v8::Local<v8::Context> v8_context,
  20. std::unique_ptr<InteractionProvider::Token> token) const override;
  21. bool HasActiveInteraction(v8::Local<v8::Context> v8_context) const override;
  22. };
  23. // User activation mock for test: sets transient activation state on
  24. // construction, resets on destruction.
  25. class ScopedTestUserActivation {
  26. public:
  27. ScopedTestUserActivation();
  28. ~ScopedTestUserActivation();
  29. };
  30. } // namespace extensions
  31. #endif // EXTENSIONS_RENDERER_BINDINGS_TEST_INTERACTION_PROVIDER_H_