extension_injection_host.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2015 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_EXTENSION_INJECTION_HOST_H_
  5. #define EXTENSIONS_RENDERER_EXTENSION_INJECTION_HOST_H_
  6. #include "base/memory/ref_counted.h"
  7. #include "extensions/common/extension.h"
  8. #include "extensions/renderer/injection_host.h"
  9. namespace extensions {
  10. // A wrapper class that holds an extension and implements the InjectionHost
  11. // interface.
  12. class ExtensionInjectionHost : public InjectionHost {
  13. public:
  14. ExtensionInjectionHost(const Extension* extension);
  15. ExtensionInjectionHost(const ExtensionInjectionHost&) = delete;
  16. ExtensionInjectionHost& operator=(const ExtensionInjectionHost&) = delete;
  17. ~ExtensionInjectionHost() override;
  18. // Create an ExtensionInjectionHost object. If the extension is gone, returns
  19. // a null scoped ptr.
  20. static std::unique_ptr<const InjectionHost> Create(
  21. const std::string& extension_id);
  22. private:
  23. // InjectionHost:
  24. const std::string* GetContentSecurityPolicy() const override;
  25. const GURL& url() const override;
  26. const std::string& name() const override;
  27. PermissionsData::PageAccess CanExecuteOnFrame(
  28. const GURL& document_url,
  29. content::RenderFrame* render_frame,
  30. int tab_id,
  31. bool is_declarative) const override;
  32. const Extension* extension_;
  33. };
  34. } // namespace extesions
  35. #endif // EXTENSIONS_RENDERER_EXTENSION_INJECTION_HOST_H_