web_message_host_factory_wrapper.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2020 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 WEBLAYER_BROWSER_JS_COMMUNICATION_WEB_MESSAGE_HOST_FACTORY_WRAPPER_H_
  5. #define WEBLAYER_BROWSER_JS_COMMUNICATION_WEB_MESSAGE_HOST_FACTORY_WRAPPER_H_
  6. #include "components/js_injection/browser/web_message_host_factory.h"
  7. namespace weblayer {
  8. class WebMessageHostFactory;
  9. // Provides an implementation of js_injection::WebMessageHostFactory that
  10. // wraps the corresponding WebLayer type.
  11. class WebMessageHostFactoryWrapper
  12. : public js_injection::WebMessageHostFactory {
  13. public:
  14. explicit WebMessageHostFactoryWrapper(
  15. std::unique_ptr<weblayer::WebMessageHostFactory> factory);
  16. WebMessageHostFactoryWrapper(const WebMessageHostFactoryWrapper&) = delete;
  17. WebMessageHostFactoryWrapper& operator=(const WebMessageHostFactoryWrapper&) =
  18. delete;
  19. ~WebMessageHostFactoryWrapper() override;
  20. // js_injection::WebMessageHostFactory:
  21. std::unique_ptr<js_injection::WebMessageHost> CreateHost(
  22. const std::string& origin_string,
  23. bool is_main_frame,
  24. js_injection::WebMessageReplyProxy* proxy) override;
  25. private:
  26. std::unique_ptr<weblayer::WebMessageHostFactory> factory_;
  27. };
  28. } // namespace weblayer
  29. #endif // WEBLAYER_BROWSER_JS_COMMUNICATION_WEB_MESSAGE_HOST_FACTORY_WRAPPER_H_