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