electron/shell/browser/native_window.h

442 lines
15 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
2013-04-12 07:04:46 +00:00
// found in the LICENSE file.
2019-06-19 20:56:58 +00:00
#ifndef SHELL_BROWSER_NATIVE_WINDOW_H_
#define SHELL_BROWSER_NATIVE_WINDOW_H_
2013-04-12 07:04:46 +00:00
#include <list>
2016-07-04 06:08:55 +00:00
#include <memory>
#include <string>
#include <vector>
#include "base/memory/weak_ptr.h"
2013-04-18 12:50:58 +00:00
#include "base/observer_list.h"
2015-10-01 05:45:59 +00:00
#include "base/supports_user_data.h"
#include "content/public/browser/desktop_media_id.h"
#include "content/public/browser/web_contents_user_data.h"
#include "extensions/browser/app_window/size_constraints.h"
#include "shell/browser/native_window_observer.h"
chore: bump chromium to 93.0.4530.0 (master) (#29256) * chore: bump chromium in DEPS to 92.0.4512.6 * 2887336: [CaptureHandle][#2] Propagate CaptureHandleConfig in browser process https://chromium-review.googlesource.com/c/chromium/src/+/2887336 * refactor: base::Optional -> absl::optional * chore: fixup patch indices * chore: bump chromium in DEPS to 92.0.4514.0 * 2899417: Make build work when enable_pdf is set to false. https://chromium-review.googlesource.com/c/chromium/src/+/2899417 * 2904731: use BrowserContext instead of Profile in PreconnectManager https://chromium-review.googlesource.com/c/chromium/src/+/2904731 * 2295749: fix: check IsSecureEventInputEnabled in constructor before setting SetPasswordInputEnabled to true https://chromium-review.googlesource.com/c/chromium/src/+/2295749 * 2893803: Add a GetWebView to RenderFrame. https://chromium-review.googlesource.com/c/chromium/src/+/2893803 * 2892345: Implement WebContents::ForEachRenderFrameHost https://chromium-review.googlesource.com/c/chromium/src/+/2892345 * chore: fixup patch indices * 2892048: Real instance methods for BrowserContext: remaining 5 methods. https://chromium-review.googlesource.com/c/chromium/src/+/2892048 * 2902821: [mojo] Don't require full header includes for referenced interfaces https://chromium-review.googlesource.com/c/chromium/src/+/2902821 * 2496500: Remove last deprecated extension Event ctor. https://chromium-review.googlesource.com/c/chromium/src/+/2496500 * chore: fixup malformed pepper support patch * chore: bump chromium in DEPS to 92.0.4515.0 * 2908461: Add CreateEmptyPrintPagesParamsPtr() inside print_view_manager_base.cc. https://chromium-review.googlesource.com/c/chromium/src/+/2908461 * 2880838: viz: add optional HDRMetadata to TransferableResource https://chromium-review.googlesource.com/c/chromium/src/+/2880838 * chore: fixup patch indices * chore: bump chromium in DEPS to 92.0.4515.5 * chore: update patches * chore: bump chromium in DEPS to 92.0.4515.7 * chore: bump chromium in DEPS to 92.0.4515.9 * chore: bump chromium in DEPS to 93.0.4522.0 * chore: bump chromium in DEPS to 93.0.4523.0 * chore: bump chromium in DEPS to 93.0.4524.0 * chore: update patches * chore: enable_pak_file_integrity_checks was reverted * chore: update patches * refactor: base/optional was replaced with absl::optional Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace all usages of base::nullopt with absl::nullopt Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * chore: add missing base::Contains include Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace all usages of base::make_optional with absl::make_optional Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace WorldScriptContext() with GetScriptContextFromWorldId Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2893213 * chore: clean up left over opening namespace Refs: https://github.com/electron/electron/commit/95bfe6d08f65471394fb3005dbfa177cdf71210a * chore: add missing base::Contains include Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace GetCurrentDisplayIterator with the hard checker GetCurrentDisplay This code looks suspicious but if the iterator was invalid before it will also be invalid now. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2893191 * refactor: headers are now passed directly in extensions client Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2918906 * refactor: base::DictionaryValue::empty() has been removed Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2912424 * chore: add missing includes for network URLLoaderFactory Refs: unknown, probably a side effect of header changes * refactor: make convenience wrapper around AppendArg There is no converter FromV8 for base::StringPiece (apparently its not possible). So we now take in an std::string and use the construct for StringPiece to do implicit conversion. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2905544 * chore: add patch * chore: bump chromium in DEPS to 93.0.4525.0 * chore: update patches * refactor: CanResize has been de-virtualized Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2485774 * chore: update resource integrity patch * chore: add character encoding idl patch * chore: bump chromium in DEPS to 93.0.4526.0 * chore: update patches * chore: bump chromium in DEPS to 93.0.4527.0 * chore: bump chromium in DEPS to 93.0.4528.0 * chore: update patches * chore: update idl encoding patch * chore: bump chromium in DEPS to 93.0.4529.0 * chore: update patches * chore: bump chromium in DEPS to 93.0.4530.0 * chore: update patches * fix: only SetCanResize after the widget has been initialized * chore: add patch for vr on windows gn gen * spec: fix focus related tests on linux due to delay in focus swap * chore: remove new usages of base::Optional from main Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <sattard@slack-corp.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2021-06-03 08:05:04 +00:00
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/views/widget/widget_delegate.h"
2013-04-12 07:04:46 +00:00
namespace base {
class DictionaryValue;
}
2013-04-12 07:04:46 +00:00
namespace content {
struct NativeWebKeyboardEvent;
2013-04-12 07:04:46 +00:00
}
namespace gfx {
class Image;
2013-04-12 07:04:46 +00:00
class Point;
class Rect;
enum class ResizeEdge;
2013-04-12 07:04:46 +00:00
class Size;
2018-04-18 01:44:10 +00:00
} // namespace gfx
2013-04-12 07:04:46 +00:00
namespace gin_helper {
class Dictionary;
class PersistentDictionary;
} // namespace gin_helper
namespace electron {
2013-04-12 07:04:46 +00:00
class ElectronMenuModel;
Implement initial, experimental BrowserView API Right now, `<webview>` is the only way to embed additional content in a `BrowserWindow`. Unfortunately `<webview>` suffers from a [number of problems](https://github.com/electron/electron/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20label%3Awebview%20). To make matters worse, many of these are upstream Chromium bugs instead of Electron-specific bugs. For us at [Figma](https://www.figma.com), the main issue is very slow performance. Despite the upstream improvements to `<webview>` through the OOPIF work, it is probable that there will continue to be `<webview>`-specific bugs in the future. Therefore, this introduces a `<webview>` alternative to called `BrowserView`, which... - is a thin wrapper around `api::WebContents` (so bugs in `BrowserView` will likely also be bugs in `BrowserWindow` web contents) - is instantiated in the main process like `BrowserWindow` (and unlike `<webview>`, which lives in the DOM of a `BrowserWindow` web contents) - needs to be added to a `BrowserWindow` to display something on the screen This implements the most basic API. The API is expected to evolve and change in the near future and has consequently been marked as experimental. Please do not use this API in production unless you are prepared to deal with breaking changes. In the future, we will want to change the API to support multiple `BrowserView`s per window. We will also want to consider z-ordering auto-resizing, and possibly even nested views.
2017-04-11 17:47:30 +00:00
class NativeBrowserView;
chore: bump chromium to 0e4ca9c0a63d7a39bd910997ad4c6 (master) (#24687) * chore: bump chromium in DEPS to 1f1c4d91f6eaa4a033ec8f499d63a0717f79a42a * viz: Do not apply white level scaling for RGBA fp16 HDR video https://chromium-review.googlesource.com/c/chromium/src/+/2296006 * Move WebPreferences to WebContents https://chromium-review.googlesource.com/c/chromium/src/+/2263635 * Fix missing WeakPtr check in PreconnectManager https://chromium-review.googlesource.com/c/chromium/src/+/2309029 * Fixup swiftshader roll revision * Update patch indices * Move WebDeviceEmulationParams into common. https://chromium-review.googlesource.com/c/chromium/src/+/2303356 * Move EnableDisableDeviceEmulation to blink mojom messages https://chromium-review.googlesource.com/c/chromium/src/+/2303367 * PDF Viewer: Remove flag for two-up view https://chromium-review.googlesource.com/c/chromium/src/+/2311130 * Add mojom definition for DeviceEmulationParams. https://chromium-review.googlesource.com/c/chromium/src/+/2303491 * Remove ServiceWorkerContextWatcher from PaymentAppInstaller https://chromium-review.googlesource.com/c/chromium/src/+/2291186 * Loader: Move transferrable_url_loader.mojom into blink's mojom directory https://chromium-review.googlesource.com/c/chromium/src/+/2306123 * chore: bump chromium in DEPS to 4974f436479739025a90ebc2cc2e36d67ee1ac46 * mac: Work around Xcode 12b3 SDK bug https://chromium-review.googlesource.com/c/chromium/src/+/2315078 * Reland Update core items for macOS Big Sur. https://chromium-review.googlesource.com/c/chromium/src/+/2315162 * Update Swiftshader revision * mac/arm64: When cross-building the snapshot, use page size of the target ISA instead of the host. https://chromium-review.googlesource.com/c/v8/v8/+/2310575 * Update patch indices * Rename {,Non}ClientView::CanClose() to OnWindowCloseRequested() https://chromium-review.googlesource.com/c/chromium/src/+/2247838 * chore: bump chromium in DEPS to e9465d70d1dea539400f0fddad43358ea3c31d71 * chore: bump chromium in DEPS to bd5b71c5f20288eb26068a39ae6e0579566a51c5 * chore: bump chromium in DEPS to 786ee543048bd07d07c5ac50b7dbbdd6bdd8dcce * chore: bump chromium in DEPS to 34eb6ecbf2c5894b648900bf771a2a29de204798 * chore: bump chromium in DEPS to 567ff038d68e3adb8116a01eec863cdf34d775f5 * chore: bump chromium in DEPS to 340b45c8d4ceb2dd61969fc34e1928d3c46db48c * chore: update patches * chore: base::DeleteFile with two params is removed Should use base::DeleteFile and base::DeletePathRecursively when appropriate Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2313376 * chore: add patch for NodePlatform::PostJob impl * chore: update patches * chore: extension file access is now instrumented Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2209995 * chore: implement SetWindowFrameInScreen in OSR RWHV Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2321409 * chore: NotifyUserActivation requires a type now This is just for a histogram thing and therefore it does not matter what we pass in Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2281303 * chore: update patches * chore: bump chromium in DEPS to cd570e6dd3dcb84463ac252b04e92ceb02d8400c * chore: update patches * chore: bump chromium in DEPS to 0187908a31866992b90c59719ac1d016328f6ee0 * chore: bump chromium in DEPS to 3c9df38c508f3dba26a75248beed4882ddfb98e9 * chore: bump chromium in DEPS to 1a47d3b9cee710bd3c958c4f2d8b205710df9d50 * chore: bump chromium in DEPS to baac93040d96abdab72d46dd034c60f86e108702 * chore: bump chromium in DEPS to 13836145f97299e636491de38064b78861c4fb2e * update patches * change OS_MACOSX -> OS_MAC Refs: https://bugs.chromium.org/p/chromium/issues/detail?id=1105907 * patch: add header for ToExecutionContext in WebMessagePortConverter * chore: bump chromium in DEPS to 91ab9b6ac5d04dc034a03ad847fbfa8261328c2b * update patches * NeedToFireBeforeUnloadOrUnload -> NeedToFireBeforeUnloadOrUnloadEvents Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2288711 * chore: bump chromium in DEPS to 290deb11f0e30cb1382fd8f8793d340560283c23 * update patches * add dragdrop header for autofill popup * int -> x11::Time * patch out accessibility private API use Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2330812 * remove usage of XEvent Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2317767 * trigger recalculation of WebPreferences before renderer initialization Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2263635 * chore: bump chromium in DEPS to 6bdb484583b99c96ef3388d0c2184326581b2d5a * chore: bump chromium in DEPS to 1eb2a79cde04fd5c8ae51b4d813e6521635269e5 * chore: bump chromium in DEPS to 3dc8e3c0f400e4ca9c0a63d7a39bd910997ad4c6 * chore: update patches * fixup! trigger recalculation of WebPreferences before renderer initialization * views: Make MenuButton and RadioButton default constructible https://chromium-review.googlesource.com/c/chromium/src/+/2339586 * chore: fix code style Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Samuel Attard <sattard@slack-corp.com> Co-authored-by: Andy Locascio <andy@slack-corp.com> Co-authored-by: deepak1556 <hop2deep@gmail.com>
2020-08-12 18:33:58 +00:00
#if defined(OS_MAC)
typedef NSView* NativeWindowHandle;
#else
typedef gfx::AcceleratedWidget NativeWindowHandle;
#endif
class NativeWindow : public base::SupportsUserData,
public views::WidgetDelegate {
2013-04-12 07:04:46 +00:00
public:
~NativeWindow() override;
2013-04-12 07:04:46 +00:00
// Create window with existing WebContents, the caller is responsible for
// managing the window's live.
static NativeWindow* Create(const gin_helper::Dictionary& options,
2018-04-08 11:20:43 +00:00
NativeWindow* parent = nullptr);
void InitFromOptions(const gin_helper::Dictionary& options);
2013-04-12 07:04:46 +00:00
virtual void SetContentView(views::View* view) = 0;
2018-04-08 11:20:43 +00:00
2013-04-12 07:04:46 +00:00
virtual void Close() = 0;
2013-05-01 08:12:00 +00:00
virtual void CloseImmediately() = 0;
virtual bool IsClosed() const;
2013-04-12 07:04:46 +00:00
virtual void Focus(bool focus) = 0;
2013-05-16 14:56:52 +00:00
virtual bool IsFocused() = 0;
2013-04-12 07:04:46 +00:00
virtual void Show() = 0;
2014-10-17 14:51:20 +00:00
virtual void ShowInactive() = 0;
2013-04-12 07:04:46 +00:00
virtual void Hide() = 0;
2013-10-03 00:27:59 +00:00
virtual bool IsVisible() = 0;
virtual bool IsEnabled() = 0;
virtual void SetEnabled(bool enable) = 0;
2013-04-12 07:04:46 +00:00
virtual void Maximize() = 0;
virtual void Unmaximize() = 0;
2014-05-14 21:58:49 +00:00
virtual bool IsMaximized() = 0;
2013-04-12 07:04:46 +00:00
virtual void Minimize() = 0;
virtual void Restore() = 0;
2014-07-26 05:58:26 +00:00
virtual bool IsMinimized() = 0;
2014-11-25 06:34:14 +00:00
virtual void SetFullScreen(bool fullscreen) = 0;
2015-04-21 13:35:36 +00:00
virtual bool IsFullscreen() const = 0;
virtual void SetBounds(const gfx::Rect& bounds, bool animate = false) = 0;
virtual gfx::Rect GetBounds() = 0;
virtual void SetSize(const gfx::Size& size, bool animate = false);
virtual gfx::Size GetSize();
virtual void SetPosition(const gfx::Point& position, bool animate = false);
virtual gfx::Point GetPosition();
virtual void SetContentSize(const gfx::Size& size, bool animate = false);
virtual gfx::Size GetContentSize();
2016-08-04 19:02:24 +00:00
virtual void SetContentBounds(const gfx::Rect& bounds, bool animate = false);
virtual gfx::Rect GetContentBounds();
virtual bool IsNormal();
virtual gfx::Rect GetNormalBounds() = 0;
virtual void SetSizeConstraints(
const extensions::SizeConstraints& window_constraints);
2017-05-21 18:57:19 +00:00
virtual extensions::SizeConstraints GetSizeConstraints() const;
virtual void SetContentSizeConstraints(
const extensions::SizeConstraints& size_constraints);
2017-05-21 18:57:19 +00:00
virtual extensions::SizeConstraints GetContentSizeConstraints() const;
virtual void SetMinimumSize(const gfx::Size& size);
2017-05-21 18:57:19 +00:00
virtual gfx::Size GetMinimumSize() const;
virtual void SetMaximumSize(const gfx::Size& size);
2017-05-21 18:57:19 +00:00
virtual gfx::Size GetMaximumSize() const;
virtual gfx::Size GetContentMinimumSize() const;
virtual gfx::Size GetContentMaximumSize() const;
virtual void SetSheetOffset(const double offsetX, const double offsetY);
virtual double GetSheetOffsetX();
virtual double GetSheetOffsetY();
2013-04-12 07:04:46 +00:00
virtual void SetResizable(bool resizable) = 0;
virtual bool MoveAbove(const std::string& sourceId) = 0;
virtual void MoveTop() = 0;
2013-04-18 07:38:04 +00:00
virtual bool IsResizable() = 0;
virtual void SetMovable(bool movable) = 0;
virtual bool IsMovable() = 0;
virtual void SetMinimizable(bool minimizable) = 0;
virtual bool IsMinimizable() = 0;
2016-01-22 21:24:33 +00:00
virtual void SetMaximizable(bool maximizable) = 0;
virtual bool IsMaximizable() = 0;
2016-01-23 07:47:37 +00:00
virtual void SetFullScreenable(bool fullscreenable) = 0;
virtual bool IsFullScreenable() = 0;
virtual void SetClosable(bool closable) = 0;
virtual bool IsClosable() = 0;
virtual void SetAlwaysOnTop(ui::ZOrderLevel z_order,
const std::string& level = "floating",
int relativeLevel = 0) = 0;
virtual ui::ZOrderLevel GetZOrderLevel() = 0;
virtual void Center() = 0;
virtual void Invalidate() = 0;
2013-04-12 07:04:46 +00:00
virtual void SetTitle(const std::string& title) = 0;
2013-04-18 06:30:05 +00:00
virtual std::string GetTitle() = 0;
#if defined(OS_MAC)
virtual std::string GetAlwaysOnTopLevel() = 0;
virtual void SetActive(bool is_key) = 0;
virtual bool IsActive() const = 0;
#endif
// Ability to augment the window title for the screen readers.
void SetAccessibleTitle(const std::string& title);
std::string GetAccessibleTitle();
2013-04-12 07:04:46 +00:00
virtual void FlashFrame(bool flash) = 0;
virtual void SetSkipTaskbar(bool skip) = 0;
virtual void SetExcludedFromShownWindowsMenu(bool excluded) = 0;
virtual bool IsExcludedFromShownWindowsMenu() = 0;
virtual void SetSimpleFullScreen(bool simple_fullscreen) = 0;
virtual bool IsSimpleFullScreen() = 0;
2013-04-12 07:04:46 +00:00
virtual void SetKiosk(bool kiosk) = 0;
virtual bool IsKiosk() = 0;
virtual bool IsTabletMode() const;
virtual void SetBackgroundColor(SkColor color) = 0;
virtual SkColor GetBackgroundColor() = 0;
2016-01-23 10:55:12 +00:00
virtual void SetHasShadow(bool has_shadow) = 0;
virtual bool HasShadow() = 0;
2017-09-29 02:26:02 +00:00
virtual void SetOpacity(const double opacity) = 0;
virtual double GetOpacity() = 0;
virtual void SetRepresentedFilename(const std::string& filename);
virtual std::string GetRepresentedFilename();
virtual void SetDocumentEdited(bool edited);
virtual bool IsDocumentEdited();
virtual void SetIgnoreMouseEvents(bool ignore, bool forward) = 0;
virtual void SetContentProtection(bool enable) = 0;
2016-06-13 08:10:28 +00:00
virtual void SetFocusable(bool focusable);
virtual bool IsFocusable();
virtual void SetMenu(ElectronMenuModel* menu);
virtual void SetParentWindow(NativeWindow* parent);
virtual void AddBrowserView(NativeBrowserView* browser_view) = 0;
virtual void RemoveBrowserView(NativeBrowserView* browser_view) = 0;
virtual void SetTopBrowserView(NativeBrowserView* browser_view) = 0;
virtual content::DesktopMediaID GetDesktopMediaID() const = 0;
2017-05-21 18:57:19 +00:00
virtual gfx::NativeView GetNativeView() const = 0;
virtual gfx::NativeWindow GetNativeWindow() const = 0;
virtual gfx::AcceleratedWidget GetAcceleratedWidget() const = 0;
virtual NativeWindowHandle GetNativeWindowHandle() const = 0;
2015-08-06 03:10:34 +00:00
// Taskbar/Dock APIs.
enum class ProgressState {
kNone, // no progress, no marking
kIndeterminate, // progress, indeterminate
kError, // progress, errored (red)
kPaused, // progress, paused (yellow)
kNormal, // progress, not marked (green)
};
2018-04-18 01:44:10 +00:00
virtual void SetProgressBar(double progress, const ProgressState state) = 0;
2015-02-07 01:00:26 +00:00
virtual void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description) = 0;
2015-08-06 03:10:34 +00:00
// Workspace APIs.
virtual void SetVisibleOnAllWorkspaces(
bool visible,
bool visibleOnFullScreen = false,
bool skipTransformProcessType = false) = 0;
2015-03-27 11:41:07 +00:00
virtual bool IsVisibleOnAllWorkspaces() = 0;
2014-02-24 04:08:33 +00:00
virtual void SetAutoHideCursor(bool auto_hide);
2016-11-07 20:22:41 +00:00
// Vibrancy API
virtual void SetVibrancy(const std::string& type);
2016-11-07 20:22:41 +00:00
// Traffic Light API
chore: bump chromium to 0e4ca9c0a63d7a39bd910997ad4c6 (master) (#24687) * chore: bump chromium in DEPS to 1f1c4d91f6eaa4a033ec8f499d63a0717f79a42a * viz: Do not apply white level scaling for RGBA fp16 HDR video https://chromium-review.googlesource.com/c/chromium/src/+/2296006 * Move WebPreferences to WebContents https://chromium-review.googlesource.com/c/chromium/src/+/2263635 * Fix missing WeakPtr check in PreconnectManager https://chromium-review.googlesource.com/c/chromium/src/+/2309029 * Fixup swiftshader roll revision * Update patch indices * Move WebDeviceEmulationParams into common. https://chromium-review.googlesource.com/c/chromium/src/+/2303356 * Move EnableDisableDeviceEmulation to blink mojom messages https://chromium-review.googlesource.com/c/chromium/src/+/2303367 * PDF Viewer: Remove flag for two-up view https://chromium-review.googlesource.com/c/chromium/src/+/2311130 * Add mojom definition for DeviceEmulationParams. https://chromium-review.googlesource.com/c/chromium/src/+/2303491 * Remove ServiceWorkerContextWatcher from PaymentAppInstaller https://chromium-review.googlesource.com/c/chromium/src/+/2291186 * Loader: Move transferrable_url_loader.mojom into blink's mojom directory https://chromium-review.googlesource.com/c/chromium/src/+/2306123 * chore: bump chromium in DEPS to 4974f436479739025a90ebc2cc2e36d67ee1ac46 * mac: Work around Xcode 12b3 SDK bug https://chromium-review.googlesource.com/c/chromium/src/+/2315078 * Reland Update core items for macOS Big Sur. https://chromium-review.googlesource.com/c/chromium/src/+/2315162 * Update Swiftshader revision * mac/arm64: When cross-building the snapshot, use page size of the target ISA instead of the host. https://chromium-review.googlesource.com/c/v8/v8/+/2310575 * Update patch indices * Rename {,Non}ClientView::CanClose() to OnWindowCloseRequested() https://chromium-review.googlesource.com/c/chromium/src/+/2247838 * chore: bump chromium in DEPS to e9465d70d1dea539400f0fddad43358ea3c31d71 * chore: bump chromium in DEPS to bd5b71c5f20288eb26068a39ae6e0579566a51c5 * chore: bump chromium in DEPS to 786ee543048bd07d07c5ac50b7dbbdd6bdd8dcce * chore: bump chromium in DEPS to 34eb6ecbf2c5894b648900bf771a2a29de204798 * chore: bump chromium in DEPS to 567ff038d68e3adb8116a01eec863cdf34d775f5 * chore: bump chromium in DEPS to 340b45c8d4ceb2dd61969fc34e1928d3c46db48c * chore: update patches * chore: base::DeleteFile with two params is removed Should use base::DeleteFile and base::DeletePathRecursively when appropriate Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2313376 * chore: add patch for NodePlatform::PostJob impl * chore: update patches * chore: extension file access is now instrumented Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2209995 * chore: implement SetWindowFrameInScreen in OSR RWHV Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2321409 * chore: NotifyUserActivation requires a type now This is just for a histogram thing and therefore it does not matter what we pass in Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2281303 * chore: update patches * chore: bump chromium in DEPS to cd570e6dd3dcb84463ac252b04e92ceb02d8400c * chore: update patches * chore: bump chromium in DEPS to 0187908a31866992b90c59719ac1d016328f6ee0 * chore: bump chromium in DEPS to 3c9df38c508f3dba26a75248beed4882ddfb98e9 * chore: bump chromium in DEPS to 1a47d3b9cee710bd3c958c4f2d8b205710df9d50 * chore: bump chromium in DEPS to baac93040d96abdab72d46dd034c60f86e108702 * chore: bump chromium in DEPS to 13836145f97299e636491de38064b78861c4fb2e * update patches * change OS_MACOSX -> OS_MAC Refs: https://bugs.chromium.org/p/chromium/issues/detail?id=1105907 * patch: add header for ToExecutionContext in WebMessagePortConverter * chore: bump chromium in DEPS to 91ab9b6ac5d04dc034a03ad847fbfa8261328c2b * update patches * NeedToFireBeforeUnloadOrUnload -> NeedToFireBeforeUnloadOrUnloadEvents Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2288711 * chore: bump chromium in DEPS to 290deb11f0e30cb1382fd8f8793d340560283c23 * update patches * add dragdrop header for autofill popup * int -> x11::Time * patch out accessibility private API use Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2330812 * remove usage of XEvent Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2317767 * trigger recalculation of WebPreferences before renderer initialization Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2263635 * chore: bump chromium in DEPS to 6bdb484583b99c96ef3388d0c2184326581b2d5a * chore: bump chromium in DEPS to 1eb2a79cde04fd5c8ae51b4d813e6521635269e5 * chore: bump chromium in DEPS to 3dc8e3c0f400e4ca9c0a63d7a39bd910997ad4c6 * chore: update patches * fixup! trigger recalculation of WebPreferences before renderer initialization * views: Make MenuButton and RadioButton default constructible https://chromium-review.googlesource.com/c/chromium/src/+/2339586 * chore: fix code style Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Samuel Attard <sattard@slack-corp.com> Co-authored-by: Andy Locascio <andy@slack-corp.com> Co-authored-by: deepak1556 <hop2deep@gmail.com>
2020-08-12 18:33:58 +00:00
#if defined(OS_MAC)
virtual void SetWindowButtonVisibility(bool visible) = 0;
virtual bool GetWindowButtonVisibility() const = 0;
chore: bump chromium to 93.0.4530.0 (master) (#29256) * chore: bump chromium in DEPS to 92.0.4512.6 * 2887336: [CaptureHandle][#2] Propagate CaptureHandleConfig in browser process https://chromium-review.googlesource.com/c/chromium/src/+/2887336 * refactor: base::Optional -> absl::optional * chore: fixup patch indices * chore: bump chromium in DEPS to 92.0.4514.0 * 2899417: Make build work when enable_pdf is set to false. https://chromium-review.googlesource.com/c/chromium/src/+/2899417 * 2904731: use BrowserContext instead of Profile in PreconnectManager https://chromium-review.googlesource.com/c/chromium/src/+/2904731 * 2295749: fix: check IsSecureEventInputEnabled in constructor before setting SetPasswordInputEnabled to true https://chromium-review.googlesource.com/c/chromium/src/+/2295749 * 2893803: Add a GetWebView to RenderFrame. https://chromium-review.googlesource.com/c/chromium/src/+/2893803 * 2892345: Implement WebContents::ForEachRenderFrameHost https://chromium-review.googlesource.com/c/chromium/src/+/2892345 * chore: fixup patch indices * 2892048: Real instance methods for BrowserContext: remaining 5 methods. https://chromium-review.googlesource.com/c/chromium/src/+/2892048 * 2902821: [mojo] Don't require full header includes for referenced interfaces https://chromium-review.googlesource.com/c/chromium/src/+/2902821 * 2496500: Remove last deprecated extension Event ctor. https://chromium-review.googlesource.com/c/chromium/src/+/2496500 * chore: fixup malformed pepper support patch * chore: bump chromium in DEPS to 92.0.4515.0 * 2908461: Add CreateEmptyPrintPagesParamsPtr() inside print_view_manager_base.cc. https://chromium-review.googlesource.com/c/chromium/src/+/2908461 * 2880838: viz: add optional HDRMetadata to TransferableResource https://chromium-review.googlesource.com/c/chromium/src/+/2880838 * chore: fixup patch indices * chore: bump chromium in DEPS to 92.0.4515.5 * chore: update patches * chore: bump chromium in DEPS to 92.0.4515.7 * chore: bump chromium in DEPS to 92.0.4515.9 * chore: bump chromium in DEPS to 93.0.4522.0 * chore: bump chromium in DEPS to 93.0.4523.0 * chore: bump chromium in DEPS to 93.0.4524.0 * chore: update patches * chore: enable_pak_file_integrity_checks was reverted * chore: update patches * refactor: base/optional was replaced with absl::optional Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace all usages of base::nullopt with absl::nullopt Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * chore: add missing base::Contains include Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace all usages of base::make_optional with absl::make_optional Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace WorldScriptContext() with GetScriptContextFromWorldId Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2893213 * chore: clean up left over opening namespace Refs: https://github.com/electron/electron/commit/95bfe6d08f65471394fb3005dbfa177cdf71210a * chore: add missing base::Contains include Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2910202 * refactor: replace GetCurrentDisplayIterator with the hard checker GetCurrentDisplay This code looks suspicious but if the iterator was invalid before it will also be invalid now. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2893191 * refactor: headers are now passed directly in extensions client Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2918906 * refactor: base::DictionaryValue::empty() has been removed Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2912424 * chore: add missing includes for network URLLoaderFactory Refs: unknown, probably a side effect of header changes * refactor: make convenience wrapper around AppendArg There is no converter FromV8 for base::StringPiece (apparently its not possible). So we now take in an std::string and use the construct for StringPiece to do implicit conversion. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2905544 * chore: add patch * chore: bump chromium in DEPS to 93.0.4525.0 * chore: update patches * refactor: CanResize has been de-virtualized Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2485774 * chore: update resource integrity patch * chore: add character encoding idl patch * chore: bump chromium in DEPS to 93.0.4526.0 * chore: update patches * chore: bump chromium in DEPS to 93.0.4527.0 * chore: bump chromium in DEPS to 93.0.4528.0 * chore: update patches * chore: update idl encoding patch * chore: bump chromium in DEPS to 93.0.4529.0 * chore: update patches * chore: bump chromium in DEPS to 93.0.4530.0 * chore: update patches * fix: only SetCanResize after the widget has been initialized * chore: add patch for vr on windows gn gen * spec: fix focus related tests on linux due to delay in focus swap * chore: remove new usages of base::Optional from main Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <sattard@slack-corp.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2021-06-03 08:05:04 +00:00
virtual void SetTrafficLightPosition(absl::optional<gfx::Point> position) = 0;
virtual absl::optional<gfx::Point> GetTrafficLightPosition() const = 0;
virtual void RedrawTrafficLights() = 0;
virtual void UpdateFrame() = 0;
#endif
// Touchbar API
virtual void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items);
2017-03-01 00:08:12 +00:00
virtual void RefreshTouchBarItem(const std::string& item_id);
virtual void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item);
// Native Tab API
virtual void SelectPreviousTab();
virtual void SelectNextTab();
virtual void MergeAllWindows();
virtual void MoveTabToNewWindow();
virtual void ToggleTabBar();
virtual bool AddTabbedWindow(NativeWindow* window);
2014-11-12 09:36:20 +00:00
// Toggle the menu bar.
virtual void SetAutoHideMenuBar(bool auto_hide);
virtual bool IsMenuBarAutoHide();
virtual void SetMenuBarVisibility(bool visible);
virtual bool IsMenuBarVisible();
// Set the aspect ratio when resizing window.
double GetAspectRatio();
gfx::Size GetAspectRatioExtraSize();
virtual void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
2016-11-21 18:30:13 +00:00
// File preview APIs.
2016-10-14 16:42:50 +00:00
virtual void PreviewFile(const std::string& path,
2016-10-26 00:47:22 +00:00
const std::string& display_name);
2016-11-21 18:30:13 +00:00
virtual void CloseFilePreview();
virtual void SetGTKDarkThemeEnabled(bool use_dark_theme) {}
// Converts between content bounds and window bounds.
virtual gfx::Rect ContentBoundsToWindowBounds(
const gfx::Rect& bounds) const = 0;
virtual gfx::Rect WindowBoundsToContentBounds(
const gfx::Rect& bounds) const = 0;
base::WeakPtr<NativeWindow> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
virtual gfx::Rect GetWindowControlsOverlayRect();
virtual void SetWindowControlsOverlayRect(const gfx::Rect& overlay_rect);
// Methods called by the WebContents.
virtual void HandleKeyboardEvent(
content::WebContents*,
const content::NativeWebKeyboardEvent& event) {}
// Public API used by platform-dependent delegates and observers to send UI
// related notifications.
void NotifyWindowRequestPreferredWith(int* width);
void NotifyWindowCloseButtonClicked();
void NotifyWindowClosed();
void NotifyWindowEndSession();
void NotifyWindowBlur();
void NotifyWindowFocus();
void NotifyWindowShow();
2020-06-29 20:15:28 +00:00
void NotifyWindowIsKeyChanged(bool is_key);
void NotifyWindowHide();
2014-11-25 04:43:25 +00:00
void NotifyWindowMaximize();
void NotifyWindowUnmaximize();
void NotifyWindowMinimize();
void NotifyWindowRestore();
2015-05-09 15:55:10 +00:00
void NotifyWindowMove();
void NotifyWindowWillResize(const gfx::Rect& new_bounds,
const gfx::ResizeEdge& edge,
bool* prevent_default);
2015-05-09 15:55:10 +00:00
void NotifyWindowResize();
void NotifyWindowResized();
void NotifyWindowWillMove(const gfx::Rect& new_bounds, bool* prevent_default);
2015-05-20 08:37:13 +00:00
void NotifyWindowMoved();
2016-01-22 00:31:09 +00:00
void NotifyWindowScrollTouchBegin();
void NotifyWindowScrollTouchEnd();
void NotifyWindowSwipe(const std::string& direction);
void NotifyWindowRotateGesture(float rotation);
void NotifyWindowSheetBegin();
void NotifyWindowSheetEnd();
virtual void NotifyWindowEnterFullScreen();
virtual void NotifyWindowLeaveFullScreen();
void NotifyWindowEnterHtmlFullScreen();
void NotifyWindowLeaveHtmlFullScreen();
void NotifyWindowAlwaysOnTopChanged();
void NotifyWindowExecuteAppCommand(const std::string& command);
void NotifyTouchBarItemInteraction(const std::string& item_id,
const base::DictionaryValue& details);
void NotifyNewWindowForTab();
void NotifyWindowSystemContextMenu(int x, int y, bool* prevent_default);
void NotifyLayoutWindowControlsOverlay();
2018-04-18 01:44:10 +00:00
#if defined(OS_WIN)
2015-10-27 01:12:01 +00:00
void NotifyWindowMessage(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
2018-04-18 01:44:10 +00:00
void AddObserver(NativeWindowObserver* obs) { observers_.AddObserver(obs); }
2013-04-18 12:50:58 +00:00
void RemoveObserver(NativeWindowObserver* obs) {
observers_.RemoveObserver(obs);
}
views::Widget* widget() const { return widget_.get(); }
views::View* content_view() const { return content_view_; }
feat: enable windows control overlay on Windows (#29600) * rebase "feat: enable windows control overlay on Windows" * correct compilation error * fix linting errors * modify includes and build file * change `hidden` option to `overlay` * add patch to fix visual layout * add button background color parameter * add button text color parameter * modify `overlay` in docs and modify button hover/press transition color * change `text` to `symbol` * remove todo and fix `text` replacement * add new titleBarOverlay property and remove titleBarStyle `overlay` * update browser and frameless window docs * remove chromium patches * chore: update patches * change button hover color, update trailing `_`, update test file * add dchecks, update title bar drawing checks, update test file * modify for mac and linux builds * update docs with overlayColor and overlaySymbolColor * add corner and side hit test info * modify docs and copyright info * modify `titlebar_overlay_` as boolean or object * move `title_bar_style_ to `NativeWindow` * update docs with boolean and object titlebar_overlay_ * add `IsEmpty` checks * move get options for boolean and object checks * fix linting error * disable `use_lld` for macos * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Apply docs suggestions from code review Co-authored-by: Jeremy Rose <jeremya@chromium.org> * modify `true` option description `titleBarOverlay` * ci: cleanup keychain after tests on arm64 mac (#30472) Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2021-08-11 18:07:36 +00:00
enum class TitleBarStyle {
kNormal,
kHidden,
kHiddenInset,
kCustomButtonsOnHover,
};
TitleBarStyle title_bar_style() const { return title_bar_style_; }
bool has_frame() const { return has_frame_; }
void set_has_frame(bool has_frame) { has_frame_ = has_frame; }
bool transparent() const { return transparent_; }
bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
NativeWindow* parent() const { return parent_; }
bool is_modal() const { return is_modal_; }
std::list<NativeBrowserView*> browser_views() const { return browser_views_; }
int32_t window_id() const { return next_id_; }
2013-04-12 07:04:46 +00:00
protected:
NativeWindow(const gin_helper::Dictionary& options, NativeWindow* parent);
2013-04-12 07:04:46 +00:00
// views::WidgetDelegate:
views::Widget* GetWidget() override;
const views::Widget* GetWidget() const override;
std::u16string GetAccessibleWindowTitle() const override;
void set_content_view(views::View* view) { content_view_ = view; }
void add_browser_view(NativeBrowserView* browser_view) {
browser_views_.push_back(browser_view);
}
void remove_browser_view(NativeBrowserView* browser_view) {
browser_views_.remove_if(
[&browser_view](NativeBrowserView* n) { return (n == browser_view); });
}
feat: enable windows control overlay on Windows (#29600) * rebase "feat: enable windows control overlay on Windows" * correct compilation error * fix linting errors * modify includes and build file * change `hidden` option to `overlay` * add patch to fix visual layout * add button background color parameter * add button text color parameter * modify `overlay` in docs and modify button hover/press transition color * change `text` to `symbol` * remove todo and fix `text` replacement * add new titleBarOverlay property and remove titleBarStyle `overlay` * update browser and frameless window docs * remove chromium patches * chore: update patches * change button hover color, update trailing `_`, update test file * add dchecks, update title bar drawing checks, update test file * modify for mac and linux builds * update docs with overlayColor and overlaySymbolColor * add corner and side hit test info * modify docs and copyright info * modify `titlebar_overlay_` as boolean or object * move `title_bar_style_ to `NativeWindow` * update docs with boolean and object titlebar_overlay_ * add `IsEmpty` checks * move get options for boolean and object checks * fix linting error * disable `use_lld` for macos * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Apply docs suggestions from code review Co-authored-by: Jeremy Rose <jeremya@chromium.org> * modify `true` option description `titleBarOverlay` * ci: cleanup keychain after tests on arm64 mac (#30472) Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2021-08-11 18:07:36 +00:00
// The boolean parsing of the "titleBarOverlay" option
bool titlebar_overlay_ = false;
feat: enable windows control overlay on Windows (#29600) * rebase "feat: enable windows control overlay on Windows" * correct compilation error * fix linting errors * modify includes and build file * change `hidden` option to `overlay` * add patch to fix visual layout * add button background color parameter * add button text color parameter * modify `overlay` in docs and modify button hover/press transition color * change `text` to `symbol` * remove todo and fix `text` replacement * add new titleBarOverlay property and remove titleBarStyle `overlay` * update browser and frameless window docs * remove chromium patches * chore: update patches * change button hover color, update trailing `_`, update test file * add dchecks, update title bar drawing checks, update test file * modify for mac and linux builds * update docs with overlayColor and overlaySymbolColor * add corner and side hit test info * modify docs and copyright info * modify `titlebar_overlay_` as boolean or object * move `title_bar_style_ to `NativeWindow` * update docs with boolean and object titlebar_overlay_ * add `IsEmpty` checks * move get options for boolean and object checks * fix linting error * disable `use_lld` for macos * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Update docs/api/frameless-window.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * Apply docs suggestions from code review Co-authored-by: Jeremy Rose <jeremya@chromium.org> * modify `true` option description `titleBarOverlay` * ci: cleanup keychain after tests on arm64 mac (#30472) Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2021-08-11 18:07:36 +00:00
// The "titleBarStyle" option.
TitleBarStyle title_bar_style_ = TitleBarStyle::kNormal;
2013-04-12 07:04:46 +00:00
private:
std::unique_ptr<views::Widget> widget_;
static int32_t next_id_;
// The content view, weak ref.
views::View* content_view_ = nullptr;
// Whether window has standard frame.
bool has_frame_ = true;
// Whether window is transparent.
bool transparent_ = false;
// Minimum and maximum size, stored as content size.
extensions::SizeConstraints size_constraints_;
// Whether window can be resized larger than screen.
bool enable_larger_than_screen_ = false;
// The windows has been closed.
bool is_closed_ = false;
// Used to display sheets at the appropriate horizontal and vertical offsets
2016-06-18 13:26:26 +00:00
// on macOS.
double sheet_offset_x_ = 0.0;
double sheet_offset_y_ = 0.0;
2015-07-16 18:26:48 +00:00
// Used to maintain the aspect ratio of a view which is inside of the
// content view.
double aspect_ratio_ = 0.0;
gfx::Size aspect_ratio_extraSize_;
// The parent window, it is guaranteed to be valid during this window's life.
NativeWindow* parent_ = nullptr;
// Is this a modal window.
bool is_modal_ = false;
// The browser view layer.
std::list<NativeBrowserView*> browser_views_;
// Observers of this window.
2015-09-02 07:16:49 +00:00
base::ObserverList<NativeWindowObserver> observers_;
// Accessible title.
std::u16string accessible_title_;
gfx::Rect overlay_rect_;
base::WeakPtrFactory<NativeWindow> weak_factory_{this};
2013-04-12 07:04:46 +00:00
DISALLOW_COPY_AND_ASSIGN(NativeWindow);
};
// This class provides a hook to get a NativeWindow from a WebContents.
2018-04-18 01:44:10 +00:00
class NativeWindowRelay
: public content::WebContentsUserData<NativeWindowRelay> {
public:
static void CreateForWebContents(content::WebContents*,
base::WeakPtr<NativeWindow>);
~NativeWindowRelay() override;
NativeWindow* GetNativeWindow() const { return native_window_.get(); }
WEB_CONTENTS_USER_DATA_KEY_DECL();
private:
friend class content::WebContentsUserData<NativeWindow>;
explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window);
base::WeakPtr<NativeWindow> native_window_;
};
} // namespace electron
2013-04-12 07:04:46 +00:00
2019-06-19 20:56:58 +00:00
#endif // SHELL_BROWSER_NATIVE_WINDOW_H_