electron/shell/browser/api/electron_api_browser_window.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

106 lines
3.5 KiB
C
Raw Normal View History

// 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
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_BROWSER_WINDOW_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_BROWSER_WINDOW_H_
#include <string>
2013-11-22 06:23:19 +00:00
#include "base/cancelable_callback.h"
#include "shell/browser/api/electron_api_base_window.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/drag_util.h"
#include "shell/common/gin_helper/error_thrower.h"
2022-06-29 19:55:47 +00:00
namespace electron::api {
class BrowserWindow : public BaseWindow,
public content::WebContentsObserver,
public ExtendedWebContentsObserver {
public:
static gin_helper::WrappableBase* New(gin_helper::ErrorThrower thrower,
gin::Arguments* args);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
2015-10-01 05:45:59 +00:00
// Returns the BrowserWindow object from |native_window|.
static v8::Local<v8::Value> From(v8::Isolate* isolate,
NativeWindow* native_window);
base::WeakPtr<BrowserWindow> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
2017-02-16 18:58:02 +00:00
// disable copy
BrowserWindow(const BrowserWindow&) = delete;
BrowserWindow& operator=(const BrowserWindow&) = delete;
protected:
BrowserWindow(gin::Arguments* args, const gin_helper::Dictionary& options);
~BrowserWindow() override;
// content::WebContentsObserver:
void BeforeUnloadDialogCancelled() override;
void OnRendererUnresponsive(content::RenderProcessHost*) override;
chore: bump chromium to d66c2e32380bf5d1eb5e1fe37faef (master) (#23791) * chore: bump chromium in DEPS to db7d7b3e7cb2bc925f2abfde526280cfdfc21a41 * Update patches * chore: bump chromium in DEPS to 5613e1b99a44fcbe22f3910f803ca76903a77ec1 * Update patches * Network service: Remove primary_network_context bool. https://chromium-review.googlesource.com/c/chromium/src/+/2204678 * WebContentsObserver now implements OnRendererResponsive https://chromium-review.googlesource.com/c/chromium/src/+/2211066 * update patches * Fixup printing patch * chore: bump chromium in DEPS to e387b972cdd7160c416fa6c64a724e2258aa0218 * update patches * [printing] Move PrintHostMsg_DidPrintContent_Params to print.mojom https://chromium-review.googlesource.com/c/chromium/src/+/2212110 * [XProto] Move items from ::x11::XProto to ::x11 https://chromium-review.googlesource.com/c/chromium/src/+/2218476 * revert Add IChromeAccessible This was added in https://chromium-review.googlesource.com/c/chromium/src/+/2206224 but it breaks WOA builds because third_party/win_build_output/midl/ui/accessibility/platform/arm64 does not exist. The link above says that the new interface is behind a feature flag which is disabled by default so it is safe to remove for now. * rebaseline ichromeaccessible for Windows arm64 This patch will not be needed once we get the next roll. * Update to 1b9e01844e8bf1aaafc4a52c0c62af7f56d9637b to get arm64 fix * update patches * chore: bump chromium in DEPS to 096aefa04092ea00f7b68d8d19345883f20db3c3 * chore: bump chromium in DEPS to a524a45ffd1d6fd46a7a86138fe2b22df5b6651a * chore: update patches * Window Placement: Gate cross-screen fullscreen behavior on permission https://chromium-review.googlesource.com/c/chromium/src/+/2203268 * chore: add spec for https://crbug.com/1085836 * chore: bump chromium in DEPS to ff6c4f4b826d66c2e32380bf5d1eb5e1fe37faef * update patches Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: Electron Bot <anonymous@electronjs.org> Co-authored-by: deepak1556 <hop2deep@gmail.com>
2020-06-01 20:34:34 +00:00
void OnRendererResponsive(
content::RenderProcessHost* render_process_host) override;
void WebContentsDestroyed() override;
2018-02-22 06:57:03 +00:00
// ExtendedWebContentsObserver:
void OnSetContentBounds(const gfx::Rect& rect) override;
void OnActivateContents() override;
void OnPageTitleUpdated(const std::u16string& title,
bool explicit_set) override;
2018-02-22 06:57:03 +00:00
2014-11-25 04:43:25 +00:00
// NativeWindowObserver:
void RequestPreferredWidth(int* width) override;
void OnCloseButtonClicked(bool* prevent_default) override;
2020-06-29 20:15:28 +00:00
void OnWindowIsKeyChanged(bool is_key) override;
void UpdateWindowControlsOverlay(const gfx::Rect& bounding_rect) override;
// BaseWindow:
void OnWindowBlur() override;
void OnWindowFocus() override;
void OnWindowLeaveFullScreen() override;
void CloseImmediately() override;
void Focus() override;
void Blur() override;
void SetBackgroundColor(const std::string& color_name) override;
void OnWindowShow() override;
void OnWindowHide() override;
// BrowserWindow APIs.
void FocusOnWebView();
void BlurWebView();
bool IsWebViewFocused();
v8::Local<v8::Value> GetWebContents(v8::Isolate* isolate);
#if BUILDFLAG(IS_WIN)
void SetTitleBarOverlay(const gin_helper::Dictionary& options,
gin_helper::Arguments* args);
#endif
2016-05-20 13:22:15 +00:00
private:
// Helpers.
2016-06-17 07:57:03 +00:00
// Schedule a notification unresponsive event.
void ScheduleUnresponsiveEvent(int ms);
// Dispatch unresponsive event to observers.
void NotifyWindowUnresponsive();
// Closure that would be called when window is unresponsive when closing,
// it should be cancelled when we can prove that the window is responsive.
base::CancelableRepeatingClosure window_unresponsive_closure_;
v8::Global<v8::Value> web_contents_;
base::WeakPtr<api::WebContents> api_web_contents_;
base::WeakPtrFactory<BrowserWindow> weak_factory_{this};
};
2022-06-29 19:55:47 +00:00
} // namespace electron::api
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_BROWSER_WINDOW_H_