electron/shell/browser/native_window.cc

708 lines
20 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.
#include "shell/browser/native_window.h"
2013-04-12 07:04:46 +00:00
#include <algorithm>
2013-04-12 07:04:46 +00:00
#include <string>
#include <vector>
2013-04-12 07:04:46 +00:00
2019-08-29 06:57:11 +00:00
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "shell/browser/browser.h"
#include "shell/browser/window_list.h"
#include "shell/common/color_util.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
#include "shell/common/options_switches.h"
#include "ui/views/widget/widget.h"
#if defined(OS_WIN)
#include "ui/base/win/shell.h"
#include "ui/display/win/screen_win.h"
#endif
2013-04-12 07:04:46 +00:00
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
namespace gin {
template <>
struct Converter<electron::NativeWindow::TitleBarStyle> {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
electron::NativeWindow::TitleBarStyle* out) {
using TitleBarStyle = electron::NativeWindow::TitleBarStyle;
std::string title_bar_style;
if (!ConvertFromV8(isolate, val, &title_bar_style))
return false;
if (title_bar_style == "hidden") {
*out = TitleBarStyle::kHidden;
#if defined(OS_MAC)
} else if (title_bar_style == "hiddenInset") {
*out = TitleBarStyle::kHiddenInset;
} else if (title_bar_style == "customButtonsOnHover") {
*out = TitleBarStyle::kCustomButtonsOnHover;
#endif
} else {
return false;
}
return true;
}
};
} // namespace gin
namespace electron {
2013-04-12 07:04:46 +00:00
namespace {
#if defined(OS_WIN)
2018-05-12 17:51:19 +00:00
gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
if (!window->transparent() || !ui::win::IsAeroGlassEnabled())
return size;
2018-05-12 17:51:19 +00:00
gfx::Size min_size = display::win::ScreenWin::ScreenToDIPSize(
window->GetAcceleratedWidget(), gfx::Size(64, 64));
2018-05-12 17:51:19 +00:00
// Some AMD drivers can't display windows that are less than 64x64 pixels,
// so expand them to be at least that size. http://crbug.com/286609
gfx::Size expanded(std::max(size.width(), min_size.width()),
std::max(size.height(), min_size.height()));
return expanded;
}
#endif
} // namespace
NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
NativeWindow* parent)
: widget_(std::make_unique<views::Widget>()), parent_(parent) {
++next_id_;
options.Get(options::kFrame, &has_frame_);
options.Get(options::kTransparent, &transparent_);
options.Get(options::kEnableLargerThanScreen, &enable_larger_than_screen_);
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
options.Get(options::kTitleBarStyle, &title_bar_style_);
v8::Local<v8::Value> titlebar_overlay;
if (options.Get(options::ktitleBarOverlay, &titlebar_overlay)) {
if (titlebar_overlay->IsBoolean()) {
options.Get(options::ktitleBarOverlay, &titlebar_overlay_);
} else if (titlebar_overlay->IsObject()) {
titlebar_overlay_ = true;
#if !defined(OS_WIN)
DCHECK(false);
#endif
}
}
if (parent)
options.Get("modal", &is_modal_);
WindowList::AddWindow(this);
2013-04-12 07:04:46 +00:00
}
NativeWindow::~NativeWindow() {
// It's possible that the windows gets destroyed before it's closed, in that
// case we need to ensure the Widget delegate gets destroyed and
// OnWindowClosed message is still notified.
if (widget_->widget_delegate())
widget_->OnNativeWidgetDestroyed();
NotifyWindowClosed();
2013-04-12 07:04:46 +00:00
}
void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
2013-04-12 07:04:46 +00:00
// Setup window from options.
int x = -1, y = -1;
bool center;
if (options.Get(options::kX, &x) && options.Get(options::kY, &y)) {
SetPosition(gfx::Point(x, y));
2017-10-30 18:19:50 +00:00
2017-10-31 17:31:05 +00:00
#if defined(OS_WIN)
2017-11-01 18:30:32 +00:00
// FIXME(felixrieseberg): Dirty, dirty workaround for
2017-10-30 18:19:50 +00:00
// https://github.com/electron/electron/issues/10862
// Somehow, we need to call `SetBounds` twice to get
// usable results. The root cause is still unknown.
SetPosition(gfx::Point(x, y));
#endif
} else if (options.Get(options::kCenter, &center) && center) {
Center();
2013-04-12 07:04:46 +00:00
}
bool use_content_size = false;
options.Get(options::kUseContentSize, &use_content_size);
// On Linux and Window we may already have maximum size defined.
extensions::SizeConstraints size_constraints(
use_content_size ? GetContentSizeConstraints() : GetSizeConstraints());
int min_height = 0, min_width = 0;
chore: bump chromium to 98.0.4706.0 (main) (#31555) * chore: bump chromium in DEPS to 97.0.4678.0 * chore: bump chromium in DEPS to 97.0.4679.0 * chore: bump chromium in DEPS to 97.0.4680.0 * chore: bump chromium in DEPS to 97.0.4681.0 * chore: bump chromium in DEPS to 97.0.4682.0 * chore: update patches * 3234737: Disable -Wunused-but-set-variable Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3234737 * 3216953: Reland "Move task-related files from base/ to base/task/" Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3216953 * 3202710: TimeDelta factory function migration. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3202710 * 3226841: Rename WCO::RenderProcessGone to PrimaryMainFrameRenderProcessGone Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3226841 * 3212165: blink/gin: changes blink to load snapshot based on runtime information Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3212165 * 3220292: Deprecate returning a GURL from GURL::GetOrigin() Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3220292 * 3231995: build: Enable -Wbitwise-instead-of-logical everywhere except iOS and Windows Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3231995 * 3205121: Remove base::DictionaryValue::GetDouble Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3205121 * 3208413: [flags] Make --js-flags settings have priority over V8 features Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3208413 * chore: bump chromium in DEPS to 97.0.4683.0 * chore: update patches * 3188834: Combine RWHVBase GetCurrentDeviceScaleFactor/GetDeviceScaleFactor Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3188834 * chore: update process_singleton patches * chore: bump chromium in DEPS to 97.0.4684.0 * chore: update patches * chore: bump chromium in DEPS to 97.0.4685.0 * chore: update patches * chore: bump chromium in DEPS to 97.0.4686.0 * chore: update patches * chore: bump chromium in DEPS to 97.0.4687.0 * chore: update patches * chore: bump chromium in DEPS to 97.0.4688.0 * chore: update patches * 3247722: Use correct source_site_instance if navigating via context menu Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3247722 Update signature of HandleContextMenu() * 3247722: Use correct source_site_instance if navigating via context menu Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3247722 Update signature of HandleContextMenu() * 3223422: Remove PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE enum option Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3223422 sync pepper_plugin_support.patch with upstream * chore: bump chromium in DEPS to 97.0.4689.0 * 3247791: ax_mac_merge: Merge AX Math attribute implementations Xref: ax_mac_merge: Merge AX Math attribute implementations chore: fix minor patch shear in #includes * 3243425: Add VisibleTimeRequestTrigger helper class Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3243425 chore: fix minor patch shear in #includes * chore: regen chromium patches * fixup! 3247722: Use correct source_site_instance if navigating via context menu * chore: bump chromium in DEPS to 97.0.4690.0 * 3188659: Window Placement: make GetScreenInfo(s) const Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3188659 simple sync GetScreenInfo with upstream refactor * chore: update patches * chore: bump chromium in DEPS to 97.0.4690.4 * chore: bump chromium in DEPS to 97.0.4692.0 * 3198073: ozone: //content: clean up from USE_X11 Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3198073 Fixing patch shear. Nothing to see here. * 3252338: Remove label images checkbox from chrome://accessibility page Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3252338 Part of our a11y patch is no longer needed due to upstream label removal * 3258183: Remove DISALLOW_IMPLICIT_CONSTRUCTORS() definition Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3258183 Replace our use of the macro with explicitly-deleted class methods. See https://chromium-review.googlesource.com/c/chromium/src/+/3256952 for upstream examples of this same replacement. * chore: update patches * 3247295: Unwind SecurityStyleExplanations Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3247295 update GetSecurityStyle() signature and impl to match upstream changes * 3259578: media: grabs lock to ensure video output when occluded Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3259578 Add stub for new upstream virtual method OnCapturerCountChanged() * fixup! 3247295: Unwind SecurityStyleExplanations * 3238504: Fix up drag image is not shown from bookmark bar Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3238504 SetDragImage() no longer takes a widget argument * 3217452: [devtools] Add getSyncInformation host binding Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3217452 Add stub for new upstream method GetSyncInformation(). Stub sends info back to caller saying that syncing is disabled. * chore: bump chromium in DEPS to 98.0.4693.0 * chore: bump chromium in DEPS to 98.0.4694.0 * chore: bump chromium in DEPS to 98.0.4695.0 * chore: bump chromium in DEPS to 98.0.4696.0 * chore: bump chromium in DEPS to 98.0.4697.0 * chore: bump chromium in DEPS to 98.0.4699.0 * chore: bump chromium in DEPS to 98.0.4701.0 * chore: bump chromium in DEPS to 98.0.4703.0 * chore: bump chromium in DEPS to 98.0.4705.0 * chore: bump chromium in DEPS to 98.0.4706.0 * chore: update patches * 3279210: Rename "base/macros.h" => "base/ignore_result.h" https://chromium-review.googlesource.com/c/chromium/src/+/3279210 * 3259964: Remove all DISALLOW_COPY_AND_ASSIGNs https://chromium-review.googlesource.com/c/chromium/src/+/3259964 * 3269029: blink/gin: sets histogram callbacks during isolate creation https://chromium-review.googlesource.com/c/chromium/src/+/3269029 * fixup after rebase * [content] Make ContentMainParams and MainFunctionParams move-only https://chromium-review.googlesource.com/c/chromium/src/+/3244976 * 3255305: Stop sending the securityStateChanged event and unwind https://chromium-review.googlesource.com/c/chromium/src/+/3255305 * [Blink] Add promise support to WebLocalFrame::RequestExecuteScript() https://chromium-review.googlesource.com/c/chromium/src/+/3230010 * 3256162: Simplify RWHV Show and ShowWithVisibility handling https://chromium-review.googlesource.com/c/chromium/src/+/3256162 * 3263824: ozone: //ui/base: clean up from USE_X11 1/* https://chromium-review.googlesource.com/c/chromium/src/+/3263824 * Request or cancel RecordContentToPresentationTimeRequest during capture https://chromium-review.googlesource.com/c/chromium/src/+/3256802 * appcache: remove BrowsingData/quota references https://chromium-review.googlesource.com/c/chromium/src/+/3255725 * [Autofill] Don't show Autofill dropdown if overlaps with permissions https://chromium-review.googlesource.com/c/chromium/src/+/3236729 * Rename to_different_document to should_show_loading_ui in LoadingStateChanged() callbacks https://chromium-review.googlesource.com/c/chromium/src/+/3268574 * cleanup patch * fixup [content] Make ContentMainParams and MainFunctionParams move-only * 3279210: Rename "base/macros.h" => "base/ignore_result.h" https://chromium-review.googlesource.com/c/chromium/src/+/3279210 * ozone: //chrome/browser clean up from USE_X11 https://chromium-review.googlesource.com/c/chromium/src/+/3186490 Refs: https://github.com/electron/electron/issues/31382 * chore: update support_mixed_sandbox_with_zygote.patch * Enable -Wunused-but-set-variable. Refs https://chromium-review.googlesource.com/c/chromium/src/+/3234737 * fixup! ozone: //ui/base: clean up from USE_X11 1/* * fixup! ozone: //chrome/browser clean up from USE_X11 * chore: fix deprecation warning in libuv * chore: fixup for lint * 3251161: Reland "Make the Clang update.py script require Python 3" https://chromium-review.googlesource.com/c/chromium/src/+/3251161 * fixup: Enable -Wunused-but-set-variable. * [base][win] Rename DIR_APP_DATA to DIR_ROAMING_APP_DATA https://chromium-review.googlesource.com/c/chromium/src/+/3262369 * Replace sandbox::policy::SandboxType with mojom Sandbox enum https://chromium-review.googlesource.com/c/chromium/src/+/3213677 * fixup: [content] Make ContentMainParams and MainFunctionParams move-only * build: ensure angle has a full git checkout available to it * fixup: [base][win] Rename DIR_APP_DATA to DIR_ROAMING_APP_DATA * fixup lint * [unseasoned-pdf] Dispatch 'afterprint' event in PDF plugin frame https://chromium-review.googlesource.com/c/chromium/src/+/3223434 * fixup: [Autofill] Don't show Autofill dropdown if overlaps with permissions * 3217591: Move browser UI CSS color parsing to own file part 2/2 https://chromium-review.googlesource.com/c/chromium/src/+/3217591 * Make kNoSandboxAndElevatedPrivileges only available to utilities https://chromium-review.googlesource.com/c/chromium/src/+/3276784 * 3211575: [modules] Change ScriptOrModule to custom Struct https://chromium-review.googlesource.com/c/v8/v8/+/3211575 * Address review feedback * chore: update patches * 3211575: [modules] Change ScriptOrModule to custom Struct https://chromium-review.googlesource.com/c/v8/v8/+/3211575 * fix: unused variable compat * chore: remove redundant patch * fixup for 3262517: Re-enable WindowCaptureMacV2 https://chromium-review.googlesource.com/c/chromium/src/+/3262517 * chore: cleanup todo The functions added in https://chromium-review.googlesource.com/c/chromium/src/+/3256802 are not used by offscreen rendering. * fixup: update mas_no_private_api.patch * 3216879: [PA] Make features::kPartitionAllocLazyCommit to be PartitionOptions::LazyCommit Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3216879 Fixes up commit b2f1aca95604ec61649808c846657454097e6935 * chore: cleanup support_mixed_sandbox_with_zygote.patch * test: use window focus event instead of delay to wait for webContents focus Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: VerteDinde <khammond@slack-corp.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: deepak1556 <hop2deep@gmail.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-11-24 08:45:59 +00:00
if (options.Get(options::kMinHeight, &min_height) ||
options.Get(options::kMinWidth, &min_width)) {
size_constraints.set_minimum_size(gfx::Size(min_width, min_height));
2013-04-12 07:04:46 +00:00
}
int max_height = INT_MAX, max_width = INT_MAX;
chore: bump chromium to 98.0.4706.0 (main) (#31555) * chore: bump chromium in DEPS to 97.0.4678.0 * chore: bump chromium in DEPS to 97.0.4679.0 * chore: bump chromium in DEPS to 97.0.4680.0 * chore: bump chromium in DEPS to 97.0.4681.0 * chore: bump chromium in DEPS to 97.0.4682.0 * chore: update patches * 3234737: Disable -Wunused-but-set-variable Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3234737 * 3216953: Reland "Move task-related files from base/ to base/task/" Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3216953 * 3202710: TimeDelta factory function migration. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3202710 * 3226841: Rename WCO::RenderProcessGone to PrimaryMainFrameRenderProcessGone Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3226841 * 3212165: blink/gin: changes blink to load snapshot based on runtime information Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3212165 * 3220292: Deprecate returning a GURL from GURL::GetOrigin() Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3220292 * 3231995: build: Enable -Wbitwise-instead-of-logical everywhere except iOS and Windows Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3231995 * 3205121: Remove base::DictionaryValue::GetDouble Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3205121 * 3208413: [flags] Make --js-flags settings have priority over V8 features Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3208413 * chore: bump chromium in DEPS to 97.0.4683.0 * chore: update patches * 3188834: Combine RWHVBase GetCurrentDeviceScaleFactor/GetDeviceScaleFactor Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3188834 * chore: update process_singleton patches * chore: bump chromium in DEPS to 97.0.4684.0 * chore: update patches * chore: bump chromium in DEPS to 97.0.4685.0 * chore: update patches * chore: bump chromium in DEPS to 97.0.4686.0 * chore: update patches * chore: bump chromium in DEPS to 97.0.4687.0 * chore: update patches * chore: bump chromium in DEPS to 97.0.4688.0 * chore: update patches * 3247722: Use correct source_site_instance if navigating via context menu Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3247722 Update signature of HandleContextMenu() * 3247722: Use correct source_site_instance if navigating via context menu Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3247722 Update signature of HandleContextMenu() * 3223422: Remove PP_ISOLATEDFILESYSTEMTYPE_PRIVATE_PLUGINPRIVATE enum option Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3223422 sync pepper_plugin_support.patch with upstream * chore: bump chromium in DEPS to 97.0.4689.0 * 3247791: ax_mac_merge: Merge AX Math attribute implementations Xref: ax_mac_merge: Merge AX Math attribute implementations chore: fix minor patch shear in #includes * 3243425: Add VisibleTimeRequestTrigger helper class Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3243425 chore: fix minor patch shear in #includes * chore: regen chromium patches * fixup! 3247722: Use correct source_site_instance if navigating via context menu * chore: bump chromium in DEPS to 97.0.4690.0 * 3188659: Window Placement: make GetScreenInfo(s) const Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3188659 simple sync GetScreenInfo with upstream refactor * chore: update patches * chore: bump chromium in DEPS to 97.0.4690.4 * chore: bump chromium in DEPS to 97.0.4692.0 * 3198073: ozone: //content: clean up from USE_X11 Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3198073 Fixing patch shear. Nothing to see here. * 3252338: Remove label images checkbox from chrome://accessibility page Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3252338 Part of our a11y patch is no longer needed due to upstream label removal * 3258183: Remove DISALLOW_IMPLICIT_CONSTRUCTORS() definition Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3258183 Replace our use of the macro with explicitly-deleted class methods. See https://chromium-review.googlesource.com/c/chromium/src/+/3256952 for upstream examples of this same replacement. * chore: update patches * 3247295: Unwind SecurityStyleExplanations Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3247295 update GetSecurityStyle() signature and impl to match upstream changes * 3259578: media: grabs lock to ensure video output when occluded Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3259578 Add stub for new upstream virtual method OnCapturerCountChanged() * fixup! 3247295: Unwind SecurityStyleExplanations * 3238504: Fix up drag image is not shown from bookmark bar Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3238504 SetDragImage() no longer takes a widget argument * 3217452: [devtools] Add getSyncInformation host binding Xref: https://chromium-review.googlesource.com/c/chromium/src/+/3217452 Add stub for new upstream method GetSyncInformation(). Stub sends info back to caller saying that syncing is disabled. * chore: bump chromium in DEPS to 98.0.4693.0 * chore: bump chromium in DEPS to 98.0.4694.0 * chore: bump chromium in DEPS to 98.0.4695.0 * chore: bump chromium in DEPS to 98.0.4696.0 * chore: bump chromium in DEPS to 98.0.4697.0 * chore: bump chromium in DEPS to 98.0.4699.0 * chore: bump chromium in DEPS to 98.0.4701.0 * chore: bump chromium in DEPS to 98.0.4703.0 * chore: bump chromium in DEPS to 98.0.4705.0 * chore: bump chromium in DEPS to 98.0.4706.0 * chore: update patches * 3279210: Rename "base/macros.h" => "base/ignore_result.h" https://chromium-review.googlesource.com/c/chromium/src/+/3279210 * 3259964: Remove all DISALLOW_COPY_AND_ASSIGNs https://chromium-review.googlesource.com/c/chromium/src/+/3259964 * 3269029: blink/gin: sets histogram callbacks during isolate creation https://chromium-review.googlesource.com/c/chromium/src/+/3269029 * fixup after rebase * [content] Make ContentMainParams and MainFunctionParams move-only https://chromium-review.googlesource.com/c/chromium/src/+/3244976 * 3255305: Stop sending the securityStateChanged event and unwind https://chromium-review.googlesource.com/c/chromium/src/+/3255305 * [Blink] Add promise support to WebLocalFrame::RequestExecuteScript() https://chromium-review.googlesource.com/c/chromium/src/+/3230010 * 3256162: Simplify RWHV Show and ShowWithVisibility handling https://chromium-review.googlesource.com/c/chromium/src/+/3256162 * 3263824: ozone: //ui/base: clean up from USE_X11 1/* https://chromium-review.googlesource.com/c/chromium/src/+/3263824 * Request or cancel RecordContentToPresentationTimeRequest during capture https://chromium-review.googlesource.com/c/chromium/src/+/3256802 * appcache: remove BrowsingData/quota references https://chromium-review.googlesource.com/c/chromium/src/+/3255725 * [Autofill] Don't show Autofill dropdown if overlaps with permissions https://chromium-review.googlesource.com/c/chromium/src/+/3236729 * Rename to_different_document to should_show_loading_ui in LoadingStateChanged() callbacks https://chromium-review.googlesource.com/c/chromium/src/+/3268574 * cleanup patch * fixup [content] Make ContentMainParams and MainFunctionParams move-only * 3279210: Rename "base/macros.h" => "base/ignore_result.h" https://chromium-review.googlesource.com/c/chromium/src/+/3279210 * ozone: //chrome/browser clean up from USE_X11 https://chromium-review.googlesource.com/c/chromium/src/+/3186490 Refs: https://github.com/electron/electron/issues/31382 * chore: update support_mixed_sandbox_with_zygote.patch * Enable -Wunused-but-set-variable. Refs https://chromium-review.googlesource.com/c/chromium/src/+/3234737 * fixup! ozone: //ui/base: clean up from USE_X11 1/* * fixup! ozone: //chrome/browser clean up from USE_X11 * chore: fix deprecation warning in libuv * chore: fixup for lint * 3251161: Reland "Make the Clang update.py script require Python 3" https://chromium-review.googlesource.com/c/chromium/src/+/3251161 * fixup: Enable -Wunused-but-set-variable. * [base][win] Rename DIR_APP_DATA to DIR_ROAMING_APP_DATA https://chromium-review.googlesource.com/c/chromium/src/+/3262369 * Replace sandbox::policy::SandboxType with mojom Sandbox enum https://chromium-review.googlesource.com/c/chromium/src/+/3213677 * fixup: [content] Make ContentMainParams and MainFunctionParams move-only * build: ensure angle has a full git checkout available to it * fixup: [base][win] Rename DIR_APP_DATA to DIR_ROAMING_APP_DATA * fixup lint * [unseasoned-pdf] Dispatch 'afterprint' event in PDF plugin frame https://chromium-review.googlesource.com/c/chromium/src/+/3223434 * fixup: [Autofill] Don't show Autofill dropdown if overlaps with permissions * 3217591: Move browser UI CSS color parsing to own file part 2/2 https://chromium-review.googlesource.com/c/chromium/src/+/3217591 * Make kNoSandboxAndElevatedPrivileges only available to utilities https://chromium-review.googlesource.com/c/chromium/src/+/3276784 * 3211575: [modules] Change ScriptOrModule to custom Struct https://chromium-review.googlesource.com/c/v8/v8/+/3211575 * Address review feedback * chore: update patches * 3211575: [modules] Change ScriptOrModule to custom Struct https://chromium-review.googlesource.com/c/v8/v8/+/3211575 * fix: unused variable compat * chore: remove redundant patch * fixup for 3262517: Re-enable WindowCaptureMacV2 https://chromium-review.googlesource.com/c/chromium/src/+/3262517 * chore: cleanup todo The functions added in https://chromium-review.googlesource.com/c/chromium/src/+/3256802 are not used by offscreen rendering. * fixup: update mas_no_private_api.patch * 3216879: [PA] Make features::kPartitionAllocLazyCommit to be PartitionOptions::LazyCommit Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3216879 Fixes up commit b2f1aca95604ec61649808c846657454097e6935 * chore: cleanup support_mixed_sandbox_with_zygote.patch * test: use window focus event instead of delay to wait for webContents focus Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: VerteDinde <khammond@slack-corp.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: deepak1556 <hop2deep@gmail.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-11-24 08:45:59 +00:00
if (options.Get(options::kMaxHeight, &max_height) ||
options.Get(options::kMaxWidth, &max_width)) {
size_constraints.set_maximum_size(gfx::Size(max_width, max_height));
}
if (use_content_size) {
SetContentSizeConstraints(size_constraints);
} else {
SetSizeConstraints(size_constraints);
2013-04-12 07:04:46 +00:00
}
2020-10-20 18:24:52 +00:00
#if defined(OS_WIN) || defined(OS_LINUX)
bool resizable;
if (options.Get(options::kResizable, &resizable)) {
SetResizable(resizable);
}
bool closable;
if (options.Get(options::kClosable, &closable)) {
SetClosable(closable);
}
#endif
2016-01-23 10:23:18 +00:00
bool movable;
2016-01-23 11:35:30 +00:00
if (options.Get(options::kMovable, &movable)) {
2016-01-23 10:23:18 +00:00
SetMovable(movable);
}
2016-01-23 10:55:12 +00:00
bool has_shadow;
if (options.Get(options::kHasShadow, &has_shadow)) {
SetHasShadow(has_shadow);
}
2017-09-29 02:26:02 +00:00
double opacity;
if (options.Get(options::kOpacity, &opacity)) {
SetOpacity(opacity);
}
2013-04-12 07:04:46 +00:00
bool top;
if (options.Get(options::kAlwaysOnTop, &top) && top) {
SetAlwaysOnTop(ui::ZOrderLevel::kFloatingWindow);
2013-04-12 07:04:46 +00:00
}
bool fullscreenable = true;
bool fullscreen = false;
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) {
// Disable fullscreen button if 'fullscreen' is specified to false.
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)
fullscreenable = false;
2018-04-18 01:55:30 +00:00
#endif
}
// Overridden by 'fullscreenable'.
2016-03-05 12:54:41 +00:00
options.Get(options::kFullScreenable, &fullscreenable);
SetFullScreenable(fullscreenable);
2016-03-05 12:54:41 +00:00
if (fullscreen) {
2014-11-25 06:34:14 +00:00
SetFullScreen(true);
2016-03-05 12:54:41 +00:00
}
bool skip;
if (options.Get(options::kSkipTaskbar, &skip)) {
SetSkipTaskbar(skip);
}
2013-04-12 07:04:46 +00:00
bool kiosk;
if (options.Get(options::kKiosk, &kiosk) && kiosk) {
2013-04-12 07:04:46 +00:00
SetKiosk(kiosk);
}
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)
std::string type;
if (options.Get(options::kVibrancyType, &type)) {
SetVibrancy(type);
}
#endif
2015-10-23 03:35:33 +00:00
std::string color;
if (options.Get(options::kBackgroundColor, &color)) {
SetBackgroundColor(ParseHexColor(color));
} else if (!transparent()) {
// For normal window, use white as default background.
SetBackgroundColor(SK_ColorWHITE);
2015-10-23 03:35:33 +00:00
}
2016-06-08 21:17:33 +00:00
std::string title(Browser::Get()->GetName());
options.Get(options::kTitle, &title);
2013-04-12 07:04:46 +00:00
SetTitle(title);
// Then show it.
bool show = true;
options.Get(options::kShow, &show);
2015-10-01 09:46:11 +00:00
if (show)
2013-04-12 07:04:46 +00:00
Show();
}
bool NativeWindow::IsClosed() const {
return is_closed_;
}
2016-01-15 04:54:12 +00:00
void NativeWindow::SetSize(const gfx::Size& size, bool animate) {
SetBounds(gfx::Rect(GetPosition(), size), animate);
}
gfx::Size NativeWindow::GetSize() {
return GetBounds().size();
}
2016-01-15 04:54:12 +00:00
void NativeWindow::SetPosition(const gfx::Point& position, bool animate) {
SetBounds(gfx::Rect(position, GetSize()), animate);
}
gfx::Point NativeWindow::GetPosition() {
return GetBounds().origin();
}
2016-01-15 04:54:12 +00:00
void NativeWindow::SetContentSize(const gfx::Size& size, bool animate) {
SetSize(ContentBoundsToWindowBounds(gfx::Rect(size)).size(), animate);
}
gfx::Size NativeWindow::GetContentSize() {
return GetContentBounds().size();
2016-08-04 19:02:24 +00:00
}
void NativeWindow::SetContentBounds(const gfx::Rect& bounds, bool animate) {
SetBounds(ContentBoundsToWindowBounds(bounds), animate);
}
gfx::Rect NativeWindow::GetContentBounds() {
return WindowBoundsToContentBounds(GetBounds());
}
bool NativeWindow::IsNormal() {
return !IsMinimized() && !IsMaximized() && !IsFullscreen();
}
void NativeWindow::SetSizeConstraints(
const extensions::SizeConstraints& window_constraints) {
extensions::SizeConstraints content_constraints(GetContentSizeConstraints());
if (window_constraints.HasMaximumSize()) {
gfx::Rect max_bounds = WindowBoundsToContentBounds(
gfx::Rect(window_constraints.GetMaximumSize()));
content_constraints.set_maximum_size(max_bounds.size());
}
if (window_constraints.HasMinimumSize()) {
gfx::Rect min_bounds = WindowBoundsToContentBounds(
gfx::Rect(window_constraints.GetMinimumSize()));
content_constraints.set_minimum_size(min_bounds.size());
}
SetContentSizeConstraints(content_constraints);
}
2017-05-21 18:57:19 +00:00
extensions::SizeConstraints NativeWindow::GetSizeConstraints() const {
extensions::SizeConstraints content_constraints = GetContentSizeConstraints();
extensions::SizeConstraints window_constraints;
if (content_constraints.HasMaximumSize()) {
gfx::Rect max_bounds = ContentBoundsToWindowBounds(
gfx::Rect(content_constraints.GetMaximumSize()));
2016-08-04 19:14:23 +00:00
window_constraints.set_maximum_size(max_bounds.size());
}
if (content_constraints.HasMinimumSize()) {
gfx::Rect min_bounds = ContentBoundsToWindowBounds(
gfx::Rect(content_constraints.GetMinimumSize()));
window_constraints.set_minimum_size(min_bounds.size());
}
return window_constraints;
}
void NativeWindow::SetContentSizeConstraints(
const extensions::SizeConstraints& size_constraints) {
size_constraints_ = size_constraints;
}
2017-05-21 18:57:19 +00:00
extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() const {
return size_constraints_;
}
void NativeWindow::SetMinimumSize(const gfx::Size& size) {
extensions::SizeConstraints size_constraints;
size_constraints.set_minimum_size(size);
SetSizeConstraints(size_constraints);
}
2017-05-21 18:57:19 +00:00
gfx::Size NativeWindow::GetMinimumSize() const {
return GetSizeConstraints().GetMinimumSize();
}
void NativeWindow::SetMaximumSize(const gfx::Size& size) {
extensions::SizeConstraints size_constraints;
size_constraints.set_maximum_size(size);
SetSizeConstraints(size_constraints);
}
2017-05-21 18:57:19 +00:00
gfx::Size NativeWindow::GetMaximumSize() const {
return GetSizeConstraints().GetMaximumSize();
}
gfx::Size NativeWindow::GetContentMinimumSize() const {
return GetContentSizeConstraints().GetMinimumSize();
}
gfx::Size NativeWindow::GetContentMaximumSize() const {
gfx::Size maximum_size = GetContentSizeConstraints().GetMaximumSize();
#if defined(OS_WIN)
return GetContentSizeConstraints().HasMaximumSize()
? GetExpandedWindowSize(this, maximum_size)
: maximum_size;
2018-05-12 20:05:25 +00:00
#else
return maximum_size;
#endif
}
void NativeWindow::SetSheetOffset(const double offsetX, const double offsetY) {
sheet_offset_x_ = offsetX;
sheet_offset_y_ = offsetY;
}
double NativeWindow::GetSheetOffsetX() {
return sheet_offset_x_;
}
double NativeWindow::GetSheetOffsetY() {
return sheet_offset_y_;
}
bool NativeWindow::IsTabletMode() const {
return false;
}
2018-04-18 01:55:30 +00:00
void NativeWindow::SetRepresentedFilename(const std::string& filename) {}
std::string NativeWindow::GetRepresentedFilename() {
return "";
}
2018-04-18 01:55:30 +00:00
void NativeWindow::SetDocumentEdited(bool edited) {}
2014-08-21 13:00:49 +00:00
bool NativeWindow::IsDocumentEdited() {
return false;
}
2018-04-18 01:55:30 +00:00
void NativeWindow::SetFocusable(bool focusable) {}
2016-06-13 08:10:28 +00:00
bool NativeWindow::IsFocusable() {
return false;
}
void NativeWindow::SetMenu(ElectronMenuModel* menu) {}
void NativeWindow::SetParentWindow(NativeWindow* parent) {
parent_ = parent;
}
2018-04-18 01:55:30 +00:00
void NativeWindow::SetAutoHideCursor(bool auto_hide) {}
2018-04-18 01:55:30 +00:00
void NativeWindow::SelectPreviousTab() {}
2018-04-18 01:55:30 +00:00
void NativeWindow::SelectNextTab() {}
2018-04-18 01:55:30 +00:00
void NativeWindow::MergeAllWindows() {}
2018-04-18 01:55:30 +00:00
void NativeWindow::MoveTabToNewWindow() {}
2018-04-18 01:55:30 +00:00
void NativeWindow::ToggleTabBar() {}
bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
return true; // for non-Mac platforms
}
void NativeWindow::SetVibrancy(const std::string& type) {}
void NativeWindow::SetTouchBar(
std::vector<gin_helper::PersistentDictionary> items) {}
2018-04-18 01:55:30 +00:00
void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {}
2017-03-29 19:41:49 +00:00
void NativeWindow::SetEscapeTouchBarItem(
gin_helper::PersistentDictionary item) {}
2018-04-18 01:55:30 +00:00
void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {}
bool NativeWindow::IsMenuBarAutoHide() {
return false;
}
2018-04-18 01:55:30 +00:00
void NativeWindow::SetMenuBarVisibility(bool visible) {}
bool NativeWindow::IsMenuBarVisible() {
return true;
}
double NativeWindow::GetAspectRatio() {
return aspect_ratio_;
}
gfx::Size NativeWindow::GetAspectRatioExtraSize() {
return aspect_ratio_extraSize_;
}
void NativeWindow::SetAspectRatio(double aspect_ratio,
const gfx::Size& extra_size) {
aspect_ratio_ = aspect_ratio;
aspect_ratio_extraSize_ = extra_size;
}
2016-10-14 16:42:50 +00:00
void NativeWindow::PreviewFile(const std::string& path,
2018-04-18 01:55:30 +00:00
const std::string& display_name) {}
2016-10-12 01:08:01 +00:00
2018-04-18 01:55:30 +00:00
void NativeWindow::CloseFilePreview() {}
2016-11-21 18:30:13 +00:00
gfx::Rect NativeWindow::GetWindowControlsOverlayRect() {
return overlay_rect_;
}
void NativeWindow::SetWindowControlsOverlayRect(const gfx::Rect& overlay_rect) {
overlay_rect_ = overlay_rect;
}
void NativeWindow::NotifyWindowRequestPreferredWith(int* width) {
for (NativeWindowObserver& observer : observers_)
observer.RequestPreferredWidth(width);
}
void NativeWindow::NotifyWindowCloseButtonClicked() {
// First ask the observers whether we want to close.
bool prevent_default = false;
for (NativeWindowObserver& observer : observers_)
observer.WillCloseWindow(&prevent_default);
if (prevent_default) {
WindowList::WindowCloseCancelled(this);
return;
}
// Then ask the observers how should we close the window.
for (NativeWindowObserver& observer : observers_)
observer.OnCloseButtonClicked(&prevent_default);
if (prevent_default)
return;
CloseImmediately();
}
void NativeWindow::NotifyWindowClosed() {
if (is_closed_)
return;
is_closed_ = true;
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowClosed();
WindowList::RemoveWindow(this);
}
2017-04-21 20:45:30 +00:00
void NativeWindow::NotifyWindowEndSession() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowEndSession();
}
void NativeWindow::NotifyWindowBlur() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowBlur();
}
void NativeWindow::NotifyWindowFocus() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowFocus();
}
2020-06-29 20:15:28 +00:00
void NativeWindow::NotifyWindowIsKeyChanged(bool is_key) {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowIsKeyChanged(is_key);
}
void NativeWindow::NotifyWindowShow() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowShow();
}
void NativeWindow::NotifyWindowHide() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowHide();
}
2014-11-25 04:43:25 +00:00
void NativeWindow::NotifyWindowMaximize() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowMaximize();
2014-11-25 04:43:25 +00:00
}
void NativeWindow::NotifyWindowUnmaximize() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowUnmaximize();
2014-11-25 04:43:25 +00:00
}
void NativeWindow::NotifyWindowMinimize() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowMinimize();
2014-11-25 04:43:25 +00:00
}
void NativeWindow::NotifyWindowRestore() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowRestore();
2014-11-25 04:43:25 +00:00
}
void NativeWindow::NotifyWindowWillResize(const gfx::Rect& new_bounds,
const gfx::ResizeEdge& edge,
bool* prevent_default) {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowWillResize(new_bounds, edge, prevent_default);
}
void NativeWindow::NotifyWindowWillMove(const gfx::Rect& new_bounds,
bool* prevent_default) {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowWillMove(new_bounds, prevent_default);
}
2015-05-09 15:55:10 +00:00
void NativeWindow::NotifyWindowResize() {
NotifyLayoutWindowControlsOverlay();
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowResize();
2015-05-09 15:55:10 +00:00
}
void NativeWindow::NotifyWindowResized() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowResized();
}
2015-05-09 15:55:10 +00:00
void NativeWindow::NotifyWindowMove() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowMove();
2015-05-09 15:55:10 +00:00
}
2015-05-20 08:37:13 +00:00
void NativeWindow::NotifyWindowMoved() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowMoved();
2015-05-20 08:37:13 +00:00
}
2014-11-25 04:43:25 +00:00
void NativeWindow::NotifyWindowEnterFullScreen() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowEnterFullScreen();
2014-11-25 04:43:25 +00:00
}
2016-01-22 00:31:09 +00:00
void NativeWindow::NotifyWindowScrollTouchBegin() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowScrollTouchBegin();
}
2016-01-22 00:31:09 +00:00
void NativeWindow::NotifyWindowScrollTouchEnd() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowScrollTouchEnd();
}
void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowSwipe(direction);
}
void NativeWindow::NotifyWindowRotateGesture(float rotation) {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowRotateGesture(rotation);
}
void NativeWindow::NotifyWindowSheetBegin() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowSheetBegin();
}
void NativeWindow::NotifyWindowSheetEnd() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowSheetEnd();
}
2014-11-25 04:43:25 +00:00
void NativeWindow::NotifyWindowLeaveFullScreen() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowLeaveFullScreen();
2014-11-25 04:43:25 +00:00
}
void NativeWindow::NotifyWindowEnterHtmlFullScreen() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowEnterHtmlFullScreen();
}
void NativeWindow::NotifyWindowLeaveHtmlFullScreen() {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowLeaveHtmlFullScreen();
}
void NativeWindow::NotifyWindowAlwaysOnTopChanged() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowAlwaysOnTopChanged();
}
void NativeWindow::NotifyWindowExecuteAppCommand(const std::string& command) {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnExecuteAppCommand(command);
}
void NativeWindow::NotifyTouchBarItemInteraction(
const std::string& item_id,
const base::DictionaryValue& details) {
2017-02-27 17:20:25 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnTouchBarItemResult(item_id, details);
2017-02-27 17:20:25 +00:00
}
void NativeWindow::NotifyNewWindowForTab() {
2018-04-18 01:55:30 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnNewWindowForTab();
}
void NativeWindow::NotifyWindowSystemContextMenu(int x,
int y,
bool* prevent_default) {
for (NativeWindowObserver& observer : observers_)
observer.OnSystemContextMenu(x, y, prevent_default);
}
void NativeWindow::NotifyLayoutWindowControlsOverlay() {
gfx::Rect bounding_rect = GetWindowControlsOverlayRect();
if (!bounding_rect.IsEmpty()) {
for (NativeWindowObserver& observer : observers_)
observer.UpdateWindowControlsOverlay(bounding_rect);
}
}
2015-10-27 01:12:01 +00:00
#if defined(OS_WIN)
2018-04-18 01:55:30 +00:00
void NativeWindow::NotifyWindowMessage(UINT message,
WPARAM w_param,
LPARAM l_param) {
2017-01-24 03:34:39 +00:00
for (NativeWindowObserver& observer : observers_)
observer.OnWindowMessage(message, w_param, l_param);
2015-10-27 01:12:01 +00:00
}
#endif
views::Widget* NativeWindow::GetWidget() {
return widget();
}
const views::Widget* NativeWindow::GetWidget() const {
return widget();
}
std::u16string NativeWindow::GetAccessibleWindowTitle() const {
if (accessible_title_.empty()) {
return views::WidgetDelegate::GetAccessibleWindowTitle();
}
return accessible_title_;
}
void NativeWindow::SetAccessibleTitle(const std::string& title) {
accessible_title_ = base::UTF8ToUTF16(title);
}
std::string NativeWindow::GetAccessibleTitle() {
return base::UTF16ToUTF8(accessible_title_);
}
// static
int32_t NativeWindow::next_id_ = 0;
// static
void NativeWindowRelay::CreateForWebContents(
content::WebContents* web_contents,
base::WeakPtr<NativeWindow> window) {
DCHECK(web_contents);
if (!web_contents->GetUserData(UserDataKey())) {
web_contents->SetUserData(UserDataKey(),
base::WrapUnique(new NativeWindowRelay(window)));
}
}
NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)
: native_window_(window) {}
NativeWindowRelay::~NativeWindowRelay() = default;
chore: bump chromium to 96.0.4664.4 (main) (#31317) * chore: bump chromium in DEPS to 96.0.4662.0 * chore: bump chromium in DEPS to 96.0.4663.0 * chore: update patches * [Extensions] Remove RuntimeData entirely https://chromium-review.googlesource.com/c/chromium/src/+/3177328 * Make helper macros behave consistently for //content/public UserData types https://chromium-review.googlesource.com/c/chromium/src/+/3198788 * Enabling sandboxing for the speech recognition service browser tests https://chromium-review.googlesource.com/c/chromium/src/+/3146090 * [devtools] Add 'RegisterPreference' host binding https://chromium-review.googlesource.com/c/chromium/src/+/3162281 * [Reland][Extensions]: Add persistAcrossSessions flag (scripting API) https://chromium-review.googlesource.com/c/chromium/src/+/3175161 * [Bluetooth] Add Passkey prompt dialog for bonding. https://chromium-review.googlesource.com/c/chromium/src/+/2841104 * Clipboard: Remove ReadImage path in browser https://chromium-review.googlesource.com/c/chromium/src/+/3194826 * Split printing metafile code into its own target. https://chromium-review.googlesource.com/c/chromium/src/+/3164925 * Cleanup unused DesktopMediaListObserver params https://chromium-review.googlesource.com/c/chromium/src/+/3179203 * Remove base::DictionaryValue::GetBinary https://chromium-review.googlesource.com/c/chromium/src/+/3201974 * Window Placement: change RWHV::GetDisplayList to GetScreenInfos https://chromium-review.googlesource.com/c/chromium/src/+/3138774 * Add a preview to the Tab Capture picker dialog https://chromium-review.googlesource.com/c/chromium/src/+/3045268 * Add service-based usage to update print settings https://chromium-review.googlesource.com/c/chromium/src/+/3155426 * chore: bump chromium in DEPS to 96.0.4664.2 * chore: update patches * chore: bump chromium in DEPS to 96.0.4664.4 * chore: update patches * chore: bump chromium in DEPS to 97.0.4666.0 * Revert "chore: bump chromium in DEPS to 97.0.4666.0" This reverts commit d73caae8ba4b39efc9b3ea4de52685b9c92ef3d0. * Reland "Block external protocol handler with sandbox." https://chromium-review.googlesource.com/c/chromium/src/+/3198263 * fixup for lint * Add CookiePartitionKeychain parameter to CookeManager.GetCookieList. https://chromium-review.googlesource.com/c/chromium/src/+/3206016 * Move ui/gfx/transform*,rrect*,mask_filter_info* into ui/gfx/geometry https://chromium-review.googlesource.com/c/chromium/src/+/3200392 * fixup Move ui/gfx/transform*,rrect*,mask_filter_info* into ui/gfx/geometry * ozone: //chrome/browser clean up from USE_X11 https://chromium-review.googlesource.com/c/chromium/src/+/3186490 * content: don't load v8 snapshot in browser process https://chromium-review.googlesource.com/c/chromium/src/+/3183394 * [devtools] Add 'RegisterPreference' host binding https://chromium-review.googlesource.com/c/chromium/src/+/3162281 * 3186491: Add 'devtools.sync_preferences' preference https://chromium-review.googlesource.com/c/chromium/src/+/3186491 * 2951147: DCHECK accessible names for focusable Views https://chromium-review.googlesource.com/c/chromium/src/+/2951147 * 3201014: Use real font size for calculation of SmallTextRatio https://chromium-review.googlesource.com/c/chromium/src/+/3201014 * fixup Clipboard: Remove ReadImage path in browser * chore: update patches * fix: disable PlzServiceWorker to fix custom protocol SW script loading Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3199761 Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2021-10-21 18:51:36 +00:00
WEB_CONTENTS_USER_DATA_KEY_IMPL(NativeWindowRelay);
} // namespace electron