frame_window_tree_host.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 FUCHSIA_WEB_WEBENGINE_BROWSER_FRAME_WINDOW_TREE_HOST_H_
  5. #define FUCHSIA_WEB_WEBENGINE_BROWSER_FRAME_WINDOW_TREE_HOST_H_
  6. #include <lib/ui/scenic/cpp/view_ref_pair.h>
  7. #include "ui/aura/window_tree_host_platform.h"
  8. #include "ui/platform_window/fuchsia/scenic_window_delegate.h"
  9. namespace content {
  10. class WebContents;
  11. } // namespace content
  12. // aura::WindowTreeHost implementation used to present web content inside
  13. // web.Frame.
  14. class FrameWindowTreeHost final : public aura::WindowTreeHostPlatform,
  15. public ui::ScenicWindowDelegate {
  16. public:
  17. using OnPixelScaleUpdateCallback = base::RepeatingCallback<void(float)>;
  18. FrameWindowTreeHost(fuchsia::ui::views::ViewToken view_token,
  19. scenic::ViewRefPair view_ref_pair,
  20. content::WebContents* web_contents,
  21. OnPixelScaleUpdateCallback on_pixel_scale_update);
  22. FrameWindowTreeHost(fuchsia::ui::views::ViewCreationToken view_creation_token,
  23. scenic::ViewRefPair view_ref_pair,
  24. content::WebContents* web_contents,
  25. OnPixelScaleUpdateCallback on_pixel_scale_update);
  26. ~FrameWindowTreeHost() override;
  27. FrameWindowTreeHost(const FrameWindowTreeHost&) = delete;
  28. FrameWindowTreeHost& operator=(const FrameWindowTreeHost&) = delete;
  29. // Creates and returns a ViewRef for the window.
  30. fuchsia::ui::views::ViewRef CreateViewRef();
  31. float scenic_scale_factor() { return scenic_pixel_scale_; }
  32. private:
  33. class WindowParentingClientImpl;
  34. // aura::WindowTreeHostPlatform overrides.
  35. void OnActivationChanged(bool active) override;
  36. void OnWindowStateChanged(ui::PlatformWindowState old_state,
  37. ui::PlatformWindowState new_state) override;
  38. void OnWindowBoundsChanged(const BoundsChange& bounds);
  39. // ScenicWindowDelegate implementation.
  40. void OnScenicPixelScale(ui::PlatformWindow* window, float scale) final;
  41. const fuchsia::ui::views::ViewRef view_ref_;
  42. std::unique_ptr<WindowParentingClientImpl> window_parenting_client_;
  43. content::WebContents* const web_contents_;
  44. float scenic_pixel_scale_ = 1.0;
  45. OnPixelScaleUpdateCallback on_pixel_scale_update_;
  46. };
  47. #endif // FUCHSIA_WEB_WEBENGINE_BROWSER_FRAME_WINDOW_TREE_HOST_H_