native_window_observer.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Copyright (c) 2013 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_WINDOW_OBSERVER_H_
  5. #define ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_OBSERVER_H_
  6. #include <string>
  7. #include "base/observer_list_types.h"
  8. #include "base/values.h"
  9. #include "ui/base/window_open_disposition.h"
  10. #if BUILDFLAG(IS_WIN)
  11. #include <windows.h>
  12. #endif
  13. class GURL;
  14. namespace gfx {
  15. class Rect;
  16. enum class ResizeEdge;
  17. } // namespace gfx
  18. namespace electron {
  19. class NativeWindowObserver : public base::CheckedObserver {
  20. public:
  21. ~NativeWindowObserver() override {}
  22. // Called when the web page in window wants to create a popup window.
  23. virtual void WillCreatePopupWindow(const std::u16string& frame_name,
  24. const GURL& target_url,
  25. const std::string& partition_id,
  26. WindowOpenDisposition disposition) {}
  27. // Called when user is starting an navigation in web page.
  28. virtual void WillNavigate(bool* prevent_default, const GURL& url) {}
  29. // Called when the window is gonna closed.
  30. virtual void WillCloseWindow(bool* prevent_default) {}
  31. // Called when the window wants to know the preferred width.
  32. virtual void RequestPreferredWidth(int* width) {}
  33. // Called when closed button is clicked.
  34. virtual void OnCloseButtonClicked(bool* prevent_default) {}
  35. // Called when the window is closed.
  36. virtual void OnWindowClosed() {}
  37. // Called when Windows sends WM_ENDSESSION message
  38. virtual void OnWindowEndSession() {}
  39. // Called when window loses focus.
  40. virtual void OnWindowBlur() {}
  41. // Called when window gains focus.
  42. virtual void OnWindowFocus() {}
  43. // Called when window gained or lost key window status.
  44. virtual void OnWindowIsKeyChanged(bool is_key) {}
  45. // Called when window is shown.
  46. virtual void OnWindowShow() {}
  47. // Called when window is hidden.
  48. virtual void OnWindowHide() {}
  49. // Called when window state changed.
  50. virtual void OnWindowMaximize() {}
  51. virtual void OnWindowUnmaximize() {}
  52. virtual void OnWindowMinimize() {}
  53. virtual void OnWindowRestore() {}
  54. virtual void OnWindowWillResize(const gfx::Rect& new_bounds,
  55. const gfx::ResizeEdge& edge,
  56. bool* prevent_default) {}
  57. virtual void OnWindowResize() {}
  58. virtual void OnWindowResized() {}
  59. virtual void OnWindowWillMove(const gfx::Rect& new_bounds,
  60. bool* prevent_default) {}
  61. virtual void OnWindowMove() {}
  62. virtual void OnWindowMoved() {}
  63. virtual void OnWindowSwipe(const std::string& direction) {}
  64. virtual void OnWindowRotateGesture(float rotation) {}
  65. virtual void OnWindowSheetBegin() {}
  66. virtual void OnWindowSheetEnd() {}
  67. virtual void OnWindowEnterFullScreen() {}
  68. virtual void OnWindowLeaveFullScreen() {}
  69. virtual void OnWindowEnterHtmlFullScreen() {}
  70. virtual void OnWindowLeaveHtmlFullScreen() {}
  71. virtual void OnWindowAlwaysOnTopChanged() {}
  72. virtual void OnTouchBarItemResult(const std::string& item_id,
  73. const base::Value::Dict& details) {}
  74. virtual void OnNewWindowForTab() {}
  75. virtual void OnSystemContextMenu(int x, int y, bool* prevent_default) {}
  76. // Called when window message received
  77. #if BUILDFLAG(IS_WIN)
  78. virtual void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {}
  79. #endif
  80. // Called on Windows when App Commands arrive (WM_APPCOMMAND)
  81. // Some commands are implemented on on other platforms as well
  82. virtual void OnExecuteAppCommand(const std::string& command_name) {}
  83. virtual void UpdateWindowControlsOverlay(const gfx::Rect& bounding_rect) {}
  84. };
  85. } // namespace electron
  86. #endif // ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_OBSERVER_H_