native_browser_view.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "third_party/skia/include/core/SkColor.h"
  10. namespace gfx {
  11. class Rect;
  12. }
  13. namespace electron {
  14. enum AutoResizeFlags {
  15. kAutoResizeWidth = 0x1,
  16. kAutoResizeHeight = 0x2,
  17. kAutoResizeHorizontal = 0x4,
  18. kAutoResizeVertical = 0x8,
  19. };
  20. class InspectableWebContents;
  21. class InspectableWebContentsView;
  22. class NativeBrowserView : public content::WebContentsObserver {
  23. public:
  24. ~NativeBrowserView() override;
  25. // disable copy
  26. NativeBrowserView(const NativeBrowserView&) = delete;
  27. NativeBrowserView& operator=(const NativeBrowserView&) = delete;
  28. static NativeBrowserView* Create(
  29. InspectableWebContents* inspectable_web_contents);
  30. InspectableWebContents* GetInspectableWebContents() {
  31. return inspectable_web_contents_;
  32. }
  33. InspectableWebContentsView* GetInspectableWebContentsView();
  34. virtual void SetAutoResizeFlags(uint8_t flags) = 0;
  35. virtual void SetBounds(const gfx::Rect& bounds) = 0;
  36. virtual gfx::Rect GetBounds() = 0;
  37. virtual void SetBackgroundColor(SkColor color) = 0;
  38. protected:
  39. explicit NativeBrowserView(InspectableWebContents* inspectable_web_contents);
  40. // content::WebContentsObserver:
  41. void WebContentsDestroyed() override;
  42. InspectableWebContents* inspectable_web_contents_;
  43. };
  44. } // namespace electron
  45. #endif // ELECTRON_SHELL_BROWSER_NATIVE_BROWSER_VIEW_H_