2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-04-18 12:50:58 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_OBSERVER_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_OBSERVER_H_
|
2013-04-18 12:50:58 +00:00
|
|
|
|
2013-07-01 13:56:46 +00:00
|
|
|
#include <string>
|
2013-04-18 12:50:58 +00:00
|
|
|
|
2018-10-25 06:43:50 +00:00
|
|
|
#include "base/observer_list_types.h"
|
2017-02-28 23:37:15 +00:00
|
|
|
#include "base/values.h"
|
2014-11-04 09:59:15 +00:00
|
|
|
#include "ui/base/window_open_disposition.h"
|
2014-10-27 08:56:28 +00:00
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2015-10-27 01:12:01 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2021-07-02 00:51:37 +00:00
|
|
|
class GURL;
|
|
|
|
|
2018-07-27 09:53:01 +00:00
|
|
|
namespace gfx {
|
|
|
|
class Rect;
|
2021-06-02 02:37:10 +00:00
|
|
|
enum class ResizeEdge;
|
|
|
|
} // namespace gfx
|
2018-07-27 09:53:01 +00:00
|
|
|
|
2013-04-18 12:50:58 +00:00
|
|
|
namespace electron {
|
|
|
|
|
2018-10-25 06:43:50 +00:00
|
|
|
class NativeWindowObserver : public base::CheckedObserver {
|
2013-04-18 12:50:58 +00:00
|
|
|
public:
|
2018-10-25 06:43:50 +00:00
|
|
|
~NativeWindowObserver() override {}
|
2013-04-18 12:50:58 +00:00
|
|
|
|
2014-10-27 08:56:28 +00:00
|
|
|
// Called when the web page in window wants to create a popup window.
|
2021-03-16 16:18:45 +00:00
|
|
|
virtual void WillCreatePopupWindow(const std::u16string& frame_name,
|
2014-10-27 08:56:28 +00:00
|
|
|
const GURL& target_url,
|
2014-11-04 09:59:15 +00:00
|
|
|
const std::string& partition_id,
|
|
|
|
WindowOpenDisposition disposition) {}
|
2014-10-27 08:56:28 +00:00
|
|
|
|
2014-12-17 22:40:19 +00:00
|
|
|
// Called when user is starting an navigation in web page.
|
|
|
|
virtual void WillNavigate(bool* prevent_default, const GURL& url) {}
|
|
|
|
|
2013-05-01 08:33:19 +00:00
|
|
|
// Called when the window is gonna closed.
|
|
|
|
virtual void WillCloseWindow(bool* prevent_default) {}
|
|
|
|
|
2018-03-06 03:03:12 +00:00
|
|
|
// Called when the window wants to know the preferred width.
|
|
|
|
virtual void RequestPreferredWidth(int* width) {}
|
|
|
|
|
2018-02-22 07:15:21 +00:00
|
|
|
// Called when closed button is clicked.
|
|
|
|
virtual void OnCloseButtonClicked(bool* prevent_default) {}
|
|
|
|
|
2013-05-01 08:33:19 +00:00
|
|
|
// Called when the window is closed.
|
|
|
|
virtual void OnWindowClosed() {}
|
2013-05-24 09:51:15 +00:00
|
|
|
|
2017-04-24 18:49:21 +00:00
|
|
|
// Called when Windows sends WM_ENDSESSION message
|
|
|
|
virtual void OnWindowEndSession() {}
|
|
|
|
|
2013-05-24 09:51:15 +00:00
|
|
|
// Called when window loses focus.
|
|
|
|
virtual void OnWindowBlur() {}
|
2013-06-06 11:45:48 +00:00
|
|
|
|
2014-05-21 17:46:13 +00:00
|
|
|
// Called when window gains focus.
|
|
|
|
virtual void OnWindowFocus() {}
|
|
|
|
|
2020-06-29 20:15:28 +00:00
|
|
|
// Called when window gained or lost key window status.
|
|
|
|
virtual void OnWindowIsKeyChanged(bool is_key) {}
|
|
|
|
|
2016-03-08 17:36:41 +00:00
|
|
|
// Called when window is shown.
|
|
|
|
virtual void OnWindowShow() {}
|
|
|
|
|
|
|
|
// Called when window is hidden.
|
|
|
|
virtual void OnWindowHide() {}
|
|
|
|
|
2014-11-25 04:43:25 +00:00
|
|
|
// Called when window state changed.
|
|
|
|
virtual void OnWindowMaximize() {}
|
|
|
|
virtual void OnWindowUnmaximize() {}
|
|
|
|
virtual void OnWindowMinimize() {}
|
|
|
|
virtual void OnWindowRestore() {}
|
2018-07-27 09:53:01 +00:00
|
|
|
virtual void OnWindowWillResize(const gfx::Rect& new_bounds,
|
2021-06-02 02:37:10 +00:00
|
|
|
const gfx::ResizeEdge& edge,
|
2018-07-27 09:53:01 +00:00
|
|
|
bool* prevent_default) {}
|
2015-05-09 15:55:10 +00:00
|
|
|
virtual void OnWindowResize() {}
|
2020-11-12 00:27:24 +00:00
|
|
|
virtual void OnWindowResized() {}
|
2018-08-28 13:44:10 +00:00
|
|
|
virtual void OnWindowWillMove(const gfx::Rect& new_bounds,
|
|
|
|
bool* prevent_default) {}
|
2015-05-09 15:55:10 +00:00
|
|
|
virtual void OnWindowMove() {}
|
2015-05-20 08:37:13 +00:00
|
|
|
virtual void OnWindowMoved() {}
|
2016-01-22 00:31:09 +00:00
|
|
|
virtual void OnWindowScrollTouchBegin() {}
|
|
|
|
virtual void OnWindowScrollTouchEnd() {}
|
2016-03-23 15:20:11 +00:00
|
|
|
virtual void OnWindowSwipe(const std::string& direction) {}
|
2019-07-23 19:42:26 +00:00
|
|
|
virtual void OnWindowRotateGesture(float rotation) {}
|
2017-04-20 17:31:25 +00:00
|
|
|
virtual void OnWindowSheetBegin() {}
|
|
|
|
virtual void OnWindowSheetEnd() {}
|
2014-11-25 04:43:25 +00:00
|
|
|
virtual void OnWindowEnterFullScreen() {}
|
|
|
|
virtual void OnWindowLeaveFullScreen() {}
|
2015-05-16 21:01:30 +00:00
|
|
|
virtual void OnWindowEnterHtmlFullScreen() {}
|
|
|
|
virtual void OnWindowLeaveHtmlFullScreen() {}
|
2018-10-04 18:02:16 +00:00
|
|
|
virtual void OnWindowAlwaysOnTopChanged() {}
|
2017-02-28 23:37:15 +00:00
|
|
|
virtual void OnTouchBarItemResult(const std::string& item_id,
|
2022-07-05 15:25:18 +00:00
|
|
|
const base::Value::Dict& details) {}
|
2017-06-11 08:19:01 +00:00
|
|
|
virtual void OnNewWindowForTab() {}
|
2020-10-08 22:45:05 +00:00
|
|
|
virtual void OnSystemContextMenu(int x, int y, bool* prevent_default) {}
|
2014-11-25 04:43:25 +00:00
|
|
|
|
2018-04-18 01:44:10 +00:00
|
|
|
// Called when window message received
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2015-10-29 02:53:48 +00:00
|
|
|
virtual void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {}
|
2018-04-18 01:44:10 +00:00
|
|
|
#endif
|
2015-10-27 01:12:01 +00:00
|
|
|
|
2015-06-18 00:15:02 +00:00
|
|
|
// Called on Windows when App Commands arrive (WM_APPCOMMAND)
|
2018-12-05 17:35:59 +00:00
|
|
|
// Some commands are implemented on on other platforms as well
|
|
|
|
virtual void OnExecuteAppCommand(const std::string& command_name) {}
|
2021-07-01 19:25:40 +00:00
|
|
|
|
|
|
|
virtual void UpdateWindowControlsOverlay(const gfx::Rect& bounding_rect) {}
|
2013-04-18 12:50:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_OBSERVER_H_
|