cast_web_view.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2017 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 CHROMECAST_BROWSER_CAST_WEB_VIEW_H_
  5. #define CHROMECAST_BROWSER_CAST_WEB_VIEW_H_
  6. #include <cstdint>
  7. #include <string>
  8. #include "base/observer_list_types.h"
  9. #include "base/time/time.h"
  10. #include "chromecast/browser/cast_content_window.h"
  11. #include "chromecast/browser/cast_web_contents.h"
  12. #include "chromecast/ui/mojom/ui_service.mojom.h"
  13. #include "url/gurl.h"
  14. namespace content {
  15. class WebContents;
  16. } // namespace content
  17. namespace chromecast {
  18. class CastWebService;
  19. // A simplified interface for loading and displaying WebContents in cast_shell.
  20. class CastWebView {
  21. public:
  22. // When the unique_ptr is reset, the CastWebView may not necessarily be
  23. // destroyed. In some cases ownership will be passed to the CastWebService,
  24. // which eventually handles destruction.
  25. using Scoped =
  26. std::unique_ptr<CastWebView, std::function<void(CastWebView*)>>;
  27. CastWebView() = default;
  28. CastWebView(const CastWebView&) = delete;
  29. CastWebView& operator=(const CastWebView&) = delete;
  30. virtual ~CastWebView() = default;
  31. virtual CastContentWindow* window() const = 0;
  32. virtual content::WebContents* web_contents() const = 0;
  33. virtual CastWebContents* cast_web_contents() = 0;
  34. virtual base::TimeDelta shutdown_delay() const = 0;
  35. // Called when the owning handle to CastWebView is destroyed.
  36. virtual void OwnerDestroyed() = 0;
  37. void BindReceivers(
  38. mojo::PendingReceiver<mojom::CastWebContents> web_contents_receiver,
  39. mojo::PendingReceiver<mojom::CastContentWindow> window_receiver);
  40. };
  41. } // namespace chromecast
  42. #endif // CHROMECAST_BROWSER_CAST_WEB_VIEW_H_