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 ATOM_RENDERER_GUEST_VIEW_CONTAINER_H_
  5. #define ATOM_RENDERER_GUEST_VIEW_CONTAINER_H_
  6. #include "base/callback.h"
  7. #include "content/public/renderer/browser_plugin_delegate.h"
  8. #include "content/public/renderer/render_frame.h"
  9. namespace gfx {
  10. class Size;
  11. }
  12. namespace atom {
  13. class GuestViewContainer : public content::BrowserPluginDelegate {
  14. public:
  15. typedef base::Callback<void(const gfx::Size&)> ResizeCallback;
  16. explicit GuestViewContainer(content::RenderFrame* render_frame);
  17. ~GuestViewContainer() override;
  18. static GuestViewContainer* FromID(int element_instance_id);
  19. void RegisterElementResizeCallback(const ResizeCallback& callback);
  20. // content::BrowserPluginDelegate:
  21. void SetElementInstanceID(int element_instance_id) final;
  22. void DidResizeElement(const gfx::Size& new_size) final;
  23. base::WeakPtr<BrowserPluginDelegate> GetWeakPtr() final;
  24. private:
  25. int element_instance_id_;
  26. ResizeCallback element_resize_callback_;
  27. base::WeakPtrFactory<GuestViewContainer> weak_ptr_factory_;
  28. DISALLOW_COPY_AND_ASSIGN(GuestViewContainer);
  29. };
  30. } // namespace atom
  31. #endif // ATOM_RENDERER_GUEST_VIEW_CONTAINER_H_