chore: bump chromium to 137.0.7128.1 (main) (#46482)

* chore: bump chromium in DEPS to 137.0.7107.0

* chore: bump chromium in DEPS to 137.0.7109.0

* chore: bump chromium in DEPS to 137.0.7111.0

* chore: bump chromium in DEPS to 137.0.7113.0

* 6384240: Remove double-declaration for accessibility on macOS | 6384240

* 6422872: Remove unused includes in isolation_info_mojom_traits.h | 6422872

* chore: update patches

* 6400733: Avoid ipc_message_macros.h usage in some foo_param_traits_macros.h files | 6400733

* chore: update patches

* 6423410: Enable unsafe buffer warnings for chromium, try #3. | 6423410

* chore: iwyu

* refactor: prefer value initialization over memset()

From the looks up upstream commits in base/, it looks like memset()
could trigger `-Wunsafe-buffer-usage` warnings soon?

Value initialization is more C++ish and less error-prone anyway,
due to memset()'s easily swappable parameters.

* refactor: NotifyIcon::InitIconData() returns a NOTIFYICONDATA

This follows F.20 in the C++ Core Guidelines and also removes the need
for memset()

* 6423410: Enable unsafe buffer warnings for chromium, try #3. | 6423410

remove all uses of:

- strcmp()

* fixup!  6423410: Enable unsafe buffer warnings for chromium, try #3. | 6423410

* 6433203: Add a PassKey to RegisterDeleteDelegateCallback(). | 6433203

* chore: bump chromium in DEPS to 137.0.7115.0

* 6387077: [PermissionOptions] Generalize PermissionRequestDescription | 6387077

* chore: update patches

* 6387077: [PermissionOptions] Generalize PermissionRequestDescription | 6387077

* fix: add pragma for MacSDK unsafe buffers | 6423410: Enable unsafe buffer warnings for chromium, try #3. | 6423410

* chore: bump chromium in DEPS to 137.0.7117.0

* chore: update patches

* chore: update filesnames.libcxx.gni

* 6431756: Replace SetOwnedByWidget() bool arg with a PassKey. | 6431756

* 6387077: [PermissionOptions] Generalize PermissionRequestDescription | 6387077

* 6428345: Remove ExtensionService usage from ChromeExtensionRegistrarDelegate | 6428345

* 6384315: Migrate extensions_enabled from ExtensionService to Registrar | 6384315

* 6428749: [extensions] Refactor ExtensionService for AddNewAndUpdateExtension. | 6428749

* chore: bump chromium in DEPS to 137.0.7119.0

* 6440290: corner-shape: support inset shadow | 6440290

* 6429230: FSA: Move blocked paths to the PermissionContext class | 6429230

* chore: update patches

* chore: bump chromium in DEPS to 137.0.7121.0

* chore: update patches

* fix: partially revert 6443473: Remove ItemDelete from the Mac version of AppleKeychain | 6443473

* fix: update filenames.libcxx.gni

* chore: bump chromium in DEPS to 137.0.7123.0

* chore: update patches

* chore: "grandfather in" electron views too

Lock further access to View::set_owned_by_client() | 6448510

* chore: update feat_corner_smoothing_css_rule_and_blink_painting.patch

corner-shape: support inset shadow | 6440290

* refactor: grandfather in AutofillPopupView as a subclass of WidgetDelegateView

Add a PassKey for std::make_unique<WidgetDelegateView>() | 6442265

* Provide dbus appmenu information on Wayland | 6405535

* [extensions] Move OnExtensionInstalled out of ExtensionService. | 6443325

* refactor: grandfather in NativeWindowViews for delete callbacks

6433203: Add a PassKey to RegisterDeleteDelegateCallback(). | 6433203

* chore: merge the four "grandfather" patches into one

* [A11yPerformance] Remove IsAccessibilityAllowed() | 6404386: [A11yPerformance] Remove IsAccessibilityAllowed() | 6404386

NB: the changes here are copied from the upstream changes in
chrome/browser/ui/webui/accessibility/accessibility_ui.cc

* 6420753: [PermissionOptions] Use PermissionDescriptorPtr in PermissionController | 6420753

* 6429573: [accessibility] Move mode change out of AccessibilityNotificationWaiter | 6429573

* chore: e patches all

* 6419936: [win] Change ScreenWin public static methods to virtual | 6419936

* 6423410: Enable unsafe buffer warnings for chromium, try #3. | 6423410

remove all uses of:

- fprintf()
- fputs()
- snprintf()
- vsnprintf()

* fix: size conversion FTBFS on Win

* 6423410: Enable unsafe buffer warnings for chromium, try #3. | 6423410

remove all uses of:

- wcscpy_s()

* 6423410: Enable unsafe buffer warnings for chromium, try #3. | 6423410

remove all uses of:

- wcsncpy_s()

* chore: update mas_avoid_private_macos_api_usage.patch.patch

6394283: Remove double-declaration for accessibility on iOS | 6394283

Lots of context shear in this commit but the only interesting part is:

-+  return nullptr;
++  return {};

Which is needed because the return type is sometimes not a pointer.

* chore: e patches all

* chore: disable -Wmacro-redefined warning in electron_main_win.cc

* chore: bump chromium in DEPS to 137.0.7123.5

* refactor: patch electron PermissionTypes into blink

6387077: [PermissionOptions] Generalize PermissionRequestDescription | 6387077

* chore: e patches all

* chore: remove the box_painter_base.cc part of feat_corner_smoothing_css_rule_and_blink_painting.patch

as per code review @ https://github.com/electron/electron/pull/46482#pullrequestreview-2777338370

* test: enable window-smaller-than-64x64 test on Linux

* chore: bump chromium in DEPS to 137.0.7124.1

* chore: bump chromium in DEPS to 137.0.7125.1

* chore: bump chromium in DEPS to 137.0.7127.3

* 6459201: [Extensions] Remove ExtensionSystem::FinishDelayedInstallationIfReady() | 6459201

* 6454796: [Extensions] Move (most) registrar delayed install logic to //extensions | 6454796

* chore: bump chromium in DEPS to 137.0.7128.1

* chore: e patches all

* chore: node ./script/gen-libc++-filenames.js

* [views] Gate DesktopWindowTreeHostWin::window_enlargement_ behind flag

Refs 6428649

* feat: allow opt-out animated_content_sampler.

Refs 6438681

* Trigger CI

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
electron-roller[bot] 2025-04-22 15:53:29 -04:00 committed by GitHub
parent d0e13cc262
commit dd03cceda0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
145 changed files with 1414 additions and 1780 deletions

View file

@ -3,7 +3,9 @@
// found in the LICENSE file.
#include <cstdlib>
#include <iostream>
#include <memory>
#include <string>
#include "base/strings/cstring_view.h"
#include "electron/fuses.h"
@ -35,15 +37,11 @@ namespace {
}
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
[[noreturn]] void FatalError(const char* format, ...) {
va_list valist;
va_start(valist, format);
char message[4096];
if (vsnprintf(message, sizeof(message), format, valist) >= 0) {
fputs(message, stderr);
abort_report_np("%s", message);
[[noreturn]] void FatalError(const std::string errmsg) {
if (!errmsg.empty()) {
std::cerr << errmsg;
abort_report_np("%s", errmsg.c_str());
}
va_end(valist);
abort();
}
#endif

View file

@ -15,6 +15,11 @@
#include <string>
#include <utility>
// workaround for base/strings/strcat.h(18,9): error: 'StrCat' macro redefined
// [-Werror,-Wmacro-redefined]
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmacro-redefined"
#include "base/at_exit.h"
#include "base/debug/alias.h"
#include "base/i18n/icu_util.h"
@ -38,6 +43,8 @@
#include "shell/common/electron_constants.h"
#include "third_party/crashpad/crashpad/util/win/initial_client_data.h"
#pragma clang diagnostic pop
namespace {
// Redefined here so we don't have to introduce a dependency on //content

View file

@ -4,6 +4,7 @@
#include "shell/app/node_main.h"
#include <iostream>
#include <map>
#include <memory>
#include <string>
@ -190,7 +191,7 @@ int NodeMain() {
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform});
for (const std::string& error : result->errors())
fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str());
std::cerr << args[0] << ": " << error << '\n';
if (result->early_return() != 0) {
return result->exit_code();

View file

@ -1167,11 +1167,13 @@ void App::SetAccessibilitySupportEnabled(gin_helper::ErrorThrower thrower,
return;
}
// TODO(wg-upgrades): crbug.com/1470199 remove use of deprecated
// AddAccessibilityModeFlags() and RemoveAccessibilityModeFlags()
auto* ax_state = content::BrowserAccessibilityState::GetInstance();
if (enabled) {
ax_state->EnableProcessAccessibility();
ax_state->AddAccessibilityModeFlags(ui::kAXModeComplete);
} else {
ax_state->DisableProcessAccessibility();
ax_state->RemoveAccessibilityModeFlags(ui::kAXModeComplete);
}
Browser::Get()->OnAccessibilitySupportChanged();
}

View file

@ -20,6 +20,7 @@
#include "electron/mas.h"
#include "net/base/completion_once_callback.h"
#include "net/base/completion_repeating_callback.h"
#include "net/base/features.h"
#include "net/ssl/client_cert_identity.h"
#include "shell/browser/browser.h"
#include "shell/browser/browser_observer.h"

View file

@ -93,13 +93,21 @@ gfx::Point Screen::GetCursorScreenPoint(v8::Isolate* isolate) {
static gfx::Rect ScreenToDIPRect(electron::NativeWindow* window,
const gfx::Rect& rect) {
HWND hwnd = window ? window->GetAcceleratedWidget() : nullptr;
return display::win::ScreenWin::ScreenToDIPRect(hwnd, rect);
return display::win::GetScreenWin()->ScreenToDIPRect(hwnd, rect);
}
static gfx::Rect DIPToScreenRect(electron::NativeWindow* window,
const gfx::Rect& rect) {
HWND hwnd = window ? window->GetAcceleratedWidget() : nullptr;
return display::win::ScreenWin::DIPToScreenRect(hwnd, rect);
return display::win::GetScreenWin()->DIPToScreenRect(hwnd, rect);
}
static gfx::PointF ScreenToDIPPoint(const gfx::PointF& pixel_point) {
return display::win::GetScreenWin()->ScreenToDIPPoint(pixel_point);
}
static gfx::Point DIPToScreenPoint(const gfx::Point& dip_point) {
return display::win::GetScreenWin()->DIPToScreenPoint(dip_point);
}
#endif
@ -154,8 +162,8 @@ gin::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder(
.SetMethod("getAllDisplays", &Screen::GetAllDisplays)
.SetMethod("getDisplayNearestPoint", &Screen::GetDisplayNearestPoint)
#if BUILDFLAG(IS_WIN)
.SetMethod("screenToDipPoint", &display::win::ScreenWin::ScreenToDIPPoint)
.SetMethod("dipToScreenPoint", &display::win::ScreenWin::DIPToScreenPoint)
.SetMethod("screenToDipPoint", &ScreenToDIPPoint)
.SetMethod("dipToScreenPoint", &DIPToScreenPoint)
.SetMethod("screenToDipRect", &ScreenToDIPRect)
.SetMethod("dipToScreenRect", &DIPToScreenRect)
#endif

View file

@ -170,7 +170,7 @@ class JSLayoutManager : public views::LayoutManagerBase {
};
View::View(views::View* view) : view_(view) {
view_->set_owned_by_client();
view_->set_owned_by_client(views::View::OwnedByClientPassKey{});
view_->AddObserver(this);
}

View file

@ -14,7 +14,7 @@
namespace electron::api {
ImageView::ImageView() : View(new views::ImageView()) {
view()->set_owned_by_client();
view()->set_owned_by_client(views::View::OwnedByClientPassKey{});
}
ImageView::~ImageView() = default;

View file

@ -252,12 +252,8 @@ std::string MakePartitionName(const std::string& input) {
bool DoesDeviceMatch(const base::Value& device,
const base::Value& device_to_compare,
const blink::PermissionType permission_type) {
if (permission_type ==
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::HID) ||
permission_type ==
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::USB)) {
if (permission_type == blink::PermissionType::HID ||
permission_type == blink::PermissionType::USB) {
if (device.GetDict().FindInt(kDeviceVendorIdKey) !=
device_to_compare.GetDict().FindInt(kDeviceVendorIdKey) ||
device.GetDict().FindInt(kDeviceProductIdKey) !=
@ -273,9 +269,7 @@ bool DoesDeviceMatch(const base::Value& device,
if (serial_number && device_serial_number &&
*device_serial_number == *serial_number)
return true;
} else if (permission_type ==
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::SERIAL)) {
} else if (permission_type == blink::PermissionType::SERIAL) {
#if BUILDFLAG(IS_WIN)
const auto* instance_id = device.GetDict().FindString(kDeviceInstanceIdKey);
const auto* port_instance_id =

View file

@ -53,8 +53,7 @@ int g_shutdown_pipe_read_fd = -1;
// Common code between SIG{HUP, INT, TERM}Handler.
void GracefulShutdownHandler(int signal) {
// Reinstall the default handler. We had one shot at graceful shutdown.
struct sigaction action;
memset(&action, 0, sizeof(action));
struct sigaction action = {};
action.sa_handler = SIG_DFL;
RAW_CHECK(sigaction(signal, &action, nullptr) == 0);
@ -174,8 +173,7 @@ void ShutdownDetector::ThreadMain() {
void ElectronBrowserMainParts::HandleSIGCHLD() {
// We need to accept SIGCHLD, even though our handler is a no-op because
// otherwise we cannot wait on children. (According to POSIX 2001.)
struct sigaction action;
memset(&action, 0, sizeof(action));
struct sigaction action = {};
action.sa_handler = SIGCHLDHandler;
CHECK_EQ(sigaction(SIGCHLD, &action, nullptr), 0);
}
@ -217,8 +215,7 @@ void ElectronBrowserMainParts::InstallShutdownSignalHandlers(
// We need to handle SIGTERM, because that is how many POSIX-based distros
// ask processes to quit gracefully at shutdown time.
struct sigaction action;
memset(&action, 0, sizeof(action));
struct sigaction action = {};
action.sa_handler = SIGTERMHandler;
CHECK_EQ(sigaction(SIGTERM, &action, nullptr), 0);

View file

@ -8,6 +8,7 @@
#include <utility>
#include <vector>
#include "base/containers/to_vector.h"
#include "base/values.h"
#include "content/browser/permissions/permission_util.h" // nogncheck
#include "content/public/browser/child_process_security_policy.h"
@ -54,20 +55,21 @@ void PermissionRequestResponseCallbackWrapper(
class ElectronPermissionManager::PendingRequest {
public:
PendingRequest(content::RenderFrameHost* render_frame_host,
const std::vector<blink::PermissionType>& permissions,
std::vector<blink::mojom::PermissionDescriptorPtr> permissions,
StatusesCallback callback)
: render_frame_host_id_(render_frame_host->GetGlobalId()),
callback_(std::move(callback)),
permissions_(permissions),
results_(permissions.size(), blink::mojom::PermissionStatus::DENIED),
remaining_results_(permissions.size()) {}
permissions_(std::move(permissions)),
results_(permissions_.size(), blink::mojom::PermissionStatus::DENIED),
remaining_results_(permissions_.size()) {}
void SetPermissionStatus(int permission_id,
blink::mojom::PermissionStatus status) {
DCHECK(!IsComplete());
if (status == blink::mojom::PermissionStatus::GRANTED) {
const auto permission = permissions_[permission_id];
const auto permission = blink::PermissionDescriptorToPermissionType(
permissions_[permission_id]);
if (permission == blink::PermissionType::MIDI_SYSEX) {
content::ChildProcessSecurityPolicy::GetInstance()
->GrantSendMidiSysExMessage(render_frame_host_id_.child_id);
@ -97,7 +99,7 @@ class ElectronPermissionManager::PendingRequest {
private:
content::GlobalRenderFrameHostId render_frame_host_id_;
StatusesCallback callback_;
std::vector<blink::PermissionType> permissions_;
std::vector<blink::mojom::PermissionDescriptorPtr> permissions_;
std::vector<blink::mojom::PermissionStatus> results_;
size_t remaining_results_;
};
@ -141,7 +143,7 @@ void ElectronPermissionManager::SetBluetoothPairingHandler(
}
void ElectronPermissionManager::RequestPermissionWithDetails(
blink::PermissionType permission,
blink::mojom::PermissionDescriptorPtr permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
@ -154,7 +156,7 @@ void ElectronPermissionManager::RequestPermissionWithDetails(
RequestPermissionsWithDetails(
render_frame_host,
content::PermissionRequestDescription(permission, user_gesture,
content::PermissionRequestDescription(std::move(permission), user_gesture,
requesting_origin),
std::move(details),
base::BindOnce(PermissionRequestResponseCallbackWrapper,
@ -181,20 +183,26 @@ void ElectronPermissionManager::RequestPermissionsWithDetails(
const content::PermissionRequestDescription& request_description,
base::Value::Dict details,
StatusesCallback response_callback) {
auto& permissions = request_description.permissions;
if (permissions.empty()) {
if (request_description.permissions.empty()) {
std::move(response_callback).Run({});
return;
}
auto permissions = base::ToVector(request_description.permissions,
[](const auto& permission_descriptor) {
return permission_descriptor.Clone();
});
if (request_handler_.is_null()) {
std::vector<blink::mojom::PermissionStatus> statuses;
for (auto& permission : permissions) {
if (permission == blink::PermissionType::MIDI_SYSEX) {
for (const auto& permission : permissions) {
const auto permission_type =
blink::PermissionDescriptorToPermissionType(permission);
if (permission_type == blink::PermissionType::MIDI_SYSEX) {
content::ChildProcessSecurityPolicy::GetInstance()
->GrantSendMidiSysExMessage(
render_frame_host->GetProcess()->GetDeprecatedID());
} else if (permission == blink::PermissionType::GEOLOCATION) {
} else if (permission_type == blink::PermissionType::GEOLOCATION) {
ElectronBrowserMainParts::Get()
->GetGeolocationControl()
->UserDidOptIntoLocationServices();
@ -208,14 +216,15 @@ void ElectronPermissionManager::RequestPermissionsWithDetails(
auto* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host);
int request_id = pending_requests_.Add(std::make_unique<PendingRequest>(
render_frame_host, permissions, std::move(response_callback)));
render_frame_host, std::move(permissions), std::move(response_callback)));
details.Set("requestingUrl", render_frame_host->GetLastCommittedURL().spec());
details.Set("isMainFrame", render_frame_host->GetParent() == nullptr);
base::Value dict_value(std::move(details));
for (size_t i = 0; i < permissions.size(); ++i) {
auto permission = permissions[i];
for (size_t i = 0; i < request_description.permissions.size(); ++i) {
const auto permission = blink::PermissionDescriptorToPermissionType(
request_description.permissions[i]);
const auto callback =
base::BindRepeating(&ElectronPermissionManager::OnPermissionResponse,
base::Unretained(this), request_id, i);

View file

@ -67,12 +67,13 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
using BluetoothPairingHandler =
base::RepeatingCallback<void(gin_helper::Dictionary, PairCallback)>;
void RequestPermissionWithDetails(blink::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
base::Value::Dict details,
StatusCallback response_callback);
void RequestPermissionWithDetails(
blink::mojom::PermissionDescriptorPtr permission,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
base::Value::Dict details,
StatusCallback response_callback);
// Handler to dispatch permission requests in JS.
void SetPermissionRequestHandler(const RequestHandler& handler);

View file

@ -8,6 +8,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/permission_descriptor_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
@ -82,9 +83,13 @@ void ElectronWebContentsUtilityHandlerImpl::CanAccessClipboardDeprecated(
std::move(callback).Run(blink::mojom::PermissionStatus::DENIED);
return;
}
// TODO(wg-upgrades) https://crbug.com/406755622 remove use of deprecated
// CreatePermissionDescriptorForPermissionType()
blink::mojom::PermissionStatus status =
permission_controller->GetPermissionStatusForCurrentDocument(
permission, render_frame_host);
content::PermissionDescriptorUtil::
CreatePermissionDescriptorForPermissionType(permission),
render_frame_host);
std::move(callback).Run(status);
} else {
std::move(callback).Run(blink::mojom::PermissionStatus::DENIED);

View file

@ -5,6 +5,7 @@
#include "shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h"
#include <string>
#include <string_view>
#include "components/update_client/update_query_params.h"
#include "extensions/common/api/runtime.h"
@ -45,38 +46,39 @@ void ElectronRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {
}
bool ElectronRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
const char* os = update_client::UpdateQueryParams::GetOS();
if (strcmp(os, "mac") == 0) {
if (const std::string_view os = update_client::UpdateQueryParams::GetOS();
os == "mac") {
info->os = extensions::api::runtime::PlatformOs::kMac;
} else if (strcmp(os, "win") == 0) {
} else if (os == "win") {
info->os = extensions::api::runtime::PlatformOs::kWin;
} else if (strcmp(os, "linux") == 0) {
} else if (os == "linux") {
info->os = extensions::api::runtime::PlatformOs::kLinux;
} else if (strcmp(os, "openbsd") == 0) {
} else if (os == "openbsd") {
info->os = extensions::api::runtime::PlatformOs::kOpenbsd;
} else {
NOTREACHED();
}
const char* arch = update_client::UpdateQueryParams::GetArch();
if (strcmp(arch, "arm") == 0) {
if (const std::string_view arch = update_client::UpdateQueryParams::GetArch();
arch == "arm") {
info->arch = extensions::api::runtime::PlatformArch::kArm;
} else if (strcmp(arch, "arm64") == 0) {
} else if (arch == "arm64") {
info->arch = extensions::api::runtime::PlatformArch::kArm64;
} else if (strcmp(arch, "x86") == 0) {
} else if (arch == "x86") {
info->arch = extensions::api::runtime::PlatformArch::kX86_32;
} else if (strcmp(arch, "x64") == 0) {
} else if (arch == "x64") {
info->arch = extensions::api::runtime::PlatformArch::kX86_64;
} else {
NOTREACHED();
}
const char* nacl_arch = update_client::UpdateQueryParams::GetNaclArch();
if (strcmp(nacl_arch, "arm") == 0) {
if (const std::string_view nacl_arch =
update_client::UpdateQueryParams::GetNaclArch();
nacl_arch == "arm") {
info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kArm;
} else if (strcmp(nacl_arch, "x86-32") == 0) {
} else if (nacl_arch == "x86-32") {
info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kX86_32;
} else if (strcmp(nacl_arch, "x86-64") == 0) {
} else if (nacl_arch == "x86-64") {
info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kX86_64;
} else {
NOTREACHED();

View file

@ -7,6 +7,7 @@
#include <utility>
#include "base/auto_reset.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
@ -98,7 +99,7 @@ ElectronExtensionLoader::ElectronExtensionLoader(
: browser_context_(browser_context),
extension_registrar_(ExtensionRegistrar::Get(browser_context)) {
extension_registrar_->Init(
this, /*extensions_enabled=*/true,
this, /*extensions_enabled=*/true, base::CommandLine::ForCurrentProcess(),
browser_context_->GetPath().AppendASCII(kInstallDirectoryName),
browser_context_->GetPath().AppendASCII(kUnpackedInstallDirectoryName));
}
@ -200,9 +201,6 @@ void ElectronExtensionLoader::PostUninstallExtension(
scoped_refptr<const Extension> extension,
base::OnceClosure done_callback) {}
void ElectronExtensionLoader::PostNotifyUninstallExtension(
scoped_refptr<const Extension> extension) {}
void ElectronExtensionLoader::LoadExtensionForReload(
const ExtensionId& extension_id,
const base::FilePath& path,
@ -224,12 +222,6 @@ void ElectronExtensionLoader::ShowExtensionDisabledError(
const Extension* extension,
bool is_remote_install) {}
void ElectronExtensionLoader::FinishDelayedInstallationsIfAny() {}
bool ElectronExtensionLoader::CanAddExtension(const Extension* extension) {
return true;
}
bool ElectronExtensionLoader::CanEnableExtension(const Extension* extension) {
return true;
}
@ -239,10 +231,6 @@ bool ElectronExtensionLoader::CanDisableExtension(const Extension* extension) {
return false;
}
bool ElectronExtensionLoader::ShouldBlockExtension(const Extension* extension) {
return false;
}
void ElectronExtensionLoader::GrantActivePermissions(
const Extension* extension) {
NOTIMPLEMENTED();

View file

@ -36,6 +36,13 @@ class ElectronExtensionLoader : public ExtensionRegistrar::Delegate {
ElectronExtensionLoader(const ElectronExtensionLoader&) = delete;
ElectronExtensionLoader& operator=(const ElectronExtensionLoader&) = delete;
void OnAddNewOrUpdatedExtension(const Extension* extension) override {}
void UpdateExternalExtensionAlert() override {}
void OnExtensionInstalled(const Extension* extension,
const syncer::StringOrdinal& page_ordinal,
int install_flags,
base::Value::Dict ruleset_install_prefs) override {}
// Loads an unpacked extension from a directory synchronously. Returns the
// extension on success, or nullptr otherwise.
void LoadExtension(const base::FilePath& extension_dir,
@ -75,19 +82,14 @@ class ElectronExtensionLoader : public ExtensionRegistrar::Delegate {
void PreUninstallExtension(scoped_refptr<const Extension> extension) override;
void PostUninstallExtension(scoped_refptr<const Extension> extension,
base::OnceClosure done_callback) override;
void PostNotifyUninstallExtension(
scoped_refptr<const Extension> extension) override;
void LoadExtensionForReload(
const ExtensionId& extension_id,
const base::FilePath& path,
ExtensionRegistrar::LoadErrorBehavior load_error_behavior) override;
void ShowExtensionDisabledError(const Extension* extension,
bool is_remote_install) override;
void FinishDelayedInstallationsIfAny() override;
bool CanAddExtension(const Extension* extension) override;
bool CanEnableExtension(const Extension* extension) override;
bool CanDisableExtension(const Extension* extension) override;
bool ShouldBlockExtension(const Extension* extension) override;
void GrantActivePermissions(const Extension* extension) override;
raw_ptr<content::BrowserContext> browser_context_; // Not owned.

View file

@ -192,12 +192,6 @@ void ElectronExtensionSystem::InstallUpdate(
NOTREACHED();
}
bool ElectronExtensionSystem::FinishDelayedInstallationIfReady(
const std::string& extension_id,
bool install_immediately) {
NOTREACHED();
}
void ElectronExtensionSystem::PerformActionBasedOnOmahaAttributes(
const std::string& extension_id,
const base::Value::Dict& attributes) {

View file

@ -80,8 +80,6 @@ class ElectronExtensionSystem : public ExtensionSystem {
const base::FilePath& temp_dir,
bool install_immediately,
InstallUpdateCallback install_update_callback) override;
bool FinishDelayedInstallationIfReady(const std::string& extension_id,
bool install_immediately) override;
void PerformActionBasedOnOmahaAttributes(
const std::string& extension_id,
const base::Value::Dict& attributes) override;

View file

@ -32,6 +32,10 @@
#include "printing/printing_features.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "ui/views/views_features.h"
#endif
namespace electron {
void InitializeFeatureList() {
@ -52,6 +56,12 @@ void InitializeFeatureList() {
// Delayed spellcheck initialization is causing the
// 'custom dictionary word list API' spec to crash.
std::string(",") + spellcheck::kWinDelaySpellcheckServiceInit.name;
// Refs https://issues.chromium.org/issues/401996981
// TODO(deepak1556): Remove this once test added in
// https://github.com/electron/electron/pull/12904
// can work without this feature.
enable_features += std::string(",") +
views::features::kEnableTransparentHwndEnlargement.name;
#endif
#if BUILDFLAG(IS_MAC)

View file

@ -25,6 +25,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/disallow_activation_reason.h"
#include "content/public/browser/permission_descriptor_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
@ -162,7 +163,7 @@ bool ShouldBlockAccessToPath(const base::FilePath& path,
// Add the hard-coded rules to the dynamic rules.
for (auto const& [key, rule_path, type] :
ChromeFileSystemAccessPermissionContext::kBlockedPaths) {
ChromeFileSystemAccessPermissionContext::GenerateBlockedPath()) {
if (key == ChromeFileSystemAccessPermissionContext::kNoBasePathKey) {
rules.emplace_back(base::FilePath{rule_path}, type);
} else if (base::FilePath block_path;
@ -319,17 +320,17 @@ class FileSystemAccessPermissionContext::PermissionGrantImpl
return;
}
blink::PermissionType type = static_cast<blink::PermissionType>(
electron::WebContentsPermissionHelper::PermissionType::FILE_SYSTEM);
base::Value::Dict details;
details.Set("filePath", base::FilePathToValue(path_info_.path));
details.Set("isDirectory", handle_type_ == HandleType::kDirectory);
details.Set("fileAccessType",
type_ == GrantType::kWrite ? "writable" : "readable");
const blink::PermissionType type = blink::PermissionType::FILE_SYSTEM;
permission_manager->RequestPermissionWithDetails(
type, rfh, origin, false, std::move(details),
content::PermissionDescriptorUtil::
CreatePermissionDescriptorForPermissionType(type),
rfh, origin, false, std::move(details),
base::BindOnce(&PermissionGrantImpl::OnPermissionRequestResult, this,
std::move(callback)));
}

View file

@ -144,9 +144,7 @@ bool ElectronHidDelegate::CanRequestDevicePermission(
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context->GetPermissionControllerDelegate());
return permission_manager->CheckPermissionWithDetails(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::HID),
nullptr, origin.GetURL(), std::move(details));
blink::PermissionType::HID, nullptr, origin.GetURL(), std::move(details));
}
bool ElectronHidDelegate::HasDevicePermission(

View file

@ -98,10 +98,9 @@ void HidChooserContext::GrantDevicePermission(
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
permission_manager->GrantDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::HID),
origin, DeviceInfoToValue(device), browser_context_);
permission_manager->GrantDevicePermission(blink::PermissionType::HID,
origin, DeviceInfoToValue(device),
browser_context_);
} else {
ephemeral_devices_[origin].insert(device.guid);
}
@ -132,10 +131,9 @@ void HidChooserContext::RevokePersistentDevicePermission(
const device::mojom::HidDeviceInfo& device) {
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
permission_manager->RevokeDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::HID),
origin, DeviceInfoToValue(device), browser_context_);
permission_manager->RevokeDevicePermission(blink::PermissionType::HID, origin,
DeviceInfoToValue(device),
browser_context_);
RevokeEphemeralDevicePermission(origin, device);
}
@ -173,9 +171,8 @@ bool HidChooserContext::HasDevicePermission(
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
return permission_manager->CheckDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::HID),
origin, DeviceInfoToValue(device), browser_context_);
blink::PermissionType::HID, origin, DeviceInfoToValue(device),
browser_context_);
}
bool HidChooserContext::IsFidoAllowedForOrigin(const url::Origin& origin) {

View file

@ -5,6 +5,7 @@
#include "shell/browser/mac/dict_util.h"
#include <string>
#include <string_view>
#include "base/json/json_writer.h"
#include "base/strings/sys_string_conversions.h"
@ -34,12 +35,10 @@ base::Value::List NSArrayToValue(NSArray* arr) {
if ([value isKindOfClass:[NSString class]]) {
result.Append(base::SysNSStringToUTF8(value));
} else if ([value isKindOfClass:[NSNumber class]]) {
const char* objc_type = [value objCType];
if (strcmp(objc_type, @encode(BOOL)) == 0 ||
strcmp(objc_type, @encode(char)) == 0)
const std::string_view objc_type = [value objCType];
if (objc_type == @encode(BOOL) || objc_type == @encode(char))
result.Append([value boolValue]);
else if (strcmp(objc_type, @encode(double)) == 0 ||
strcmp(objc_type, @encode(float)) == 0)
else if (objc_type == @encode(double) || objc_type == @encode(float))
result.Append([value doubleValue]);
else
result.Append([value intValue]);
@ -81,12 +80,10 @@ base::Value::Dict NSDictionaryToValue(NSDictionary* dict) {
if ([value isKindOfClass:[NSString class]]) {
result.Set(str_key, base::Value(base::SysNSStringToUTF8(value)));
} else if ([value isKindOfClass:[NSNumber class]]) {
const char* objc_type = [value objCType];
if (strcmp(objc_type, @encode(BOOL)) == 0 ||
strcmp(objc_type, @encode(char)) == 0)
const std::string_view objc_type = [value objCType];
if (objc_type == @encode(BOOL) || objc_type == @encode(char))
result.Set(str_key, base::Value([value boolValue]));
else if (strcmp(objc_type, @encode(double)) == 0 ||
strcmp(objc_type, @encode(float)) == 0)
else if (objc_type == @encode(double) || objc_type == @encode(float))
result.Set(str_key, base::Value([value doubleValue]));
else
result.Set(str_key, base::Value([value intValue]));

View file

@ -210,10 +210,12 @@ inline void dispatch_sync_main(dispatch_block_t block) {
bool is_manual_ax = [attribute isEqualToString:@"AXManualAccessibility"];
if ([attribute isEqualToString:@"AXEnhancedUserInterface"] || is_manual_ax) {
auto* ax_state = content::BrowserAccessibilityState::GetInstance();
// TODO(wg-upgrades): crbug.com/1470199 remove use of deprecated
// AddAccessibilityModeFlags() and RemoveAccessibilityModeFlags()
if ([value boolValue]) {
ax_state->EnableProcessAccessibility();
ax_state->AddAccessibilityModeFlags(ui::kAXModeComplete);
} else {
ax_state->DisableProcessAccessibility();
ax_state->RemoveAccessibilityModeFlags(ui::kAXModeComplete);
}
electron::Browser::Get()->OnAccessibilitySupportChanged();

View file

@ -34,6 +34,7 @@
#if BUILDFLAG(IS_WIN)
#include "ui/display/win/screen_win.h"
#include "ui/views/views_features.h"
#endif
#if defined(USE_OZONE)
@ -75,11 +76,14 @@ namespace {
#if BUILDFLAG(IS_WIN)
gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
if (!window->transparent())
if (!base::FeatureList::IsEnabled(
views::features::kEnableTransparentHwndEnlargement) ||
!window->transparent()) {
return size;
}
gfx::Size min_size = display::win::ScreenWin::ScreenToDIPSize(
window->GetAcceleratedWidget(), gfx::Size(64, 64));
gfx::Size min_size = display::win::GetScreenWin()->ScreenToDIPSize(
window->GetAcceleratedWidget(), gfx::Size{64, 64});
// 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

View file

@ -210,14 +210,15 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
window_ = static_cast<ElectronNSWindow*>(
widget()->GetNativeWindow().GetNativeNSWindow());
RegisterDeleteDelegateCallback(base::BindOnce(
[](NativeWindowMac* window) {
if (window->window_)
window->window_ = nil;
if (window->buttons_proxy_)
window->buttons_proxy_ = nil;
},
this));
RegisterDeleteDelegateCallback(RegisterDeleteCallbackPassKey(),
base::BindOnce(
[](NativeWindowMac* window) {
if (window->window_)
window->window_ = nil;
if (window->buttons_proxy_)
window->buttons_proxy_ = nil;
},
this));
[window_ setEnableLargerThanScreen:enable_larger_than_screen()];

View file

@ -106,10 +106,10 @@ DWM_SYSTEMBACKDROP_TYPE GetBackdropFromString(const std::string& material) {
// original ceil()-ed values can cause calculation errors, since converting
// both ways goes through a ceil() call. Related issue: #15816
gfx::Rect ScreenToDIPRect(HWND hwnd, const gfx::Rect& pixel_bounds) {
float scale_factor = display::win::ScreenWin::GetScaleFactorForHWND(hwnd);
const auto* const screen_win = display::win::GetScreenWin();
const float scale_factor = screen_win->GetScaleFactorForHWND(hwnd);
gfx::Rect dip_rect = ScaleToRoundedRect(pixel_bounds, 1.0f / scale_factor);
dip_rect.set_origin(
display::win::ScreenWin::ScreenToDIPRect(hwnd, pixel_bounds).origin());
dip_rect.set_origin(screen_win->ScreenToDIPRect(hwnd, pixel_bounds).origin());
return dip_rect;
}
@ -135,10 +135,11 @@ void FlipWindowStyle(HWND handle, bool on, DWORD flag) {
}
gfx::Rect DIPToScreenRect(HWND hwnd, const gfx::Rect& pixel_bounds) {
float scale_factor = display::win::ScreenWin::GetScaleFactorForHWND(hwnd);
const auto* const screen_win = display::win::GetScreenWin();
const float scale_factor = screen_win->GetScaleFactorForHWND(hwnd);
gfx::Rect screen_rect = ScaleToRoundedRect(pixel_bounds, scale_factor);
screen_rect.set_origin(
display::win::ScreenWin::DIPToScreenRect(hwnd, pixel_bounds).origin());
screen_win->DIPToScreenRect(hwnd, pixel_bounds).origin());
return screen_rect;
}
@ -433,20 +434,21 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
SetBounds(gfx::Rect(GetPosition(), bounds.size()), false);
#endif
SetOwnedByWidget(false);
RegisterDeleteDelegateCallback(base::BindOnce(
[](NativeWindowViews* window) {
if (window->is_modal() && window->parent()) {
auto* parent = window->parent();
// Enable parent window after current window gets closed.
static_cast<NativeWindowViews*>(parent)->DecrementChildModals();
// Focus on parent window.
parent->Focus(true);
}
RegisterDeleteDelegateCallback(
RegisterDeleteCallbackPassKey(),
base::BindOnce(
[](NativeWindowViews* window) {
if (window->is_modal() && window->parent()) {
auto* parent = window->parent();
// Enable parent window after current window gets closed.
static_cast<NativeWindowViews*>(parent)->DecrementChildModals();
// Focus on parent window.
parent->Focus(true);
}
window->NotifyWindowClosed();
},
this));
window->NotifyWindowClosed();
},
this));
}
NativeWindowViews::~NativeWindowViews() {
@ -1081,8 +1083,7 @@ void NativeWindowViews::SetClosable(bool closable) {
bool NativeWindowViews::IsClosable() const {
#if BUILDFLAG(IS_WIN)
HMENU menu = GetSystemMenu(GetAcceleratedWidget(), false);
MENUITEMINFO info;
memset(&info, 0, sizeof(info));
MENUITEMINFO info = {};
info.cbSize = sizeof(info);
info.fMask = MIIM_STATE;
if (!GetMenuItemInfo(menu, SC_CLOSE, false, &info)) {
@ -1137,7 +1138,8 @@ void NativeWindowViews::Center() {
widget()->SetBounds(window_bounds_in_screen);
#else
HWND hwnd = GetAcceleratedWidget();
gfx::Size size = display::win::ScreenWin::DIPToScreenSize(hwnd, GetSize());
gfx::Size size =
display::win::GetScreenWin()->DIPToScreenSize(hwnd, GetSize());
gfx::CenterAndSizeWindow(nullptr, hwnd, size);
#endif
}
@ -1361,9 +1363,9 @@ void NativeWindowViews::SetMenu(ElectronMenuModel* menu_model) {
}
// Use global application menu bar when possible.
bool can_use_global_menus = ui::OzonePlatform::GetInstance()
->GetPlatformProperties()
.supports_global_application_menus;
const bool can_use_global_menus = ui::OzonePlatform::GetInstance()
->GetPlatformRuntimeProperties()
.supports_global_application_menus;
if (can_use_global_menus && ShouldUseGlobalMenuBar()) {
if (!global_menu_bar_)
global_menu_bar_ = std::make_unique<GlobalMenuBarX11>(this);

View file

@ -280,9 +280,11 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
checked_for_a11y_support_ = true;
// TODO(wg-upgrades): crbug.com/1470199 remove use of deprecated
// AddAccessibilityModeFlags() and RemoveAccessibilityModeFlags()
auto* const axState = content::BrowserAccessibilityState::GetInstance();
if (axState && axState->GetAccessibilityMode() != ui::kAXModeComplete) {
axState->EnableProcessAccessibility();
axState->AddAccessibilityModeFlags(ui::kAXModeComplete);
Browser::Get()->OnAccessibilitySupportChanged();
}

View file

@ -7,6 +7,7 @@
#include "chrome/browser/net/proxy_config_monitor.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/features.h"
#include "sandbox/policy/features.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/network_context.mojom.h"

View file

@ -31,8 +31,7 @@ void RelauncherSynchronizeWithParent() {
}
// set up a signum handler
struct sigaction action;
memset(&action, 0, sizeof(action));
struct sigaction action = {};
action.sa_handler = [](int /*signum*/) { parentWaiter.Signal(); };
if (sigaction(signum, &action, nullptr) != 0) {
PLOG(ERROR) << "sigaction";

View file

@ -92,10 +92,9 @@ void SerialChooserContext::GrantPortPermission(
if (CanStorePersistentEntry(port)) {
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
permission_manager->GrantDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::SERIAL),
origin, PortInfoToValue(port), browser_context_);
permission_manager->GrantDevicePermission(blink::PermissionType::SERIAL,
origin, PortInfoToValue(port),
browser_context_);
return;
}
@ -125,9 +124,8 @@ bool SerialChooserContext::HasPortPermission(
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
return permission_manager->CheckDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::SERIAL),
origin, PortInfoToValue(port), browser_context_);
blink::PermissionType::SERIAL, origin, PortInfoToValue(port),
browser_context_);
}
void SerialChooserContext::RevokePortPermissionWebInitiated(
@ -139,9 +137,8 @@ void SerialChooserContext::RevokePortPermissionWebInitiated(
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
permission_manager->RevokeDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::SERIAL),
origin, PortInfoToValue(*it->second), browser_context_);
blink::PermissionType::SERIAL, origin, PortInfoToValue(*it->second),
browser_context_);
}
auto ephemeral = ephemeral_ports_.find(origin);

View file

@ -16,6 +16,8 @@
#import <objc/message.h>
#import <objc/runtime.h>
using namespace std::string_view_literals;
namespace electron {
int ScopedDisableResize::disable_resize_ = 0;
@ -140,19 +142,14 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) {
if (styleMask & NSWindowStyleMaskTitled) {
if (!g_nsthemeframe_mousedown) {
NSView* theme_frame = [[self contentView] superview];
DCHECK(strcmp(class_getName([theme_frame class]), "NSThemeFrame") == 0)
<< "Expected NSThemeFrame but was "
<< class_getName([theme_frame class]);
DCHECK_EQ("NSThemeFrame"sv, class_getName([theme_frame class]));
SwizzleMouseDown(theme_frame, @selector(swiz_nsthemeframe_mouseDown:),
&g_nsthemeframe_mousedown);
}
} else {
if (!g_nsnextstepframe_mousedown) {
NSView* nextstep_frame = [[self contentView] superview];
DCHECK(strcmp(class_getName([nextstep_frame class]),
"NSNextStepFrame") == 0)
<< "Expected NSNextStepFrame but was "
<< class_getName([nextstep_frame class]);
DCHECK_EQ("NSNextStepFrame"sv, class_getName([nextstep_frame class]));
SwizzleMouseDown(nextstep_frame,
@selector(swiz_nsnextstepframe_mouseDown:),
&g_nsnextstepframe_mousedown);

View file

@ -12,7 +12,7 @@
namespace electron {
RootViewMac::RootViewMac(NativeWindow* window) : window_(window) {
set_owned_by_client();
set_owned_by_client(OwnedByClientPassKey{});
SetLayoutManager(std::make_unique<views::FillLayout>());
}

View file

@ -65,26 +65,15 @@ void ConvertFilters(const Filters& filters,
}
}
static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem,
SIGDN type,
LPWSTR lpstr,
size_t cchLength) {
assert(pShellItem != nullptr);
auto GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type) {
std::optional<base::FilePath> path;
LPWSTR lpstrName = nullptr;
HRESULT hRet = pShellItem->GetDisplayName(type, &lpstrName);
if (SUCCEEDED(hRet)) {
if (wcslen(lpstrName) < cchLength) {
wcscpy_s(lpstr, cchLength, lpstrName);
} else {
NOTREACHED();
}
::CoTaskMemFree(lpstrName);
if (wchar_t* name = {}; SUCCEEDED(pShellItem->GetDisplayName(type, &name))) {
path.emplace(name);
::CoTaskMemFree(name);
}
return hRet;
return path;
}
static void SetDefaultFolder(IFileDialog* dialog,
@ -206,14 +195,11 @@ bool ShowOpenDialogSync(const DialogSettings& settings,
if (FAILED(hr))
return false;
wchar_t file_name[MAX_PATH];
hr = GetFileNameFromShellItem(item, SIGDN_FILESYSPATH, file_name,
std::size(file_name));
if (FAILED(hr))
auto path = GetFileNameFromShellItem(item, SIGDN_FILESYSPATH);
if (!path)
return false;
paths->push_back(base::FilePath(file_name));
paths->emplace_back(std::move(*path));
}
return true;

View file

@ -23,8 +23,6 @@
namespace electron {
namespace {
class DevToolsWindowDelegate : public views::ClientView,
public views::WidgetDelegate {
public:
@ -35,8 +33,8 @@ class DevToolsWindowDelegate : public views::ClientView,
shell_(shell),
view_(view),
widget_(widget) {
SetOwnedByWidget(true);
set_owned_by_client();
SetOwnedByWidget(OwnedByWidgetPassKey{});
set_owned_by_client(OwnedByClientPassKey{});
if (shell->GetDelegate())
icon_ = shell->GetDelegate()->GetDevToolsWindowIcon();
@ -72,8 +70,6 @@ class DevToolsWindowDelegate : public views::ClientView,
ui::ImageModel icon_;
};
} // namespace
InspectableWebContentsView::InspectableWebContentsView(
InspectableWebContents* inspectable_web_contents)
: inspectable_web_contents_(inspectable_web_contents),

View file

@ -2,6 +2,9 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include <iostream>
#include <string_view>
#include "shell/browser/ui/message_box.h"
#include "base/containers/flat_map.h"
@ -25,12 +28,6 @@
#include "ui/base/ui_base_features.h"
#endif
#define ANSI_FOREGROUND_RED "\x1b[31m"
#define ANSI_FOREGROUND_BLACK "\x1b[30m"
#define ANSI_TEXT_BOLD "\x1b[1m"
#define ANSI_BACKGROUND_GRAY "\x1b[47m"
#define ANSI_RESET "\x1b[0m"
namespace electron {
MessageBoxSettings::MessageBoxSettings() = default;
@ -256,11 +253,15 @@ void ShowErrorBox(const std::u16string& title, const std::u16string& content) {
GtkMessageBox(settings).RunSynchronous();
} else {
fprintf(stderr,
ANSI_TEXT_BOLD ANSI_BACKGROUND_GRAY ANSI_FOREGROUND_RED
"%s\n" ANSI_FOREGROUND_BLACK "%s" ANSI_RESET "\n",
base::UTF16ToUTF8(title).c_str(),
base::UTF16ToUTF8(content).c_str());
static constexpr std::string_view ANSI_FG_RED = "\x1b[31m";
static constexpr std::string_view ANSI_FG_BLACK = "\x1b[30m";
static constexpr std::string_view ANSI_TEXT_BOLD = "\x1b[1m";
static constexpr std::string_view ANSI_BG_GRAY = "\x1b[47m";
static constexpr std::string_view ANSI_RESET = "\x1b[0m";
std::cerr << ANSI_TEXT_BOLD << ANSI_BG_GRAY << ANSI_FG_RED
<< base::UTF16ToUTF8(title) << '\n'
<< ANSI_FG_BLACK << base::UTF16ToUTF8(content) << '\n'
<< ANSI_RESET;
}
}

View file

@ -33,7 +33,9 @@ END_METADATA
AutofillPopupView::AutofillPopupView(AutofillPopup* popup,
views::Widget* parent_widget)
: popup_(popup), parent_widget_(parent_widget) {
: views::WidgetDelegateView(CreatePassKey()),
popup_(popup),
parent_widget_(parent_widget) {
CreateChildViews();
SetFocusBehavior(FocusBehavior::ALWAYS);
set_drag_controller(this);

View file

@ -35,7 +35,7 @@ RootView::RootView(NativeWindow* window)
: window_{raw_ref<NativeWindow>::from_ptr(window)},
main_view_{raw_ref<views::View>::from_ptr(
AddChildView(std::make_unique<views::View>()))} {
set_owned_by_client();
set_owned_by_client(OwnedByClientPassKey{});
views::BoxLayout* layout =
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical));
@ -63,7 +63,7 @@ void RootView::SetMenu(ElectronMenuModel* menu_model) {
if (!menu_bar_) {
menu_bar_ = std::make_unique<MenuBar>(&window_.get(), this);
menu_bar_->set_owned_by_client();
menu_bar_->set_owned_by_client(OwnedByClientPassKey{});
if (!menu_bar_autohide_)
SetMenuBarVisibility(true);
}

View file

@ -68,9 +68,10 @@ gfx::Rect WinFrameView::GetWindowBoundsForClientBounds(
}
int WinFrameView::FrameBorderThickness() const {
return (IsMaximized() || frame()->IsFullscreen())
? 0
: display::win::ScreenWin::GetSystemMetricsInDIP(SM_CXSIZEFRAME);
if (frame()->IsFullscreen() || IsMaximized())
return 0;
return display::win::GetScreenWin()->GetSystemMetricsInDIP(SM_CXSIZEFRAME);
}
views::View* WinFrameView::TargetForRect(views::View* root,
@ -178,7 +179,7 @@ int WinFrameView::FrameTopBorderThickness(bool restored) const {
// to fail when it ought to succeed.
return std::floor(
FrameTopBorderThicknessPx(restored) /
display::win::ScreenWin::GetScaleFactorForHWND(HWNDForView(this)));
display::win::GetScreenWin()->GetScaleFactorForHWND(HWNDForView(this)));
}
int WinFrameView::FrameTopBorderThicknessPx(bool restored) const {
@ -203,7 +204,7 @@ int WinFrameView::FrameTopBorderThicknessPx(bool restored) const {
int WinFrameView::TitlebarMaximizedVisualHeight() const {
int maximized_height =
display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYCAPTION);
display::win::GetScreenWin()->GetSystemMetricsInDIP(SM_CYCAPTION);
return maximized_height;
}

View file

@ -84,7 +84,6 @@ constexpr std::string_view kText = "text";
constexpr std::string_view kWeb = "web";
// Possible global flag values
constexpr std::string_view kDisabled = "disabled";
constexpr std::string_view kOff = "off";
constexpr std::string_view kOn = "on";
@ -160,8 +159,6 @@ void HandleAccessibilityRequestCallback(
static_cast<electron::ElectronBrowserContext*>(current_context)->prefs();
ui::AXMode mode =
content::BrowserAccessibilityState::GetInstance()->GetAccessibilityMode();
bool is_a11y_allowed = content::BrowserAccessibilityState::GetInstance()
->IsAccessibilityAllowed();
bool native = mode.has_mode(ui::AXMode::kNativeAPIs);
bool web = mode.has_mode(ui::AXMode::kWebContents);
bool text = mode.has_mode(ui::AXMode::kInlineTextBoxes);
@ -171,16 +168,14 @@ void HandleAccessibilityRequestCallback(
// The "native" and "web" flags are disabled if
// --disable-renderer-accessibility is set.
data.Set(kNative, is_a11y_allowed ? (native ? kOn : kOff) : kDisabled);
data.Set(kWeb, is_a11y_allowed ? (web ? kOn : kOff) : kDisabled);
data.Set(kNative, native ? kOn : kOff);
data.Set(kWeb, web ? kOn : kOff);
// The "text", "extendedProperties" and "html" flags are only
// meaningful if "web" is enabled.
bool is_web_enabled = is_a11y_allowed && web;
data.Set(kText, is_web_enabled ? (text ? kOn : kOff) : kDisabled);
data.Set(kExtendedProperties,
is_web_enabled ? (extendedProperties ? kOn : kOff) : kDisabled);
data.Set(kHTML, is_web_enabled ? (html ? kOn : kOff) : kDisabled);
data.Set(kText, text ? kOn : kOff);
data.Set(kExtendedProperties, extendedProperties ? kOn : kOff);
data.Set(kHTML, html ? kOn : kOff);
// The "pdfPrinting" flag is independent of the others.
data.Set(kPDFPrinting, pdf_printing ? kOn : kOff);
@ -245,9 +240,9 @@ void HandleAccessibilityRequestCallback(
}
base::Value::Dict descriptor = BuildTargetDescriptor(rvh);
descriptor.Set(kNative, is_a11y_allowed);
descriptor.Set(kExtendedProperties, is_web_enabled && extendedProperties);
descriptor.Set(kWeb, is_web_enabled);
descriptor.Set(kNative, native);
descriptor.Set(kExtendedProperties, extendedProperties);
descriptor.Set(kWeb, web);
page_list.Append(std::move(descriptor));
}
data.Set(kPagesField, std::move(page_list));

View file

@ -6,6 +6,7 @@
#include <objbase.h>
#include "base/containers/span.h"
#include "base/logging.h"
#include "base/strings/string_util_win.h"
#include "base/strings/utf_string_conversions.h"
@ -49,11 +50,10 @@ NotifyIcon::NotifyIcon(NotifyIconHost* host,
: host_(host), icon_id_(id), window_(window), message_id_(message) {
guid_ = guid;
is_using_guid_ = guid != GUID_DEFAULT;
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
NOTIFYICONDATA icon_data = InitIconData();
icon_data.uFlags |= NIF_MESSAGE;
icon_data.uCallbackMessage = message_id_;
BOOL result = Shell_NotifyIcon(NIM_ADD, &icon_data);
const BOOL result = Shell_NotifyIcon(NIM_ADD, &icon_data);
// This can happen if the explorer process isn't running when we try to
// create the icon for some reason (for example, at startup).
if (!result)
@ -63,8 +63,7 @@ NotifyIcon::NotifyIcon(NotifyIconHost* host,
NotifyIcon::~NotifyIcon() {
// Remove our icon.
host_->Remove(this);
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
NOTIFYICONDATA icon_data = InitIconData();
Shell_NotifyIcon(NIM_DELETE, &icon_data);
}
@ -110,11 +109,12 @@ void NotifyIcon::HandleMouseExited(int modifiers) {
}
void NotifyIcon::ResetIcon() {
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
// Delete any previously existing icon.
NOTIFYICONDATA icon_data = InitIconData();
Shell_NotifyIcon(NIM_DELETE, &icon_data);
InitIconData(&icon_data);
// Update the icon.
icon_data = InitIconData();
icon_data.uFlags |= NIF_MESSAGE;
icon_data.uCallbackMessage = message_id_;
icon_data.hIcon = icon_.get();
@ -132,8 +132,7 @@ void NotifyIcon::SetImage(HICON image) {
icon_ = base::win::ScopedGDIObject<HICON>(CopyIcon(image));
// Create the icon.
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
NOTIFYICONDATA icon_data = InitIconData();
icon_data.uFlags |= NIF_ICON;
icon_data.hIcon = image;
BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
@ -146,23 +145,34 @@ void NotifyIcon::SetPressedImage(HICON image) {
// pressed status icons.
}
template <typename CharT, size_t N>
static void CopyStringToBuf(CharT (&tgt_buf)[N],
const std::basic_string<CharT> src_str) {
if constexpr (N < 1U)
return;
const auto src = base::span{src_str};
const auto n_chars = std::min(src.size(), N - 1U);
auto tgt = base::span{tgt_buf};
tgt.first(n_chars).copy_from(src.first(n_chars));
tgt[n_chars] = CharT{}; // zero-terminate the string
}
void NotifyIcon::SetToolTip(const std::string& tool_tip) {
// Create the icon.
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
NOTIFYICONDATA icon_data = InitIconData();
icon_data.uFlags |= NIF_TIP;
wcsncpy_s(icon_data.szTip, base::UTF8ToWide(tool_tip).c_str(), _TRUNCATE);
CopyStringToBuf(icon_data.szTip, base::UTF8ToWide(tool_tip));
BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
if (!result)
LOG(WARNING) << "Unable to set tooltip for status tray icon";
}
void NotifyIcon::DisplayBalloon(const BalloonOptions& options) {
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
NOTIFYICONDATA icon_data = InitIconData();
icon_data.uFlags |= NIF_INFO;
wcsncpy_s(icon_data.szInfoTitle, base::as_wcstr(options.title), _TRUNCATE);
wcsncpy_s(icon_data.szInfo, base::as_wcstr(options.content), _TRUNCATE);
CopyStringToBuf(icon_data.szInfoTitle, base::AsWString(options.title));
CopyStringToBuf(icon_data.szInfo, base::AsWString(options.content));
icon_data.uTimeout = 0;
icon_data.hBalloonIcon = options.icon;
icon_data.dwInfoFlags = ConvertIconType(options.icon_type);
@ -182,8 +192,7 @@ void NotifyIcon::DisplayBalloon(const BalloonOptions& options) {
}
void NotifyIcon::RemoveBalloon() {
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
NOTIFYICONDATA icon_data = InitIconData();
icon_data.uFlags |= NIF_INFO;
BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
@ -192,8 +201,7 @@ void NotifyIcon::RemoveBalloon() {
}
void NotifyIcon::Focus() {
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
NOTIFYICONDATA icon_data = InitIconData();
BOOL result = Shell_NotifyIcon(NIM_SETFOCUS, &icon_data);
if (!result)
@ -242,8 +250,7 @@ void NotifyIcon::SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) {
}
gfx::Rect NotifyIcon::GetBounds() {
NOTIFYICONIDENTIFIER icon_id;
memset(&icon_id, 0, sizeof(NOTIFYICONIDENTIFIER));
NOTIFYICONIDENTIFIER icon_id = {};
icon_id.uID = icon_id_;
icon_id.hWnd = window_;
icon_id.cbSize = sizeof(NOTIFYICONIDENTIFIER);
@ -253,18 +260,20 @@ gfx::Rect NotifyIcon::GetBounds() {
RECT rect = {0};
Shell_NotifyIconGetRect(&icon_id, &rect);
return display::win::ScreenWin::ScreenToDIPRect(window_, gfx::Rect(rect));
return display::win::GetScreenWin()->ScreenToDIPRect(window_,
gfx::Rect{rect});
}
void NotifyIcon::InitIconData(NOTIFYICONDATA* icon_data) {
memset(icon_data, 0, sizeof(NOTIFYICONDATA));
icon_data->cbSize = sizeof(NOTIFYICONDATA);
icon_data->hWnd = window_;
icon_data->uID = icon_id_;
NOTIFYICONDATA NotifyIcon::InitIconData() const {
NOTIFYICONDATA icon_data = {};
icon_data.cbSize = sizeof(NOTIFYICONDATA);
icon_data.hWnd = window_;
icon_data.uID = icon_id_;
if (is_using_guid_) {
icon_data->uFlags = NIF_GUID;
icon_data->guidItem = guid_;
icon_data.uFlags = NIF_GUID;
icon_data.guidItem = guid_;
}
return icon_data;
}
} // namespace electron

View file

@ -76,7 +76,7 @@ class NotifyIcon : public TrayIcon {
base::WeakPtr<NotifyIcon> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
private:
void InitIconData(NOTIFYICONDATA* icon_data);
NOTIFYICONDATA InitIconData() const;
// The tray that owns us. Weak.
raw_ptr<NotifyIconHost> host_;

View file

@ -8,6 +8,7 @@
#include <array>
#include <string>
#include "base/containers/span.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/scoped_gdi_object.h"
#include "shell/browser/native_window.h"
@ -52,6 +53,18 @@ bool GetThumbarButtonFlags(const std::vector<std::string>& flags,
return true;
}
template <typename CharT, size_t N>
void CopyStringToBuf(CharT (&tgt_buf)[N],
const std::basic_string<CharT> src_str) {
if constexpr (N < 1U)
return;
const auto src = base::span{src_str};
const auto n_chars = std::min(src.size(), N - 1U);
auto tgt = base::span{tgt_buf};
tgt.first(n_chars).copy_from(src.first(n_chars));
tgt[n_chars] = CharT{}; // zero-terminate the string
}
} // namespace
TaskbarHost::ThumbarButton::ThumbarButton() = default;
@ -109,8 +122,7 @@ bool TaskbarHost::SetThumbarButtons(HWND window,
// Set tooltip.
if (!button.tooltip.empty()) {
thumb_button.dwMask |= THB_TOOLTIP;
wcsncpy_s(thumb_button.szTip, base::UTF8ToWide(button.tooltip).c_str(),
_TRUNCATE);
CopyStringToBuf(thumb_button.szTip, base::UTF8ToWide(button.tooltip));
}
// Save callback.
@ -234,7 +246,7 @@ bool TaskbarHost::SetThumbnailClip(HWND window, const gfx::Rect& region) {
return SUCCEEDED(taskbar_->SetThumbnailClip(window, nullptr));
} else {
RECT rect =
display::win::ScreenWin::DIPToScreenRect(window, region).ToRECT();
display::win::GetScreenWin()->DIPToScreenRect(window, region).ToRECT();
return SUCCEEDED(taskbar_->SetThumbnailClip(window, &rect));
}
}

View file

@ -182,9 +182,7 @@ bool ElectronUsbDelegate::CanRequestDevicePermission(
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context->GetPermissionControllerDelegate());
return permission_manager->CheckPermissionWithDetails(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::USB),
nullptr, origin.GetURL(), std::move(details));
blink::PermissionType::USB, nullptr, origin.GetURL(), std::move(details));
}
void ElectronUsbDelegate::RevokeDevicePermissionWebInitiated(

View file

@ -175,9 +175,7 @@ void UsbChooserContext::RevokeObjectPermissionInternal(
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
permission_manager->RevokeDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::USB),
origin, object, browser_context_);
blink::PermissionType::USB, origin, object, browser_context_);
} else {
const std::string* guid = object_dict->FindString(kDeviceIdKey);
auto it = ephemeral_devices_.find(origin);
@ -206,9 +204,8 @@ void UsbChooserContext::GrantDevicePermission(
auto* permission_manager = static_cast<ElectronPermissionManager*>(
browser_context_->GetPermissionControllerDelegate());
permission_manager->GrantDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::USB),
origin, DeviceInfoToValue(device_info), browser_context_);
blink::PermissionType::USB, origin, DeviceInfoToValue(device_info),
browser_context_);
} else {
ephemeral_devices_[origin].insert(device_info.guid);
}
@ -232,9 +229,8 @@ bool UsbChooserContext::HasDevicePermission(
browser_context_->GetPermissionControllerDelegate());
return permission_manager->CheckDevicePermission(
static_cast<blink::PermissionType>(
WebContentsPermissionHelper::PermissionType::USB),
origin, DeviceInfoToValue(device_info), browser_context_);
blink::PermissionType::USB, origin, DeviceInfoToValue(device_info),
browser_context_);
}
void UsbChooserContext::GetDevices(

View file

@ -10,6 +10,7 @@
#include "components/content_settings/core/common/content_settings.h"
#include "components/webrtc/media_stream_devices_controller.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/permission_descriptor_util.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents_user_data.h"
#include "shell/browser/electron_browser_context.h"
@ -220,7 +221,9 @@ void WebContentsPermissionHelper::RequestPermission(
web_contents_->GetBrowserContext()->GetPermissionControllerDelegate());
auto origin = web_contents_->GetLastCommittedURL();
permission_manager->RequestPermissionWithDetails(
permission, requesting_frame, origin, false, std::move(details),
content::PermissionDescriptorUtil::
CreatePermissionDescriptorForPermissionType(permission),
requesting_frame, origin, false, std::move(details),
base::BindOnce(&OnPermissionResponse, std::move(callback)));
}
@ -238,10 +241,9 @@ bool WebContentsPermissionHelper::CheckPermission(
void WebContentsPermissionHelper::RequestFullscreenPermission(
content::RenderFrameHost* requesting_frame,
base::OnceCallback<void(bool)> callback) {
RequestPermission(
requesting_frame,
static_cast<blink::PermissionType>(PermissionType::FULLSCREEN),
std::move(callback));
RequestPermission(requesting_frame,
blink::PermissionType::ELECTRON_FULLSCREEN,
std::move(callback));
}
void WebContentsPermissionHelper::RequestMediaAccessPermission(
@ -306,10 +308,8 @@ void WebContentsPermissionHelper::RequestOpenExternalPermission(
const GURL& url) {
base::Value::Dict details;
details.Set("externalURL", url.spec());
RequestPermission(
requesting_frame,
static_cast<blink::PermissionType>(PermissionType::OPEN_EXTERNAL),
std::move(callback), user_gesture, std::move(details));
RequestPermission(requesting_frame, blink::PermissionType::OPEN_EXTERNAL,
std::move(callback), user_gesture, std::move(details));
}
bool WebContentsPermissionHelper::CheckMediaAccessPermission(
@ -328,9 +328,7 @@ bool WebContentsPermissionHelper::CheckSerialAccessPermission(
const url::Origin& embedding_origin) const {
base::Value::Dict details;
details.Set("securityOrigin", embedding_origin.GetURL().spec());
return CheckPermission(
static_cast<blink::PermissionType>(PermissionType::SERIAL),
std::move(details));
return CheckPermission(blink::PermissionType::SERIAL, std::move(details));
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsPermissionHelper);

View file

@ -25,15 +25,6 @@ class WebContentsPermissionHelper
WebContentsPermissionHelper& operator=(const WebContentsPermissionHelper&) =
delete;
enum class PermissionType {
FULLSCREEN = static_cast<int>(blink::PermissionType::NUM) + 1,
OPEN_EXTERNAL,
SERIAL,
HID,
USB,
FILE_SYSTEM,
};
// Asynchronous Requests
void RequestFullscreenPermission(content::RenderFrameHost* requesting_frame,
base::OnceCallback<void(bool)> callback);

View file

@ -13,6 +13,7 @@
#include "base/check_op.h"
#include "base/containers/fixed_flat_map.h"
#include "base/containers/span.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/sequence_checker.h"
@ -151,20 +152,13 @@ class BufferDataSource : public mojo::DataPipeProducer::DataSource {
private:
// mojo::DataPipeProducer::DataSource:
[[nodiscard]] uint64_t GetLength() const override { return buffer_.size(); }
ReadResult Read(uint64_t offset, base::span<char> buffer) override {
ReadResult result;
if (offset <= buffer_.size()) {
size_t readable_size = buffer_.size() - offset;
size_t writable_size = buffer.size();
size_t copyable_size = std::min(readable_size, writable_size);
if (copyable_size > 0) {
memcpy(buffer.data(), &buffer_[offset], copyable_size);
}
result.bytes_read = copyable_size;
} else {
NOTREACHED();
}
return result;
ReadResult Read(uint64_t offset, base::span<char> tgt) override {
CHECK_LE(offset, buffer_.size());
const auto src =
base::span<const char>{buffer_}.subspan(static_cast<size_t>(offset));
const auto n_copied = std::min(src.size(), tgt.size());
tgt.first(n_copied).copy_from(src.first(n_copied));
return ReadResult{.bytes_read = n_copied};
}
std::vector<char> buffer_;
@ -715,7 +709,9 @@ void SimpleURLLoaderWrapper::OnDataReceived(std::string_view string_view,
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
auto array_buffer = v8::ArrayBuffer::New(isolate, string_view.size());
memcpy(array_buffer->Data(), string_view.data(), string_view.size());
// TODO SAFETY: migrate this to shell/common/v8_util.h
UNSAFE_BUFFERS(
std::ranges::copy(string_view, static_cast<char*>(array_buffer->Data())));
Emit("data", array_buffer, std::move(resume));
}

View file

@ -148,7 +148,6 @@ bool Converter<blink::mojom::PermissionStatus>::FromV8(
v8::Local<v8::Value> Converter<blink::PermissionType>::ToV8(
v8::Isolate* isolate,
const blink::PermissionType& val) {
using PermissionType = electron::WebContentsPermissionHelper::PermissionType;
// Based on mappings from content/browser/devtools/protocol/browser_handler.cc
// Not all permissions are currently used by Electron but this will future
// proof these conversions.
@ -225,28 +224,28 @@ v8::Local<v8::Value> Converter<blink::PermissionType>::ToV8(
return StringToV8(isolate, "web-app-installation");
case blink::PermissionType::LOCAL_NETWORK_ACCESS:
return StringToV8(isolate, "local-network-access");
// Permissions added by Electron
case blink::PermissionType::DEPRECATED_SYNC_CLIPBOARD_READ:
return StringToV8(isolate, "deprecated-sync-clipboard-read");
case blink::PermissionType::FILE_SYSTEM:
return StringToV8(isolate, "fileSystem");
case blink::PermissionType::ELECTRON_FULLSCREEN:
return StringToV8(isolate, "fullscreen");
case blink::PermissionType::HID:
return StringToV8(isolate, "hid");
case blink::PermissionType::OPEN_EXTERNAL:
return StringToV8(isolate, "openExternal");
case blink::PermissionType::SERIAL:
return StringToV8(isolate, "serial");
case blink::PermissionType::USB:
return StringToV8(isolate, "usb");
case blink::PermissionType::NUM:
break;
}
switch (static_cast<PermissionType>(val)) {
case PermissionType::FULLSCREEN:
return StringToV8(isolate, "fullscreen");
case PermissionType::OPEN_EXTERNAL:
return StringToV8(isolate, "openExternal");
case PermissionType::SERIAL:
return StringToV8(isolate, "serial");
case PermissionType::HID:
return StringToV8(isolate, "hid");
case PermissionType::USB:
return StringToV8(isolate, "usb");
case PermissionType::FILE_SYSTEM:
return StringToV8(isolate, "fileSystem");
default:
return StringToV8(isolate, "unknown");
}
return StringToV8(isolate, "unknown");
}
// static

View file

@ -25,10 +25,10 @@ std::vector<std::string> GetPreferredLanguages() {
// SAFETY: |g_get_language_names()| returns a glib-owned array
// of const C strings, terminated by an empty string.
// This loop is the correct way to walk through its return values.
static constexpr std::string_view CLangName = "C";
for (; *languages; UNSAFE_BUFFERS(++languages)) {
if (strcmp(*languages, "C") != 0) {
if (CLangName != *languages)
preferredLanguages.push_back(base::i18n::GetCanonicalLocale(*languages));
}
}
return preferredLanguages;

View file

@ -5,6 +5,7 @@
#include "shell/common/node_bindings.h"
#include <algorithm>
#include <iostream>
#include <string>
#include <string_view>
#include <utility>
@ -605,9 +606,8 @@ void NodeBindings::Initialize(v8::Local<v8::Context> context) {
args,
static_cast<node::ProcessInitializationFlags::Flags>(process_flags));
for (const std::string& error : result->errors()) {
fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str());
}
for (const std::string& error : result->errors())
std::cerr << args[0] << ": " << error << '\n';
if (result->early_return() != 0)
exit(result->exit_code());

View file

@ -2,6 +2,12 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove FD_ZERO and convert code to safer
// constructs.
#pragma allow_unsafe_buffers
#endif
#include "shell/common/node_bindings_mac.h"
#include <errno.h>

View file

@ -5,6 +5,7 @@
#include "shell/renderer/preload_utils.h"
#include "base/process/process.h"
#include "base/strings/strcat.h"
#include "shell/common/gin_helper/arguments.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
@ -46,10 +47,7 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
auto* mod = node::binding::get_linked_module(binding_key.c_str());
if (!mod) {
char errmsg[1024];
snprintf(errmsg, sizeof(errmsg), "No such binding: %s",
binding_key.c_str());
margs->ThrowError(errmsg);
margs->ThrowError(base::StrCat({"No such binding: ", binding_key}));
return exports;
}