web_message_host_factory.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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_PUBLIC_JS_COMMUNICATION_WEB_MESSAGE_HOST_FACTORY_H_
  5. #define WEBLAYER_PUBLIC_JS_COMMUNICATION_WEB_MESSAGE_HOST_FACTORY_H_
  6. #include <memory>
  7. #include <string>
  8. namespace weblayer {
  9. class WebMessageHost;
  10. class WebMessageReplyProxy;
  11. // Creates a WebMessageHost in response to a page interacting with the object
  12. // registered by way of Tab::AddWebMessageHostFactory(). A WebMessageHost is
  13. // created for every page that matches the parameters of
  14. // AddWebMessageHostFactory().
  15. class WebMessageHostFactory {
  16. public:
  17. virtual ~WebMessageHostFactory() = default;
  18. // The returned object is destroyed when the corresponding renderer has
  19. // been destroyed. |proxy| may be used to send messages to the page and is
  20. // valid for the life of the WebMessageHost.
  21. virtual std::unique_ptr<WebMessageHost> CreateHost(
  22. const std::string& origin_string,
  23. bool is_main_frame,
  24. WebMessageReplyProxy* proxy) = 0;
  25. };
  26. } // namespace weblayer
  27. #endif // WEBLAYER_PUBLIC_JS_COMMUNICATION_WEB_MESSAGE_HOST_FACTORY_H_