native_browser_view.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright (c) 2017 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_BROWSER_NATIVE_BROWSER_VIEW_H_
  5. #define ELECTRON_SHELL_BROWSER_NATIVE_BROWSER_VIEW_H_
  6. #include <vector>
  7. #include "content/public/browser/web_contents.h"
  8. #include "content/public/browser/web_contents_observer.h"
  9. #include "shell/common/api/api.mojom.h"
  10. #include "third_party/skia/include/core/SkColor.h"
  11. namespace gfx {
  12. class Rect;
  13. }
  14. namespace electron {
  15. enum AutoResizeFlags {
  16. kAutoResizeWidth = 0x1,
  17. kAutoResizeHeight = 0x2,
  18. kAutoResizeHorizontal = 0x4,
  19. kAutoResizeVertical = 0x8,
  20. };
  21. class InspectableWebContents;
  22. class InspectableWebContentsView;
  23. class NativeBrowserView : public content::WebContentsObserver {
  24. public:
  25. ~NativeBrowserView() override;
  26. // disable copy
  27. NativeBrowserView(const NativeBrowserView&) = delete;
  28. NativeBrowserView& operator=(const NativeBrowserView&) = delete;
  29. static NativeBrowserView* Create(
  30. InspectableWebContents* inspectable_web_contents);
  31. InspectableWebContents* GetInspectableWebContents() {
  32. return inspectable_web_contents_;
  33. }
  34. const std::vector<mojom::DraggableRegionPtr>& GetDraggableRegions() const {
  35. return draggable_regions_;
  36. }
  37. InspectableWebContentsView* GetInspectableWebContentsView();
  38. virtual void SetAutoResizeFlags(uint8_t flags) = 0;
  39. virtual void SetBounds(const gfx::Rect& bounds) = 0;
  40. virtual gfx::Rect GetBounds() = 0;
  41. virtual void SetBackgroundColor(SkColor color) = 0;
  42. virtual void UpdateDraggableRegions(
  43. const std::vector<gfx::Rect>& drag_exclude_rects) {}
  44. // Called when the window needs to update its draggable region.
  45. virtual void UpdateDraggableRegions(
  46. const std::vector<mojom::DraggableRegionPtr>& regions) {}
  47. protected:
  48. explicit NativeBrowserView(InspectableWebContents* inspectable_web_contents);
  49. // content::WebContentsObserver:
  50. void WebContentsDestroyed() override;
  51. InspectableWebContents* inspectable_web_contents_;
  52. std::vector<mojom::DraggableRegionPtr> draggable_regions_;
  53. };
  54. } // namespace electron
  55. #endif // ELECTRON_SHELL_BROWSER_NATIVE_BROWSER_VIEW_H_