guest_view_container.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2015 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_RENDERER_GUEST_VIEW_CONTAINER_H_
  5. #define ELECTRON_SHELL_RENDERER_GUEST_VIEW_CONTAINER_H_
  6. #include "base/callback.h"
  7. namespace content {
  8. class RenderFrame;
  9. }
  10. namespace gfx {
  11. class Size;
  12. }
  13. namespace electron {
  14. class GuestViewContainer {
  15. public:
  16. typedef base::RepeatingCallback<void(const gfx::Size&)> ResizeCallback;
  17. explicit GuestViewContainer(content::RenderFrame* render_frame);
  18. virtual ~GuestViewContainer();
  19. // disable copy
  20. GuestViewContainer(const GuestViewContainer&) = delete;
  21. GuestViewContainer& operator=(const GuestViewContainer&) = delete;
  22. static GuestViewContainer* FromID(int element_instance_id);
  23. void RegisterElementResizeCallback(const ResizeCallback& callback);
  24. void SetElementInstanceID(int element_instance_id);
  25. void DidResizeElement(const gfx::Size& new_size);
  26. private:
  27. int element_instance_id_;
  28. ResizeCallback element_resize_callback_;
  29. base::WeakPtrFactory<GuestViewContainer> weak_ptr_factory_{this};
  30. };
  31. } // namespace electron
  32. #endif // ELECTRON_SHELL_RENDERER_GUEST_VIEW_CONTAINER_H_