chore: bump chromium to 100.0.4857.0 (main) (#32419)

* chore: bump chromium in DEPS to 99.0.4819.0

* chore: update patches

* chore: bump chromium in DEPS to 99.0.4824.0

* chore: update patches

* chore: bump chromium in DEPS to 99.0.4827.0

* chore: update patches

* 3352511: PiP: Add inkdrop and pointer cursor to PiP window buttons

3352511

* 3309164: webhid: Show FIDO devices in the chooser if allowed

3309164

* 3297868: hid: Add experimental HIDDevice.forget()

3297868

* 3362491: [Extensions] Move i18n API to //extensions

3362491

* MCC Refactor step0: Allow embedders to register associated_interface binders with RenderFrameHostImpl::associated_registry_.

3281481

* 3352616: [Gtk] Remove libgtk from the link-line

3352616

* 3249211: Clear-Site-Data support for partitioned cookies

3249211

* [Extensions][COIL] Use [allow|block]list in //extensions/common

3372668

* Begin ScopedUserPrefUpdate migration to modern base::Value

3376154

* [Code Health] Refactor PrefService GetDict + GetList to use base::Value

3343526

* 3354997: [CodeHealth] Remove deprecated SetDictionary method

3354997

* 3287323: Add LacrosPrefStore for lacros settings

3287323

* 3365916: [PA] Clean up remaining lazy commit code

3365916

* [MPArch] Target the external protocol error at the responsible frame.

3011560

* Pass origin to RegisterNonNetworkSubresourceURLLoaderFactories

3350608

* Linux: Send OSCrypt raw encryption key to the Network Service

3320484

* [PlzServiceWorker] Remove remaining references to PlzServiceWorker.

3359441

* chore: fixup for lint

* 3327621: Fix tablet mode detection for Win 11.

3327621

* 3342428: ax_mac: move AXTextMarker conversion utils under ui umbrella

3342428

* 3353974: Mac: Use base::Feature for overlay features

3353974

* chore: bump chromium in DEPS to 99.0.4828.0

* chore: update patches

* chore: bump chromium in DEPS to 99.0.4837.0

* chore: update patches

* chore: update patches

* 3379142: Drop FALLTHROUGH macro
Ref: 3379142

* 3381749: C++17: Allow use of std::map::try_emplace and std::map::insert_or_assign
Ref: 3381749

* chore: bump chromium in DEPS to 99.0.4839.0

* chore: update patches

* chore: bump chromium in DEPS to 99.0.4840.0

* chore: bump chromium in DEPS to 99.0.4844.0

* 3395881: [api] Deprecate Local<v8::Context> v8::Object::CreationContext()

Ref: 3395881

* chore: update patches

* chore: bump chromium in DEPS to 100.0.4845.0

* chore: update patches

* chore: bump chromium in DEPS to 100.0.4847.0

* chore: update patches

* chore: bump chromium in DEPS to 100.0.4849.0

* chore: update patches

* chore: bump chromium in DEPS to 100.0.4851.0

* chore: bump chromium in DEPS to 100.0.4853.0

* update patches

* chore: update patches

* update patches

* 3383599: Fonts Access: Remove prototype that uses a font picker.

3383599

* 3404768: Remove ALLOW_UNUSED macros

3404768

* 3374762: Remove ignore_result.h

3374762

* 3399305: [unseasoned-pdf] Apply proper frame offsets for touch selections

3399305

* 3402210: [Extensions] Don't trigger unload event for already unloaded extension

3402210

* 3410912: Combine URLLoaderClient OnReceiveResponse and OnStartLoadingResponseBody.

3410912

* 3370428: Make the AuthSchemes policy support dynamic refresh

3370428

* 3407603: Finish ScopedUserPrefUpdate migration to modern base::Value

3407603

* 3378352: ozone/x11: move code from //ui/p/x11 to //ui/ozone/p/x11

3378352

* 3370810: Delete chrome/service, AKA the Cloud Print service process.

3370810

* chore: bump chromium in DEPS to 100.0.4855.0

* chore: update patches

* fixup! 3370810: Delete chrome/service, AKA the Cloud Print service process.

* revert 3348007 to fix windows build

* 3318572: [Code health] Fix gn check errors in //extensions/browser:*

3318572

* fix printing.patch

* fix iwyu issue

* 3408515: win: Make ShorcutOperation an enum class and modernize names

3408515

* 3388333: [UIA] Remove dead code accessibility_misc_utils.h/cc

3388333

* fix windows build? i hope

* patch gn visibility of //ui/ozone/platform/x11

* missing include base/logging.h

* use BUILDFLAG for USE_NSS_CERTS

3379123

* defined(OS_*) ==> BUILDFLAG(IS_*)

https://bugs.chromium.org/p/chromium/issues/detail?id=1234043

* fixup! 3404768: Remove ALLOW_UNUSED macros

* another attempt to fix windows build

* temporarily disable the custom scheme service worker test

https://github.com/electron/electron/issues/32664

* fix loading mv3 extensions

not sure what cl broke this unfort.

* fixup! 3404768: Remove ALLOW_UNUSED macros

* patch nan

3395880

* fix node test

* fix nullptr in FindPdfFrame

* patch perfetto to fix build issue on win-ia32

bc44c3c753

* fix build for linux-x64-testing-no-run-as-node

* fix patch

* skip <webview>.capturePage() test

https://github.com/electron/electron/issues/32705

* test: fix failing tests of focus/blur events of WebContents (#32711)

* inherit stdio from app module test child processes

this prevents them from timing out due to full stdout buffers

* test to see if we can get better logs on windows ci

* try again for appveyor log things

* skip contentTracing tests on ia32

* ci: disable gpu compositing

* drop applied patch

* fix merge fail

* Revert "ci: disable gpu compositing"

This reverts commit 0344129fcb19ea3e87e06c1110d751f22eba3fec.

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: VerteDinde <khammond@slack-corp.com>
Co-authored-by: VerteDinde <vertedinde@electronjs.org>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
electron-roller[bot] 2022-02-09 18:58:52 -08:00 committed by GitHub
parent e9a43be9be
commit 28ada6ea8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
279 changed files with 1681 additions and 2236 deletions

View file

@ -88,9 +88,9 @@ bool IsWidevineAvailable(
// TODO(crbug.com/767941): Push persistent-license support info here once
// we check in a new CDM that supports it on Linux.
session_types_supported->insert(media::CdmSessionType::kTemporary);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS)
session_types_supported->insert(media::CdmSessionType::kPersistentLicense);
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS)
modes_supported->insert(media::EncryptionMode::kCenc);

View file

@ -25,15 +25,15 @@
#include "electron/electron_version.h"
#include "shell/common/electron_paths.h"
#if defined(OS_POSIX) && !defined(OS_MAC)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
#include "components/version_info/version_info_values.h"
#endif
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
#include "base/debug/dump_without_crashing.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/strings/string_util_win.h"
#endif
@ -96,7 +96,7 @@ ElectronCrashReporterClient::ElectronCrashReporterClient() = default;
ElectronCrashReporterClient::~ElectronCrashReporterClient() = default;
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void ElectronCrashReporterClient::SetCrashReporterClientIdFromGUID(
const std::string& client_guid) {
crash_keys::SetMetricsClientIdFromGUID(client_guid);
@ -127,7 +127,7 @@ base::FilePath ElectronCrashReporterClient::GetReporterLogFilename() {
}
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void ElectronCrashReporterClient::GetProductNameAndVersion(
const std::wstring& exe_path,
std::wstring* product_name,
@ -139,7 +139,7 @@ void ElectronCrashReporterClient::GetProductNameAndVersion(
}
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool ElectronCrashReporterClient::GetCrashDumpLocation(
std::wstring* crash_dir_str) {
base::FilePath crash_dir;
@ -173,7 +173,7 @@ bool ElectronCrashReporterClient::GetCollectStatsConsent() {
return collect_stats_consent_;
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool ElectronCrashReporterClient::ReportingIsEnforcedByPolicy(
bool* breakpad_enabled) {
return false;
@ -195,11 +195,11 @@ void ElectronCrashReporterClient::GetProcessSimpleAnnotations(
(*annotations)["ver"] = ELECTRON_VERSION_STRING;
}
#if defined(OS_LINUX) || defined(OS_MAC)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)
bool ElectronCrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
return false;
}
#endif // OS_LINUX
#endif
std::string ElectronCrashReporterClient::GetUploadUrl() {
return upload_url_;

View file

@ -31,7 +31,7 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
const std::map<std::string, std::string>& annotations);
// crash_reporter::CrashReporterClient implementation.
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void SetCrashReporterClientIdFromGUID(
const std::string& client_guid) override;
void GetProductNameAndVersion(const char** product_name,
@ -42,7 +42,7 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
base::FilePath GetReporterLogFilename() override;
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void GetProductNameAndVersion(const std::wstring& exe_path,
std::wstring* product_name,
std::wstring* version,
@ -50,7 +50,7 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
std::wstring* channel_name) override;
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool GetCrashDumpLocation(std::wstring* crash_dir) override;
#else
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
@ -66,11 +66,11 @@ class ElectronCrashReporterClient : public crash_reporter::CrashReporterClient {
void GetProcessSimpleAnnotations(
std::map<std::string, std::string>* annotations) override;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) override;
#endif
#if defined(OS_MAC) || defined(OS_LINUX)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
bool ShouldMonitorCrashHandlerExpensively() override;
#endif

View file

@ -8,7 +8,7 @@
#include "build/build_config.h"
#include "electron/buildflags/buildflags.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
extern "C" {
__attribute__((visibility("default"))) int ElectronMain(int argc, char* argv[]);
@ -18,6 +18,6 @@ __attribute__((visibility("default"))) int ElectronInitializeICUandStartNode(
char* argv[]);
#endif
}
#endif // OS_MAC
#endif
#endif // ELECTRON_SHELL_APP_ELECTRON_LIBRARY_MAIN_H_

View file

@ -43,16 +43,16 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "shell/app/electron_main_delegate_mac.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/win/win_util.h"
#include "chrome/child/v8_crashpad_support_win.h"
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "base/nix/xdg_util.h"
#include "components/crash/core/app/breakpad_linux.h"
#include "v8/include/v8-wasm-trap-handler-posix.h"
@ -88,11 +88,11 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
// and resources loaded.
bool SubprocessNeedsResourceBundle(const std::string& process_type) {
return
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// The zygote process opens the resources for the renderers.
process_type == ::switches::kZygoteProcess ||
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Mac needs them too for scrollbar related images and for sandbox
// profiles.
process_type == ::switches::kGpuProcess ||
@ -102,7 +102,7 @@ bool SubprocessNeedsResourceBundle(const std::string& process_type) {
process_type == ::switches::kUtilityProcess;
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void InvalidParameterHandler(const wchar_t*,
const wchar_t*,
const wchar_t*,
@ -139,7 +139,7 @@ bool ElectronPathProvider(int key, base::FilePath* result) {
create_dir = true;
break;
case DIR_USER_CACHE: {
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
int parent_key = base::DIR_CACHE;
#else
// On Windows, there's no OS-level centralized location for caches, so
@ -153,7 +153,7 @@ bool ElectronPathProvider(int key, base::FilePath* result) {
create_dir = true;
break;
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
case DIR_APP_DATA: {
auto env = base::Environment::Create();
cur = base::nix::GetXDGDirectory(
@ -161,7 +161,7 @@ bool ElectronPathProvider(int key, base::FilePath* result) {
break;
}
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
case DIR_RECENT:
if (!platform_util::GetFolderPath(DIR_RECENT, &cur))
return false;
@ -169,7 +169,7 @@ bool ElectronPathProvider(int key, base::FilePath* result) {
break;
#endif
case DIR_APP_LOGS:
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (!base::PathService::Get(base::DIR_HOME, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("Library"));
@ -211,7 +211,7 @@ std::string LoadResourceBundle(const std::string& locale) {
// Load other resource files.
base::FilePath pak_dir;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
pak_dir =
base::mac::FrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources"));
#else
@ -238,14 +238,14 @@ const size_t ElectronMainDelegate::kNonWildcardDomainNonPortSchemesSize =
bool ElectronMainDelegate::BasicStartupComplete(int* exit_code) {
auto* command_line = base::CommandLine::ForCurrentProcess();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
v8_crashpad_support::SetUp();
// On Windows the terminal returns immediately, so we add a new line to
// prevent output in the same line as the prompt.
if (IsBrowserProcess(command_line))
std::wcout << std::endl;
#endif // !defined(OS_WIN)
#endif // !BUILDFLAG(IS_WIN)
auto env = base::Environment::Create();
@ -268,13 +268,13 @@ bool ElectronMainDelegate::BasicStartupComplete(int* exit_code) {
kNonWildcardDomainNonPortSchemes, kNonWildcardDomainNonPortSchemesSize);
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
OverrideChildProcessPath();
OverrideFrameworkBundlePath();
SetUpBundleOverrides();
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Ignore invalid parameter errors.
_set_invalid_parameter_handler(InvalidParameterHandler);
// Disable the ActiveVerifier, which is used by Chrome to track possible
@ -285,7 +285,7 @@ bool ElectronMainDelegate::BasicStartupComplete(int* exit_code) {
base::win::PinUser32();
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// Check for --no-sandbox parameter when running as root.
if (getuid() == 0 && IsSandboxEnabled(command_line))
LOG(FATAL) << "Running as root without --"
@ -327,7 +327,7 @@ void ElectronMainDelegate::PreSandboxStartup() {
user_data_dir, false, true);
}
#if !defined(OS_WIN)
#if !BUILDFLAG(IS_WIN)
// For windows we call InitLogging later, after the sandbox is initialized.
//
// On Linux, we force a "preinit" in the zygote (i.e. never log to a default
@ -352,7 +352,7 @@ void ElectronMainDelegate::PreSandboxStartup() {
LoadResourceBundle(locale);
}
#if defined(OS_WIN) || (defined(OS_MAC) && !defined(MAS_BUILD))
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !defined(MAS_BUILD))
// In the main process, we wait for JS to call crashReporter.start() before
// initializing crashpad. If we're in the renderer, we want to initialize it
// immediately at boot.
@ -362,7 +362,7 @@ void ElectronMainDelegate::PreSandboxStartup() {
}
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// Zygote needs to call InitCrashReporter() in RunZygote().
if (process_type != ::switches::kZygoteProcess && !process_type.empty()) {
ElectronCrashReporterClient::Create();
@ -390,7 +390,7 @@ void ElectronMainDelegate::PreSandboxStartup() {
// Allow file:// URIs to read other file:// URIs by default.
command_line->AppendSwitch(::switches::kAllowFileAccessFromFiles);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Enable AVFoundation.
command_line->AppendSwitch("enable-avfoundation");
#endif
@ -398,7 +398,7 @@ void ElectronMainDelegate::PreSandboxStartup() {
}
void ElectronMainDelegate::SandboxInitialized(const std::string& process_type) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
logging::InitElectronLogging(*base::CommandLine::ForCurrentProcess(),
/* is_preinit = */ process_type.empty());
#endif
@ -409,7 +409,7 @@ void ElectronMainDelegate::PreBrowserMain() {
// flags and we need to make sure the feature list is initialized before the
// service manager reads the features.
InitializeFeatureList();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
RegisterAtomCrApp();
#endif
}
@ -462,7 +462,7 @@ bool ElectronMainDelegate::ShouldLockSchemeRegistry() {
return false;
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void ElectronMainDelegate::ZygoteForked() {
// Needs to be called after we have DIR_USER_DATA. BrowserMain sets
// this up for the browser process in a different manner.
@ -485,6 +485,6 @@ void ElectronMainDelegate::ZygoteForked() {
// Reset the command line for the newly spawned process.
crash_keys::SetCrashKeysFromCommandLine(*command_line);
}
#endif // defined(OS_LINUX)
#endif // BUILDFLAG(IS_LINUX)
} // namespace electron

View file

@ -45,12 +45,12 @@ class ElectronMainDelegate : public content::ContentMainDelegate {
content::MainFunctionParams main_function_params) override;
bool ShouldCreateFeatureList() override;
bool ShouldLockSchemeRegistry() override;
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void ZygoteForked() override;
#endif
private:
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void OverrideChildProcessPath();
void OverrideFrameworkBundlePath();
void SetUpBundleOverrides();

View file

@ -18,20 +18,13 @@
#include "shell/common/electron_command_line.h"
#include "shell/common/electron_constants.h"
namespace {
ALLOW_UNUSED_TYPE bool IsEnvSet(const char* name) {
char* indicator = getenv(name);
return indicator && indicator[0] != '\0';
}
} // namespace
int main(int argc, char* argv[]) {
FixStdioStreams();
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
if (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
char* indicator = getenv(electron::kRunAsNode);
if (electron::fuses::IsRunAsNodeEnabled() && indicator &&
indicator[0] != '\0') {
base::i18n::InitializeICU();
base::AtExitManager atexit_manager;
return electron::NodeMain(argc, argv);

View file

@ -20,7 +20,7 @@
namespace {
ALLOW_UNUSED_TYPE bool IsEnvSet(const char* name) {
bool IsEnvSet(const char* name) {
char* indicator = getenv(name);
return indicator && indicator[0] != '\0';
}

View file

@ -44,7 +44,7 @@ namespace {
const char kUserDataDir[] = "user-data-dir";
const char kProcessType[] = "type";
ALLOW_UNUSED_TYPE bool IsEnvSet(const char* name) {
bool IsEnvSet(const char* name) {
size_t required_size;
getenv_s(&required_size, nullptr, 0, name);
return required_size != 0;

View file

@ -30,11 +30,11 @@
#include "shell/common/node_bindings.h"
#include "shell/common/node_includes.h"
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "components/crash/core/app/breakpad_linux.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "chrome/child/v8_crashpad_support_win.h"
#endif
@ -65,7 +65,7 @@ int SetNodeCliFlags() {
args.emplace_back("electron");
for (const auto& arg : argv) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
const auto& option = base::WideToUTF8(arg);
#else
const auto& option = arg;
@ -100,7 +100,7 @@ void ClearCrashKeyStub(const std::string& key) {}
namespace electron {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void CrashReporterStart(gin_helper::Dictionary options) {
std::string submit_url;
bool upload_to_server = true;
@ -140,7 +140,7 @@ v8::Local<v8::Value> GetParameters(v8::Isolate* isolate) {
int NodeMain(int argc, char* argv[]) {
base::CommandLine::Init(argc, argv);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
v8_crashpad_support::SetUp();
#endif
@ -148,7 +148,7 @@ int NodeMain(int argc, char* argv[]) {
ElectronCrashReporterClient::Create();
#endif
#if defined(OS_WIN) || (defined(OS_MAC) && !defined(MAS_BUILD))
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !defined(MAS_BUILD))
crash_reporter::InitializeCrashpad(false, "node");
#endif
@ -225,7 +225,7 @@ int NodeMain(int argc, char* argv[]) {
// Setup process.crashReporter in child node processes
gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate);
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
reporter.SetMethod("start", &CrashReporterStart);
#endif

View file

@ -8,11 +8,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <cstdio>
// Copied from //base/ignore_result.h to avoid taking a dependency on //base on
// macOS.
template <typename T>
inline void ignore_result(const T&) {}
#include <tuple>
void FixStdioStreams() {
// libuv may mark stdin/stdout/stderr as close-on-exec, which interferes
@ -24,9 +20,9 @@ void FixStdioStreams() {
// For details see https://github.com/libuv/libuv/issues/2062
struct stat st;
if (fstat(STDIN_FILENO, &st) < 0 && errno == EBADF)
ignore_result(freopen("/dev/null", "r", stdin));
std::ignore = freopen("/dev/null", "r", stdin);
if (fstat(STDOUT_FILENO, &st) < 0 && errno == EBADF)
ignore_result(freopen("/dev/null", "w", stdout));
std::ignore = freopen("/dev/null", "w", stdout);
if (fstat(STDERR_FILENO, &st) < 0 && errno == EBADF)
ignore_result(freopen("/dev/null", "w", stderr));
std::ignore = freopen("/dev/null", "w", stderr);
}

View file

@ -32,6 +32,7 @@
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/content_switches.h"
#include "crypto/crypto_buildflags.h"
#include "media/audio/audio_manager.h"
#include "net/dns/public/dns_over_https_server_config.h"
#include "net/dns/public/util.h"
@ -70,12 +71,12 @@
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/image/image.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/strings/utf_string_conversions.h"
#include "shell/browser/ui/win/jump_list.h"
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "shell/browser/ui/cocoa/electron_bundle_mover.h"
#endif
@ -84,7 +85,7 @@ using electron::Browser;
namespace gin {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
template <>
struct Converter<electron::ProcessIntegrityLevel> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
@ -346,7 +347,7 @@ struct Converter<JumpListResult> {
};
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
template <>
struct Converter<Browser::LaunchItem> {
static bool FromV8(v8::Isolate* isolate,
@ -390,7 +391,7 @@ struct Converter<Browser::LoginItemSettings> {
dict.Get("openAsHidden", &(out->open_as_hidden));
dict.Get("path", &(out->path));
dict.Get("args", &(out->args));
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
dict.Get("enabled", &(out->enabled));
dict.Get("name", &(out->name));
#endif
@ -405,7 +406,7 @@ struct Converter<Browser::LoginItemSettings> {
dict.Set("restoreState", val.restore_state);
dict.Set("wasOpenedAtLogin", val.opened_at_login);
dict.Set("wasOpenedAsHidden", val.opened_as_hidden);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
dict.Set("launchItems", val.launch_items);
dict.Set("executableWillLaunchAtLogin",
val.executable_will_launch_at_login);
@ -475,7 +476,7 @@ int GetPathConstant(const std::string& name) {
else if (name == "userData")
return chrome::DIR_USER_DATA;
else if (name == "cache")
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
return base::DIR_CACHE;
#else
return base::DIR_ROAMING_APP_DATA;
@ -506,7 +507,7 @@ int GetPathConstant(const std::string& name) {
return chrome::DIR_USER_PICTURES;
else if (name == "videos")
return chrome::DIR_USER_VIDEOS;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
else if (name == "recent")
return electron::DIR_RECENT;
#endif
@ -597,7 +598,7 @@ void OnClientCertificateSelected(
}
}
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
int ImportIntoCertStore(CertificateManagerModel* model, base::Value options) {
std::string file_data, cert_path;
std::u16string password;
@ -706,7 +707,7 @@ void App::OnWillFinishLaunching() {
}
void App::OnFinishLaunching(const base::DictionaryValue& launch_info) {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// Set the application name for audio streams shown in external
// applications. Only affects pulseaudio currently.
media::AudioManager::SetGlobalAppName(Browser::Get()->GetName());
@ -740,7 +741,7 @@ void App::OnAccessibilitySupportChanged() {
Emit("accessibility-support-changed", IsAccessibilitySupportEnabled());
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void App::OnWillContinueUserActivity(bool* prevent_default,
const std::string& type) {
if (Emit("will-continue-activity", type)) {
@ -940,7 +941,7 @@ void App::ChildProcessLaunched(int process_type,
base::ProcessHandle handle,
const std::string& service_name,
const std::string& name) {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
auto metrics = base::ProcessMetrics::CreateProcessMetrics(
handle, content::BrowserChildProcessHost::GetPortProvider());
#else
@ -962,7 +963,7 @@ void App::SetAppPath(const base::FilePath& app_path) {
app_path_ = app_path;
}
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
absl::optional<base::FilePath> custom_path) {
if (custom_path.has_value()) {
@ -998,7 +999,7 @@ bool App::IsPackaged() {
base::FilePath::StringType base_name =
base::ToLowerASCII(exe_path.BaseName().value());
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return base_name != FILE_PATH_LITERAL("electron.exe");
#else
return base_name != FILE_PATH_LITERAL("electron");
@ -1031,7 +1032,7 @@ void App::SetPath(gin_helper::ErrorThrower thrower,
}
void App::SetDesktopName(const std::string& desktop_name) {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
auto env = base::Environment::Create();
env->SetVar("CHROME_DESKTOP", desktop_name);
#endif
@ -1043,7 +1044,7 @@ std::string App::GetLocale() {
std::string App::GetLocaleCountryCode() {
std::string region;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
WCHAR locale_name[LOCALE_NAME_MAX_LENGTH] = {0};
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME,
@ -1054,7 +1055,7 @@ std::string App::GetLocaleCountryCode() {
sizeof(locale_name) / sizeof(WCHAR))) {
base::WideToUTF8(locale_name, wcslen(locale_name), &region);
}
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
CFLocaleRef locale = CFLocaleCopyCurrent();
CFStringRef value = CFStringRef(
static_cast<CFTypeRef>(CFLocaleGetValue(locale, kCFLocaleCountryCode)));
@ -1155,7 +1156,7 @@ bool App::RequestSingleInstanceLock(gin::Arguments* args) {
blink::CloneableMessage additional_data_message;
args->GetNext(&additional_data_message);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool app_is_sandboxed =
IsSandboxEnabled(base::CommandLine::ForCurrentProcess());
process_singleton_ = std::make_unique<ProcessSingleton>(
@ -1278,7 +1279,7 @@ Browser::LoginItemSettings App::GetLoginItemSettings(gin::Arguments* args) {
return Browser::Get()->GetLoginItemSettings(options);
}
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
void App::ImportCertificate(gin_helper::ErrorThrower thrower,
base::Value options,
net::CompletionOnceCallback callback) {
@ -1313,7 +1314,7 @@ void App::OnCertificateManagerModelCreated(
}
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
v8::Local<v8::Value> App::GetJumpListSettings() {
JumpList jump_list(Browser::Get()->GetAppUserModelID());
@ -1369,7 +1370,7 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
return result;
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
v8::Local<v8::Promise> App::GetFileIcon(const base::FilePath& path,
gin::Arguments* args) {
@ -1418,7 +1419,7 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
process_metric.second->metrics->GetPlatformIndependentCPUUsage() /
processor_count);
#if !defined(OS_WIN)
#if !BUILDFLAG(IS_WIN)
cpu_dict.Set("idleWakeupsPerSecond",
process_metric.second->metrics->GetIdleWakeupsPerSecond());
#else
@ -1443,7 +1444,7 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
pid_dict.Set("name", process_metric.second->name);
}
#if !defined(OS_LINUX)
#if !BUILDFLAG(IS_LINUX)
auto memory_info = process_metric.second->GetMemoryInfo();
gin_helper::Dictionary memory_dict = gin::Dictionary::CreateEmpty(isolate);
@ -1454,7 +1455,7 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
"peakWorkingSetSize",
static_cast<double>(memory_info.peak_working_set_size >> 10));
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
memory_dict.Set("privateBytes",
static_cast<double>(memory_info.private_bytes >> 10));
#endif
@ -1462,9 +1463,9 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
pid_dict.Set("memory", memory_dict);
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
pid_dict.Set("sandboxed", process_metric.second->IsSandboxed());
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
auto integrity_level = process_metric.second->GetIntegrityLevel();
auto sandboxed = ProcessMetric::IsSandboxed(integrity_level);
pid_dict.Set("integrityLevel", integrity_level);
@ -1499,7 +1500,7 @@ v8::Local<v8::Promise> App::GetGPUInfo(v8::Isolate* isolate,
auto* const info_mgr = GPUInfoManager::GetInstance();
if (info_type == "complete") {
#if defined(OS_WIN) || defined(OS_MAC)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
info_mgr->FetchCompleteInfo(std::move(promise));
#else
info_mgr->FetchBasicInfo(std::move(promise));
@ -1541,7 +1542,7 @@ void App::SetUserAgentFallback(const std::string& user_agent) {
ElectronBrowserClient::Get()->SetUserAgent(user_agent);
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool App::IsRunningUnderARM64Translation() const {
USHORT processMachine = 0;
@ -1566,7 +1567,7 @@ std::string App::GetUserAgentFallback() {
return ElectronBrowserClient::Get()->GetUserAgent();
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool App::MoveToApplicationsFolder(gin_helper::ErrorThrower thrower,
gin::Arguments* args) {
return ElectronBundleMover::Move(thrower, args);
@ -1732,7 +1733,7 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
base::BindRepeating(&Browser::AddRecentDocument, browser))
.SetMethod("clearRecentDocuments",
base::BindRepeating(&Browser::ClearRecentDocuments, browser))
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
.SetMethod("setAppUserModelId",
base::BindRepeating(&Browser::SetAppUserModelID, browser))
#endif
@ -1745,7 +1746,7 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
.SetMethod(
"removeAsDefaultProtocolClient",
base::BindRepeating(&Browser::RemoveAsDefaultProtocolClient, browser))
#if !defined(OS_LINUX)
#if !BUILDFLAG(IS_LINUX)
.SetMethod(
"getApplicationInfoForProtocol",
base::BindRepeating(&Browser::GetApplicationInfoForProtocol, browser))
@ -1762,7 +1763,7 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
base::BindRepeating(&Browser::SetLoginItemSettings, browser))
.SetMethod("isEmojiPanelSupported",
base::BindRepeating(&Browser::IsEmojiPanelSupported, browser))
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
.SetMethod("hide", base::BindRepeating(&Browser::Hide, browser))
.SetMethod("show", base::BindRepeating(&Browser::Show, browser))
.SetMethod("setUserActivity",
@ -1784,7 +1785,7 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
base::BindRepeating(&Browser::SetAboutPanelOptions, browser))
.SetMethod("showAboutPanel",
base::BindRepeating(&Browser::ShowAboutPanel, browser))
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
.SetMethod(
"isSecureKeyboardEntryEnabled",
base::BindRepeating(&Browser::IsSecureKeyboardEntryEnabled, browser))
@ -1792,17 +1793,17 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
"setSecureKeyboardEntryEnabled",
base::BindRepeating(&Browser::SetSecureKeyboardEntryEnabled, browser))
#endif
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
.SetMethod("showEmojiPanel",
base::BindRepeating(&Browser::ShowEmojiPanel, browser))
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
.SetMethod("setUserTasks",
base::BindRepeating(&Browser::SetUserTasks, browser))
.SetMethod("getJumpListSettings", &App::GetJumpListSettings)
.SetMethod("setJumpList", &App::SetJumpList)
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
.SetMethod("isUnityRunning",
base::BindRepeating(&Browser::IsUnityRunning, browser))
#endif
@ -1815,7 +1816,7 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
.SetMethod("setDesktopName", &App::SetDesktopName)
.SetMethod("getLocale", &App::GetLocale)
.SetMethod("getLocaleCountryCode", &App::GetLocaleCountryCode)
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
.SetMethod("importCertificate", &App::ImportCertificate)
#endif
.SetMethod("hasSingleInstanceLock", &App::HasSingleInstanceLock)
@ -1838,12 +1839,12 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
.SetMethod("startAccessingSecurityScopedResource",
&App::StartAccessingSecurityScopedResource)
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
.SetProperty("dock", &App::GetDockAPI)
.SetProperty("runningUnderRosettaTranslation",
&App::IsRunningUnderRosettaTranslation)
#endif
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
.SetProperty("runningUnderARM64Translation",
&App::IsRunningUnderARM64Translation)
#endif

View file

@ -16,6 +16,7 @@
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/gpu_data_manager_observer.h"
#include "content/public/browser/render_process_host.h"
#include "crypto/crypto_buildflags.h"
#include "gin/handle.h"
#include "net/base/completion_once_callback.h"
#include "net/base/completion_repeating_callback.h"
@ -29,7 +30,7 @@
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/promise.h"
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
#include "shell/browser/certificate_manager_model.h"
#endif
@ -39,7 +40,7 @@ class FilePath;
namespace electron {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
enum class JumpListResult : int;
#endif
@ -64,7 +65,7 @@ class App : public ElectronBrowserClient::Delegate,
v8::Isolate* isolate) override;
const char* GetTypeName() override;
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
void OnCertificateManagerModelCreated(
base::Value options,
net::CompletionOnceCallback callback,
@ -99,7 +100,7 @@ class App : public ElectronBrowserClient::Delegate,
void OnAccessibilitySupportChanged() override;
void OnPreMainMessageLoopRun() override;
void OnPreCreateThreads() override;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void OnWillContinueUserActivity(bool* prevent_default,
const std::string& type) override;
void OnDidFailToContinueUserActivity(const std::string& type,
@ -208,7 +209,7 @@ class App : public ElectronBrowserClient::Delegate,
void SetAccessibilitySupportEnabled(gin_helper::ErrorThrower thrower,
bool enabled);
Browser::LoginItemSettings GetLoginItemSettings(gin::Arguments* args);
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
void ImportCertificate(gin_helper::ErrorThrower thrower,
base::Value options,
net::CompletionOnceCallback callback);
@ -224,7 +225,7 @@ class App : public ElectronBrowserClient::Delegate,
void SetUserAgentFallback(const std::string& user_agent);
std::string GetUserAgentFallback();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void SetActivationPolicy(gin_helper::ErrorThrower thrower,
const std::string& policy);
bool MoveToApplicationsFolder(gin_helper::ErrorThrower, gin::Arguments* args);
@ -234,7 +235,7 @@ class App : public ElectronBrowserClient::Delegate,
v8::Global<v8::Value> dock_;
#endif
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
bool IsRunningUnderARM64Translation() const;
#endif
@ -243,17 +244,17 @@ class App : public ElectronBrowserClient::Delegate,
gin::Arguments* args);
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Get the current Jump List settings.
v8::Local<v8::Value> GetJumpListSettings();
// Set or remove a custom Jump List for the application.
JumpListResult SetJumpList(v8::Local<v8::Value> val, gin::Arguments* args);
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
std::unique_ptr<ProcessSingleton> process_singleton_;
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
std::unique_ptr<CertificateManagerModel> certificate_manager_model_;
#endif

View file

@ -32,12 +32,12 @@
#include "shell/browser/native_window_views.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "shell/browser/ui/win/taskbar_host.h"
#include "ui/base/win/shell.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
namespace gin {
template <>
@ -305,7 +305,7 @@ void BaseWindow::OnSystemContextMenu(int x, int y, bool* prevent_default) {
}
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void BaseWindow::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
if (IsWindowMessageHooked(message)) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
@ -875,7 +875,7 @@ void BaseWindow::SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value) {
window_->SetVibrancy(type);
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
std::string BaseWindow::GetAlwaysOnTopLevel() {
return window_->GetAlwaysOnTopLevel();
}
@ -1028,7 +1028,7 @@ bool BaseWindow::IsModal() const {
}
bool BaseWindow::SetThumbarButtons(gin_helper::Arguments* args) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
std::vector<TaskbarHost::ThumbarButton> buttons;
if (!args->GetNext(&buttons)) {
args->ThrowError();
@ -1055,18 +1055,18 @@ void BaseWindow::SetIconImpl(v8::Isolate* isolate,
on_error))
return;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
static_cast<NativeWindowViews*>(window_.get())
->SetIcon(native_image->GetHICON(GetSystemMetrics(SM_CXSMICON)),
native_image->GetHICON(GetSystemMetrics(SM_CXICON)));
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
static_cast<NativeWindowViews*>(window_.get())
->SetIcon(native_image->image().AsImageSkia());
#endif
}
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool BaseWindow::HookWindowMessage(UINT message,
const MessageCallback& callback) {
messages_callback_map_[message] = callback;
@ -1266,12 +1266,12 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate,
&BaseWindow::SetVisibleOnAllWorkspaces)
.SetMethod("isVisibleOnAllWorkspaces",
&BaseWindow::IsVisibleOnAllWorkspaces)
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
.SetMethod("_getAlwaysOnTopLevel", &BaseWindow::GetAlwaysOnTopLevel)
.SetMethod("setAutoHideCursor", &BaseWindow::SetAutoHideCursor)
#endif
.SetMethod("setVibrancy", &BaseWindow::SetVibrancy)
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
.SetMethod("setTrafficLightPosition",
&BaseWindow::SetTrafficLightPosition)
.SetMethod("getTrafficLightPosition",
@ -1280,7 +1280,7 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("_setTouchBarItems", &BaseWindow::SetTouchBar)
.SetMethod("_refreshTouchBarItem", &BaseWindow::RefreshTouchBarItem)
.SetMethod("_setEscapeTouchBarItem", &BaseWindow::SetEscapeTouchBarItem)
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
.SetMethod("selectPreviousTab", &BaseWindow::SelectPreviousTab)
.SetMethod("selectNextTab", &BaseWindow::SelectNextTab)
.SetMethod("mergeAllWindows", &BaseWindow::MergeAllWindows)
@ -1312,7 +1312,7 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate,
#if defined(TOOLKIT_VIEWS)
.SetMethod("setIcon", &BaseWindow::SetIcon)
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
.SetMethod("hookWindowMessage", &BaseWindow::HookWindowMessage)
.SetMethod("isWindowMessageHooked", &BaseWindow::IsWindowMessageHooked)
.SetMethod("unhookWindowMessage", &BaseWindow::UnhookWindowMessage)

View file

@ -86,7 +86,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
const base::DictionaryValue& details) override;
void OnNewWindowForTab() override;
void OnSystemContextMenu(int x, int y, bool* prevent_default) override;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) override;
#endif
@ -193,7 +193,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
void SetAutoHideCursor(bool auto_hide);
virtual void SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
std::string GetAlwaysOnTopLevel();
void SetWindowButtonVisibility(bool visible);
bool GetWindowButtonVisibility() const;
@ -234,7 +234,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
v8::Local<v8::Value> icon,
NativeImage::OnConvertError on_error);
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
typedef base::RepeatingCallback<void(v8::Local<v8::Value>,
v8::Local<v8::Value>)>
MessageCallback;
@ -264,7 +264,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
weak_factory_.GetWeakPtr(), eventName));
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
typedef std::map<UINT, MessageCallback> MessageCallbackMap;
MessageCallbackMap messages_callback_map_;
#endif

View file

@ -41,7 +41,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
options.Get(options::kTransparent, &transparent);
std::string vibrancy_type;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
options.Get(options::kVibrancyType, &vibrancy_type);
#endif
@ -109,7 +109,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
// Install the content view after BaseWindow's JS code is initialized.
SetContentView(gin::CreateHandle<View>(isolate, web_contents_view.get()));
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
OverrideNSWindowContentView(
web_contents->inspectable_web_contents()->GetView());
#endif
@ -219,7 +219,7 @@ void BrowserWindow::OnSetContentBounds(const gfx::Rect& rect) {
void BrowserWindow::OnActivateContents() {
// Hide the auto-hide menu when webContents is focused.
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
if (IsMenuBarAutoHide() && IsMenuBarVisible())
window()->SetMenuBarVisibility(false);
#endif
@ -294,7 +294,7 @@ void BrowserWindow::OnWindowFocus() {
// focus/blur events might be emitted while closing window.
if (api_web_contents_) {
web_contents()->RestoreFocus();
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
if (!api_web_contents_->IsDevToolsOpened())
web_contents()->Focus();
#endif
@ -304,7 +304,7 @@ void BrowserWindow::OnWindowFocus() {
}
void BrowserWindow::OnWindowIsKeyChanged(bool is_key) {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
auto* rwhv = web_contents()->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetActive(is_key);
@ -313,7 +313,7 @@ void BrowserWindow::OnWindowIsKeyChanged(bool is_key) {
}
void BrowserWindow::OnWindowResize() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (!draggable_regions_.empty()) {
UpdateDraggableRegions(draggable_regions_);
} else {
@ -326,7 +326,7 @@ void BrowserWindow::OnWindowResize() {
}
void BrowserWindow::OnWindowLeaveFullScreen() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (web_contents()->IsFullscreen())
web_contents()->ExitFullscreen(true);
#endif
@ -392,21 +392,21 @@ void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
void BrowserWindow::SetBrowserView(v8::Local<v8::Value> value) {
BaseWindow::ResetBrowserViews();
BaseWindow::AddBrowserView(value);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
UpdateDraggableRegions(draggable_regions_);
#endif
}
void BrowserWindow::AddBrowserView(v8::Local<v8::Value> value) {
BaseWindow::AddBrowserView(value);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
UpdateDraggableRegions(draggable_regions_);
#endif
}
void BrowserWindow::RemoveBrowserView(v8::Local<v8::Value> value) {
BaseWindow::RemoveBrowserView(value);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
UpdateDraggableRegions(draggable_regions_);
#endif
}
@ -414,14 +414,14 @@ void BrowserWindow::RemoveBrowserView(v8::Local<v8::Value> value) {
void BrowserWindow::SetTopBrowserView(v8::Local<v8::Value> value,
gin_helper::Arguments* args) {
BaseWindow::SetTopBrowserView(value, args);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
UpdateDraggableRegions(draggable_regions_);
#endif
}
void BrowserWindow::ResetBrowserViews() {
BaseWindow::ResetBrowserViews();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
UpdateDraggableRegions(draggable_regions_);
#endif
}

View file

@ -101,7 +101,7 @@ class BrowserWindow : public BaseWindow,
v8::Local<v8::Value> GetWebContents(v8::Isolate* isolate);
private:
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void OverrideNSWindowContentView(InspectableWebContentsView* webView);
#endif

View file

@ -38,7 +38,7 @@
#include "third_party/crashpad/crashpad/client/crashpad_info.h" // nogncheck
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "base/containers/span.h"
#include "base/files/file_util.h"
#include "base/guid.h"
@ -51,13 +51,13 @@
namespace {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
std::map<std::string, std::string>& GetGlobalCrashKeysMutable() {
static base::NoDestructor<std::map<std::string, std::string>>
global_crash_keys;
return *global_crash_keys;
}
#endif // defined(OS_LINUX)
#endif // BUILDFLAG(IS_LINUX)
bool g_crash_reporter_initialized = false;
@ -81,7 +81,7 @@ bool IsCrashReporterEnabled() {
return g_crash_reporter_initialized;
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
const std::map<std::string, std::string>& GetGlobalCrashKeys() {
return GetGlobalCrashKeysMutable();
}
@ -150,7 +150,7 @@ void Start(const std::string& submit_url,
is_node_process
? "node"
: command_line->GetSwitchValueASCII(::switches::kProcessType);
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
if (::crash_reporter::IsCrashpadEnabled()) {
for (const auto& pair : extra)
electron::crash_keys::SetCrashKey(pair.first, pair.second);
@ -174,7 +174,7 @@ void Start(const std::string& submit_url,
electron::crash_keys::SetCrashKey(pair.first, pair.second);
breakpad::InitCrashReporter(process_type);
}
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
for (const auto& pair : extra)
electron::crash_keys::SetCrashKey(pair.first, pair.second);
::crash_reporter::InitializeCrashpad(process_type.empty(), process_type);
@ -182,7 +182,7 @@ void Start(const std::string& submit_url,
crashpad::CrashpadInfo::GetCrashpadInfo()
->set_system_crash_reporter_forwarding(crashpad::TriState::kDisabled);
}
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
for (const auto& pair : extra)
electron::crash_keys::SetCrashKey(pair.first, pair.second);
base::FilePath user_data_dir;
@ -210,7 +210,7 @@ void GetUploadedReports(
}
#else
scoped_refptr<UploadList> CreateCrashUploadList() {
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
return base::MakeRefCounted<CrashUploadListCrashpad>();
#else
base::FilePath crash_dir_path;
@ -231,7 +231,7 @@ scoped_refptr<UploadList> CreateCrashUploadList() {
result = base::MakeRefCounted<CombiningUploadList>(std::move(uploaders));
}
return result;
#endif // defined(OS_MAC) || defined(OS_WIN)
#endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
}
v8::Local<v8::Value> GetUploadedReports(v8::Isolate* isolate) {

View file

@ -17,7 +17,7 @@ namespace crash_reporter {
bool IsCrashReporterEnabled();
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
const std::map<std::string, std::string>& GetGlobalCrashKeys();
std::string GetClientId();
#endif

View file

@ -24,11 +24,11 @@
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h"
#include "third_party/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
#include "ui/display/win/display_info.h"
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
namespace gin {
@ -74,7 +74,7 @@ void DesktopCapturer::StartHandling(bool capture_window,
const gfx::Size& thumbnail_size,
bool fetch_window_icons) {
fetch_window_icons_ = fetch_window_icons;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (content::desktop_capture::CreateDesktopCaptureOptions()
.allow_directx_capturer()) {
// DxgiDuplicatorController should be alive in this scope according to
@ -82,7 +82,7 @@ void DesktopCapturer::StartHandling(bool capture_window,
auto duplicator = webrtc::DxgiDuplicatorController::Instance();
using_directx_capturer_ = webrtc::ScreenCapturerWinDirectx::IsSupported();
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
// clear any existing captured sources.
captured_sources_.clear();
@ -143,7 +143,7 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
screen_sources.emplace_back(
DesktopCapturer::Source{list->GetSource(i), std::string()});
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Gather the same unique screen IDs used by the electron.screen API in
// order to provide an association between it and
// desktopCapturer/getUserMedia. This is only required when using the
@ -176,12 +176,12 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
source.display_id = base::NumberToString(device_id);
}
}
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
// On Mac, the IDs across the APIs match.
for (auto& source : screen_sources) {
source.display_id = base::NumberToString(source.media_list_source.id.id);
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
// TODO(ajmacd): Add Linux support. The IDs across APIs differ but Chrome
// only supports capturing the entire desktop on Linux. Revisit this if
// individual screen support is added.

View file

@ -70,9 +70,9 @@ class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
bool capture_window_ = false;
bool capture_screen_ = false;
bool fetch_window_icons_ = false;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool using_directx_capturer_ = false;
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
base::WeakPtrFactory<DesktopCapturer> weak_ptr_factory_{this};
};

View file

@ -97,7 +97,7 @@ void Initialize(v8::Local<v8::Object> exports,
dict.SetMethod("showOpenDialog", &ShowOpenDialog);
dict.SetMethod("showSaveDialogSync", &ShowSaveDialogSync);
dict.SetMethod("showSaveDialog", &ShowSaveDialog);
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
dict.SetMethod("showCertificateTrustDialog",
&certificate_trust::ShowCertificateTrust);
#endif

View file

@ -18,7 +18,7 @@
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/node_includes.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "base/mac/mac_util.h"
#endif
@ -27,7 +27,7 @@ using extensions::GlobalShortcutListener;
namespace {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool RegisteringMediaKeyForUntrustedClient(const ui::Accelerator& accelerator) {
if (base::mac::IsAtLeastOS10_14()) {
if (Command::IsMediaKey(accelerator)) {
@ -103,7 +103,7 @@ bool GlobalShortcut::Register(const ui::Accelerator& accelerator,
.ThrowError("globalShortcut cannot be used before the app is ready");
return false;
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (Command::IsMediaKey(accelerator)) {
if (RegisteringMediaKeyForUntrustedClient(accelerator))
return false;
@ -130,7 +130,7 @@ void GlobalShortcut::Unregister(const ui::Accelerator& accelerator) {
if (accelerator_callback_map_.erase(accelerator) == 0)
return;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (Command::IsMediaKey(accelerator) &&
!MapHasMediaKeys(accelerator_callback_map_)) {
GlobalShortcutListener::SetShouldUseInternalMediaKeyHandling(true);

View file

@ -141,7 +141,7 @@ namespace api {
gin::WrapperInfo InAppPurchase::kWrapperInfo = {gin::kEmbedderNativeGin};
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// static
gin::Handle<InAppPurchase> InAppPurchase::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new InAppPurchase());
@ -223,7 +223,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
v8::Isolate* isolate = context->GetIsolate();
gin_helper::Dictionary dict(isolate, exports);
dict.Set("inAppPurchase", InAppPurchase::Create(isolate));

View file

@ -19,7 +19,7 @@
#include "shell/common/node_includes.h"
#include "ui/base/models/image_model.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
namespace gin {
@ -54,7 +54,7 @@ Menu::Menu(gin::Arguments* args)
: model_(std::make_unique<ElectronMenuModel>(this)) {
model_->AddObserver(this);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
gin_helper::Dictionary options;
if (args->GetNext(&options)) {
ElectronMenuModel::SharingItem item;
@ -117,7 +117,7 @@ bool Menu::ShouldRegisterAcceleratorForCommandId(int command_id) const {
command_id);
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool Menu::GetSharingItemForCommandId(
int command_id,
ElectronMenuModel::SharingItem* item) const {
@ -296,7 +296,7 @@ v8::Local<v8::ObjectTemplate> Menu::FillObjectTemplate(
.SetMethod("popupAt", &Menu::PopupAt)
.SetMethod("closePopupAt", &Menu::ClosePopupAt)
.SetMethod("_getAcceleratorTextAt", &Menu::GetAcceleratorTextAtForTesting)
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
.SetMethod("_getUserAcceleratorAt", &Menu::GetUserAcceleratorAt)
#endif
.Build();
@ -318,7 +318,7 @@ void Initialize(v8::Local<v8::Object> exports,
gin_helper::Dictionary dict(isolate, exports);
dict.Set("Menu", Menu::GetConstructor(context));
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
dict.SetMethod("setApplicationMenu", &Menu::SetApplicationMenu);
dict.SetMethod("sendActionToFirstResponder",
&Menu::SendActionToFirstResponder);

View file

@ -36,7 +36,7 @@ class Menu : public gin::Wrappable<Menu>,
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Set the global menubar.
static void SetApplicationMenu(Menu* menu);
@ -68,7 +68,7 @@ class Menu : public gin::Wrappable<Menu>,
bool use_default_accelerator,
ui::Accelerator* accelerator) const override;
bool ShouldRegisterAcceleratorForCommandId(int command_id) const override;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool GetSharingItemForCommandId(
int command_id,
ElectronMenuModel::SharingItem* item) const override;

View file

@ -47,7 +47,7 @@ void NativeTheme::OnNativeThemeUpdated(ui::NativeTheme* theme) {
void NativeTheme::SetThemeSource(ui::NativeTheme::ThemeSource override) {
ui_theme_->set_theme_source(override);
web_theme_->set_theme_source(override);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Update the macOS appearance setting for this new override value
UpdateMacOSAppearanceForOverrideValue(override);
#endif
@ -67,14 +67,14 @@ bool NativeTheme::ShouldUseHighContrastColors() {
return ui_theme_->UserHasContrastPreference();
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
const CFStringRef WhiteOnBlack = CFSTR("whiteOnBlack");
const CFStringRef UniversalAccessDomain = CFSTR("com.apple.universalaccess");
#endif
// TODO(MarshallOfSound): Implement for Linux
bool NativeTheme::ShouldUseInvertedColorScheme() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
CFPreferencesAppSynchronize(UniversalAccessDomain);
Boolean keyExistsAndHasValidFormat = false;
Boolean is_inverted = CFPreferencesGetAppBooleanValue(

View file

@ -38,7 +38,7 @@ class NativeTheme : public gin::Wrappable<NativeTheme>,
~NativeTheme() override;
void SetThemeSource(ui::NativeTheme::ThemeSource override);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void UpdateMacOSAppearanceForOverrideValue(
ui::NativeTheme::ThemeSource override);
#endif

View file

@ -42,7 +42,7 @@ namespace api {
gin::WrapperInfo PowerMonitor::kWrapperInfo = {gin::kEmbedderNativeGin};
PowerMonitor::PowerMonitor(v8::Isolate* isolate) {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
Browser::Get()->SetShutdownHandler(base::BindRepeating(
&PowerMonitor::ShouldShutdown, base::Unretained(this)));
#endif
@ -50,7 +50,7 @@ PowerMonitor::PowerMonitor(v8::Isolate* isolate) {
base::PowerMonitor::AddPowerStateObserver(this);
base::PowerMonitor::AddPowerSuspendObserver(this);
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
InitPlatformSpecificMonitors();
#endif
}
@ -79,7 +79,7 @@ void PowerMonitor::OnResume() {
Emit("resume");
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void PowerMonitor::SetListeningForShutdown(bool is_listening) {
if (is_listening) {
// unretained is OK because we own power_observer_linux_
@ -105,7 +105,7 @@ gin::ObjectTemplateBuilder PowerMonitor::GetObjectTemplateBuilder(
auto builder =
gin_helper::EventEmitterMixin<PowerMonitor>::GetObjectTemplateBuilder(
isolate);
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
builder.SetMethod("setListeningForShutdown",
&PowerMonitor::SetListeningForShutdown);
#endif

View file

@ -11,7 +11,7 @@
#include "shell/common/gin_helper/pinnable.h"
#include "ui/base/idle/idle.h"
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "shell/browser/lib/power_observer_linux.h"
#endif
@ -41,14 +41,14 @@ class PowerMonitor : public gin::Wrappable<PowerMonitor>,
explicit PowerMonitor(v8::Isolate* isolate);
~PowerMonitor() override;
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void SetListeningForShutdown(bool);
#endif
// Called by native calles.
bool ShouldShutdown();
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
void InitPlatformSpecificMonitors();
#endif
@ -59,7 +59,7 @@ class PowerMonitor : public gin::Wrappable<PowerMonitor>,
void OnSuspend() override;
void OnResume() override;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Static callback invoked when a message comes in to our messaging window.
static LRESULT CALLBACK WndProcStatic(HWND hwnd,
UINT message,
@ -81,7 +81,7 @@ class PowerMonitor : public gin::Wrappable<PowerMonitor>,
HWND window_;
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
PowerObserverLinux power_observer_linux_{this};
#endif
};

View file

@ -20,7 +20,7 @@
#include "ui/display/screen.h"
#include "ui/gfx/geometry/point.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "ui/display/win/screen_win.h"
#endif
@ -90,7 +90,7 @@ display::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) {
return screen_->GetDisplayMatching(match_rect);
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
static gfx::Rect ScreenToDIPRect(electron::NativeWindow* window,
const gfx::Rect& rect) {
@ -153,7 +153,7 @@ gin::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder(
.SetMethod("getPrimaryDisplay", &Screen::GetPrimaryDisplay)
.SetMethod("getAllDisplays", &Screen::GetAllDisplays)
.SetMethod("getDisplayNearestPoint", &Screen::GetDisplayNearestPoint)
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
.SetMethod("screenToDipPoint", &display::win::ScreenWin::ScreenToDIPPoint)
.SetMethod("dipToScreenPoint", &display::win::ScreenWin::DIPToScreenPoint)
.SetMethod("screenToDipRect", &ScreenToDIPRect)

View file

@ -20,13 +20,13 @@ namespace api {
gin::WrapperInfo SystemPreferences::kWrapperInfo = {gin::kEmbedderNativeGin};
SystemPreferences::SystemPreferences() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
InitializeWindow();
#endif
}
SystemPreferences::~SystemPreferences() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
Browser::Get()->RemoveObserver(this);
#endif
}
@ -63,16 +63,16 @@ gin::ObjectTemplateBuilder SystemPreferences::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return gin_helper::EventEmitterMixin<
SystemPreferences>::GetObjectTemplateBuilder(isolate)
#if defined(OS_WIN) || defined(OS_MAC)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
.SetMethod("getColor", &SystemPreferences::GetColor)
.SetMethod("getAccentColor", &SystemPreferences::GetAccentColor)
.SetMethod("getMediaAccessStatus",
&SystemPreferences::GetMediaAccessStatus)
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
.SetMethod("postNotification", &SystemPreferences::PostNotification)
.SetMethod("subscribeNotification",
&SystemPreferences::SubscribeNotification)

View file

@ -15,7 +15,7 @@
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/promise.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "shell/browser/browser.h"
#include "shell/browser/browser_observer.h"
#include "ui/gfx/sys_color_change_listener.h"
@ -25,7 +25,7 @@ namespace electron {
namespace api {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
enum class NotificationCenterKind {
kNSDistributedNotificationCenter = 0,
kNSNotificationCenter,
@ -36,7 +36,7 @@ enum class NotificationCenterKind {
class SystemPreferences
: public gin::Wrappable<SystemPreferences>,
public gin_helper::EventEmitterMixin<SystemPreferences>
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
,
public BrowserObserver,
public gfx::SysColorChangeListener
@ -51,14 +51,14 @@ class SystemPreferences
v8::Isolate* isolate) override;
const char* GetTypeName() override;
#if defined(OS_WIN) || defined(OS_MAC)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
std::string GetAccentColor();
std::string GetColor(gin_helper::ErrorThrower thrower,
const std::string& color);
std::string GetMediaAccessStatus(gin_helper::ErrorThrower thrower,
const std::string& media_type);
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool IsAeroGlassEnabled();
void InitializeWindow();
@ -69,7 +69,7 @@ class SystemPreferences
// BrowserObserver:
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
using NotificationCallback = base::RepeatingCallback<
void(const std::string&, base::DictionaryValue, const std::string&)>;
@ -129,7 +129,7 @@ class SystemPreferences
SystemPreferences();
~SystemPreferences() override;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
int DoSubscribeNotification(const std::string& name,
const NotificationCallback& callback,
NotificationCenterKind kind);
@ -137,7 +137,7 @@ class SystemPreferences
#endif
private:
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Static callback invoked when a message comes in to our messaging window.
static LRESULT CALLBACK WndProcStatic(HWND hwnd,
UINT message,

View file

@ -82,7 +82,7 @@ gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
return gin::Handle<Tray>();
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (!guid.has_value() && args->Length() > 1) {
thrower.ThrowError("Invalid GUID format");
return gin::Handle<Tray>();
@ -196,7 +196,7 @@ void Tray::SetImage(v8::Isolate* isolate, v8::Local<v8::Value> image) {
if (!NativeImage::TryConvertNativeImage(isolate, image, &native_image))
return;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
tray_icon_->SetImage(native_image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
#else
tray_icon_->SetImage(native_image->image());
@ -211,7 +211,7 @@ void Tray::SetPressedImage(v8::Isolate* isolate, v8::Local<v8::Value> image) {
if (!NativeImage::TryConvertNativeImage(isolate, image, &native_image))
return;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
tray_icon_->SetPressedImage(
native_image->GetHICON(GetSystemMetrics(SM_CXSMICON)));
#else
@ -230,7 +230,7 @@ void Tray::SetTitle(const std::string& title,
gin::Arguments* args) {
if (!CheckAlive())
return;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
TrayIcon::TitleOptions title_options;
if (options) {
if (options->Get("fontType", &title_options.font_type)) {
@ -258,7 +258,7 @@ void Tray::SetTitle(const std::string& title,
std::string Tray::GetTitle() {
if (!CheckAlive())
return std::string();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
return tray_icon_->GetTitle();
#else
return "";
@ -268,7 +268,7 @@ std::string Tray::GetTitle() {
void Tray::SetIgnoreDoubleClickEvents(bool ignore) {
if (!CheckAlive())
return;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
tray_icon_->SetIgnoreDoubleClickEvents(ignore);
#endif
}
@ -276,7 +276,7 @@ void Tray::SetIgnoreDoubleClickEvents(bool ignore) {
bool Tray::GetIgnoreDoubleClickEvents() {
if (!CheckAlive())
return false;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
return tray_icon_->GetIgnoreDoubleClickEvents();
#else
return false;
@ -309,7 +309,7 @@ void Tray::DisplayBalloon(gin_helper::ErrorThrower thrower,
options.Get("respectQuietTime", &balloon_options.respect_quiet_time);
if (icon) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
balloon_options.icon = icon->GetHICON(
GetSystemMetrics(balloon_options.large_icon ? SM_CXICON : SM_CXSMICON));
#else

View file

@ -361,10 +361,12 @@ void SimpleURLLoaderWrapper::OnSSLCertificateError(
std::move(response).Run(net_error);
}
void SimpleURLLoaderWrapper::OnClearSiteData(const GURL& url,
const std::string& header_value,
int32_t load_flags,
OnClearSiteDataCallback callback) {
void SimpleURLLoaderWrapper::OnClearSiteData(
const GURL& url,
const std::string& header_value,
int32_t load_flags,
const absl::optional<net::CookiePartitionKey>& cookie_partition_key,
OnClearSiteDataCallback callback) {
std::move(callback).Run();
}
void SimpleURLLoaderWrapper::OnLoadingStateUpdate(

View file

@ -86,10 +86,12 @@ class SimpleURLLoaderWrapper
const scoped_refptr<net::SSLCertRequestInfo>& cert_info,
mojo::PendingRemote<network::mojom::ClientCertificateResponder>
client_cert_responder) override {}
void OnClearSiteData(const GURL& url,
const std::string& header_value,
int32_t load_flags,
OnClearSiteDataCallback callback) override;
void OnClearSiteData(
const GURL& url,
const std::string& header_value,
int32_t load_flags,
const absl::optional<net::CookiePartitionKey>& cookie_partition_key,
OnClearSiteDataCallback callback) override;
void OnLoadingStateUpdate(network::mojom::LoadInfoPtr info,
OnLoadingStateUpdateCallback callback) override;
void OnDataUseUpdate(int32_t network_traffic_annotation_id_hash,

View file

@ -14,7 +14,6 @@
#include "base/containers/id_map.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/json/json_reader.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
@ -144,17 +143,17 @@
#include "shell/browser/osr/osr_web_contents_view.h"
#endif
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
#include "ui/aura/window.h"
#else
#include "ui/base/cocoa/defaults_utils.h"
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "ui/views/linux_ui/linux_ui.h"
#endif
#if defined(OS_LINUX) || defined(OS_WIN)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
#include "ui/gfx/font_render_params.h"
#endif
@ -172,7 +171,7 @@
#include "shell/browser/printing/print_preview_message_handler.h"
#include "shell/browser/printing/print_view_manager_electron.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "printing/backend/win_helper.h"
#endif
#endif
@ -390,14 +389,14 @@ void OnCapturePageDone(gin_helper::Promise<gfx::Image> promise,
}
absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
base::TimeDelta interval;
if (ui::TextInsertionCaretBlinkPeriod(&interval))
return interval;
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
if (auto* linux_ui = views::LinuxUI::instance())
return linux_ui->GetCursorBlinkInterval();
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
const auto system_msec = ::GetCaretBlinkTime();
if (system_msec != 0) {
return (system_msec == INFINITE) ? base::TimeDelta()
@ -412,14 +411,14 @@ absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
// found on the network. We need to check this because Chromium does not do
// sanity checking of device_name validity and so will crash on invalid names.
bool IsDeviceNameValid(const std::u16string& device_name) {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
base::ScopedCFTypeRef<CFStringRef> new_printer_id(
base::SysUTF16ToCFStringRef(device_name));
PMPrinter new_printer = PMPrinterCreateFromPrinterID(new_printer_id.get());
bool printer_exists = new_printer != nullptr;
PMRelease(new_printer);
return printer_exists;
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
printing::ScopedPrinterHandle printer;
return printer.OpenPrinterWithName(base::as_wcstr(device_name));
#else
@ -428,7 +427,7 @@ bool IsDeviceNameValid(const std::u16string& device_name) {
}
std::pair<std::string, std::u16string> GetDefaultPrinterAsync() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Blocking is needed here because Windows printer drivers are oftentimes
// not thread-safe and have to be accessed on the UI thread.
base::ThreadRestrictions::ScopedAllowIO allow_io;
@ -463,7 +462,7 @@ std::pair<std::string, std::u16string> GetDefaultPrinterAsync() {
// chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc:L36-L54
scoped_refptr<base::TaskRunner> CreatePrinterHandlerTaskRunner() {
// USER_VISIBLE because the result is displayed in the print preview dialog.
#if !defined(OS_WIN)
#if !BUILDFLAG(IS_WIN)
static constexpr base::TaskTraits kTraits = {
base::MayBlock(), base::TaskPriority::USER_VISIBLE};
#endif
@ -471,7 +470,7 @@ scoped_refptr<base::TaskRunner> CreatePrinterHandlerTaskRunner() {
#if defined(USE_CUPS)
// CUPS is thread safe.
return base::ThreadPool::CreateTaskRunner(kTraits);
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
// Windows drivers are likely not thread-safe and need to be accessed on the
// UI thread.
return content::GetUIThreadTaskRunner(
@ -579,15 +578,17 @@ PrefService* GetPrefService(content::WebContents* web_contents) {
std::map<std::string, std::string> GetAddedFileSystemPaths(
content::WebContents* web_contents) {
auto* pref_service = GetPrefService(web_contents);
const base::DictionaryValue* file_system_paths_value =
const base::Value* file_system_paths_value =
pref_service->GetDictionary(prefs::kDevToolsFileSystemPaths);
std::map<std::string, std::string> result;
if (file_system_paths_value) {
base::DictionaryValue::Iterator it(*file_system_paths_value);
for (; !it.IsAtEnd(); it.Advance()) {
const base::DictionaryValue* file_system_paths_dict;
file_system_paths_value->GetAsDictionary(&file_system_paths_dict);
for (auto it : file_system_paths_dict->DictItems()) {
std::string type =
it.value().is_string() ? it.value().GetString() : std::string();
result[it.key()] = type;
it.second.is_string() ? it.second.GetString() : std::string();
result[it.first] = type;
}
}
return result;
@ -826,7 +827,7 @@ void WebContents::InitWithSessionAndOptions(
accept_languages.pop_back();
prefs->accept_languages = accept_languages;
#if defined(OS_LINUX) || defined(OS_WIN)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
// Update font settings.
static const gfx::FontRenderParams params(
gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr));
@ -1213,7 +1214,7 @@ bool WebContents::HandleKeyboardEvent(
}
}
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
// NOTE: The macOS version of this function is found in
// electron_api_web_contents_mac.mm, as it requires calling into objective-C
// code.
@ -1850,7 +1851,7 @@ void WebContents::ReadyToCommitNavigation(
// Don't focus content in an inactive window.
if (!owner_window())
return;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (!owner_window()->IsActive())
return;
#else
@ -2347,7 +2348,7 @@ void WebContents::ForcefullyCrashRenderer() {
content::RenderProcessHost* rph = rwh->GetProcess();
if (rph) {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// A generic |CrashDumpHungChildProcess()| is not implemented for Linux.
// Instead we send an explicit IPC to crash on the renderer's IO thread.
rph->ForceCrash();
@ -2907,7 +2908,7 @@ void WebContents::StopFindInPage(content::StopFindAction action) {
}
void WebContents::ShowDefinitionForSelection() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
auto* const view = web_contents()->GetRenderWidgetHostView();
if (view)
view->ShowDefinitionForSelection();
@ -2923,14 +2924,14 @@ void WebContents::CopyImageAt(int x, int y) {
void WebContents::Focus() {
// Focusing on WebContents does not automatically focus the window on macOS
// and Linux, do it manually to match the behavior on Windows.
#if defined(OS_MAC) || defined(OS_LINUX)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
if (owner_window())
owner_window()->Focus(true);
#endif
web_contents()->Focus();
}
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
bool WebContents::IsFocused() const {
auto* view = web_contents()->GetRenderWidgetHostView();
if (!view)
@ -3077,7 +3078,7 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
return handle;
}
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
// If the view's renderer is suspended this may fail on Windows/Linux -
// bail if so. See CopyFromSurface in
// content/public/browser/render_widget_host_view.h.
@ -3087,7 +3088,7 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
promise.Resolve(gfx::Image());
return handle;
}
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
// Capture full page if user doesn't specify a |rect|.
const gfx::Size view_size =
@ -3121,8 +3122,8 @@ void WebContents::IncrementCapturerCount(gin::Arguments* args) {
// get stayAwake arguments if they exist
args->GetNext(&stay_awake);
ignore_result(
web_contents()->IncrementCapturerCount(size, stay_hidden, stay_awake));
std::ignore =
web_contents()->IncrementCapturerCount(size, stay_hidden, stay_awake);
}
void WebContents::DecrementCapturerCount(gin::Arguments* args) {
@ -3644,8 +3645,7 @@ void WebContents::DevToolsAddFileSystem(
auto* pref_service = GetPrefService(GetDevToolsWebContents());
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
update.Get()->SetWithoutPathExpansion(path.AsUTF8Unsafe(),
std::make_unique<base::Value>(type));
update.Get()->SetKey(path.AsUTF8Unsafe(), base::Value(type));
inspectable_web_contents_->CallClientFunction(
"DevToolsAPI.fileSystemAdded", nullptr, file_system_value.get(), nullptr);
}
@ -3750,13 +3750,13 @@ void WebContents::ColorPickedInEyeDropper(int r, int g, int b, int a) {
"DevToolsAPI.eyeDropperPickedColor", &color, nullptr, nullptr);
}
#if defined(TOOLKIT_VIEWS) && !defined(OS_MAC)
#if defined(TOOLKIT_VIEWS) && !BUILDFLAG(IS_MAC)
ui::ImageModel WebContents::GetDevToolsWindowIcon() {
return owner_window() ? owner_window()->GetWindowAppIcon() : ui::ImageModel{};
}
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void WebContents::GetDevToolsWindowWMClass(std::string* name,
std::string* class_name) {
*class_name = Browser::Get()->GetName();

View file

@ -715,10 +715,10 @@ class WebContents : public ExclusiveAccessContext,
void DevToolsSetEyeDropperActive(bool active) override;
// InspectableWebContentsViewDelegate:
#if defined(TOOLKIT_VIEWS) && !defined(OS_MAC)
#if defined(TOOLKIT_VIEWS) && !BUILDFLAG(IS_MAC)
ui::ImageModel GetDevToolsWindowIcon() override;
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void GetDevToolsWindowWMClass(std::string* name,
std::string* class_name) override;
#endif

View file

@ -15,7 +15,7 @@
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "shell/browser/ui/cocoa/delayed_native_view_host.h"
#endif
@ -25,7 +25,7 @@ namespace api {
WebContentsView::WebContentsView(v8::Isolate* isolate,
gin::Handle<WebContents> web_contents)
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
: View(new DelayedNativeViewHost(web_contents->inspectable_web_contents()
->GetView()
->GetNativeView())),
@ -34,7 +34,7 @@ WebContentsView::WebContentsView(v8::Isolate* isolate,
#endif
web_contents_(isolate, web_contents.ToV8()),
api_web_contents_(web_contents.get()) {
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
// On macOS the View is a newly-created |DelayedNativeViewHost| and it is our
// responsibility to delete it. On other platforms the View is created and
// managed by InspectableWebContents.

View file

@ -69,8 +69,8 @@ void GPUInfoEnumerator::BeginVideoDecodeAcceleratorSupportedProfile() {
void GPUInfoEnumerator::EndVideoDecodeAcceleratorSupportedProfile() {
auto& top_value = value_stack.top();
top_value->SetDictionary(kVideoDecodeAcceleratorSupportedProfileKey,
std::move(current));
top_value->SetKey(kVideoDecodeAcceleratorSupportedProfileKey,
base::Value::FromUniquePtrValue(std::move(current)));
current = std::move(top_value);
value_stack.pop();
}
@ -82,8 +82,8 @@ void GPUInfoEnumerator::BeginVideoEncodeAcceleratorSupportedProfile() {
void GPUInfoEnumerator::EndVideoEncodeAcceleratorSupportedProfile() {
auto& top_value = value_stack.top();
top_value->SetDictionary(kVideoEncodeAcceleratorSupportedProfileKey,
std::move(current));
top_value->SetKey(kVideoEncodeAcceleratorSupportedProfileKey,
base::Value::FromUniquePtrValue(std::move(current)));
current = std::move(top_value);
value_stack.pop();
}
@ -95,8 +95,8 @@ void GPUInfoEnumerator::BeginImageDecodeAcceleratorSupportedProfile() {
void GPUInfoEnumerator::EndImageDecodeAcceleratorSupportedProfile() {
auto& top_value = value_stack.top();
top_value->SetDictionary(kImageDecodeAcceleratorSupportedProfileKey,
std::move(current));
top_value->SetKey(kImageDecodeAcceleratorSupportedProfileKey,
base::Value::FromUniquePtrValue(std::move(current)));
current = std::move(top_value);
value_stack.pop();
}
@ -108,7 +108,8 @@ void GPUInfoEnumerator::BeginAuxAttributes() {
void GPUInfoEnumerator::EndAuxAttributes() {
auto& top_value = value_stack.top();
top_value->SetDictionary(kAuxAttributesKey, std::move(current));
top_value->SetKey(kAuxAttributesKey,
base::Value::FromUniquePtrValue(std::move(current)));
current = std::move(top_value);
value_stack.pop();
}
@ -120,7 +121,8 @@ void GPUInfoEnumerator::BeginOverlayInfo() {
void GPUInfoEnumerator::EndOverlayInfo() {
auto& top_value = value_stack.top();
top_value->SetDictionary(kOverlayInfo, std::move(current));
top_value->SetKey(kOverlayInfo,
base::Value::FromUniquePtrValue(std::move(current)));
current = std::move(top_value);
value_stack.pop();
}

View file

@ -31,7 +31,7 @@ GPUInfoManager::~GPUInfoManager() {
// Based on
// https://chromium.googlesource.com/chromium/src.git/+/69.0.3497.106/content/browser/gpu/gpu_data_manager_impl_private.cc#838
bool GPUInfoManager::NeedsCompleteGpuInfoCollection() const {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return gpu_data_manager_->DxdiagDx12VulkanRequested() &&
gpu_data_manager_->GetGPUInfo().dx_diagnostics.IsEmpty();
#else

View file

@ -9,14 +9,14 @@
#include "third_party/abseil-cpp/absl/types/optional.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include <psapi.h>
#include "base/win/win_util.h"
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include <mach/mach.h>
#include "base/process/port_provider_mac.h"
#include "content/public/browser/browser_child_process_host.h"
@ -46,7 +46,7 @@ absl::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) {
} // namespace
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
namespace electron {
@ -60,7 +60,7 @@ ProcessMetric::ProcessMetric(int type,
this->service_name = service_name;
this->name = name;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
HANDLE duplicate_handle = INVALID_HANDLE_VALUE;
::DuplicateHandle(::GetCurrentProcess(), handle, ::GetCurrentProcess(),
&duplicate_handle, 0, false, DUPLICATE_SAME_ACCESS);
@ -72,7 +72,7 @@ ProcessMetric::ProcessMetric(int type,
ProcessMetric::~ProcessMetric() = default;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
ProcessMemoryInfo ProcessMetric::GetMemoryInfo() const {
ProcessMemoryInfo result;
@ -146,7 +146,7 @@ bool ProcessMetric::IsSandboxed(ProcessIntegrityLevel integrity_level) {
integrity_level < ProcessIntegrityLevel::kMedium;
}
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
ProcessMemoryInfo ProcessMetric::GetMemoryInfo() const {
ProcessMemoryInfo result;
@ -167,6 +167,6 @@ bool ProcessMetric::IsSandboxed() const {
#endif
}
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
} // namespace electron

View file

@ -14,17 +14,17 @@
namespace electron {
#if !defined(OS_LINUX)
#if !BUILDFLAG(IS_LINUX)
struct ProcessMemoryInfo {
size_t working_set_size = 0;
size_t peak_working_set_size = 0;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
size_t private_bytes = 0;
#endif
};
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
enum class ProcessIntegrityLevel {
kUnknown,
kUntrusted,
@ -48,14 +48,14 @@ struct ProcessMetric {
const std::string& name = std::string());
~ProcessMetric();
#if !defined(OS_LINUX)
#if !BUILDFLAG(IS_LINUX)
ProcessMemoryInfo GetMemoryInfo() const;
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
ProcessIntegrityLevel GetIntegrityLevel() const;
static bool IsSandboxed(ProcessIntegrityLevel integrity_level);
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
bool IsSandboxed() const;
#endif
};

View file

@ -16,7 +16,7 @@ void AutoUpdater::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
#if !defined(OS_MAC) || defined(MAS_BUILD)
#if !BUILDFLAG(IS_MAC) || defined(MAS_BUILD)
std::string AutoUpdater::GetFeedURL() {
return "";
}

View file

@ -41,7 +41,7 @@ void RunQuitClosure(base::OnceClosure quit) {
} // namespace
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
Browser::LaunchItem::LaunchItem() = default;
Browser::LaunchItem::~LaunchItem() = default;
Browser::LaunchItem::LaunchItem(const LaunchItem& other) = default;
@ -65,7 +65,7 @@ Browser* Browser::Get() {
return ElectronBrowserMainParts::Get()->browser();
}
#if defined(OS_WIN) || defined(OS_LINUX)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
void Browser::Focus(gin::Arguments* args) {
// Focus on the first visible window.
for (auto* const window : WindowList::GetWindows()) {
@ -275,7 +275,7 @@ void Browser::OnWindowAllClosed() {
}
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void Browser::NewWindowForTab() {
for (BrowserObserver& observer : observers_)
observer.OnNewWindowForTab();

View file

@ -18,13 +18,13 @@
#include "shell/browser/window_list_observer.h"
#include "shell/common/gin_helper/promise.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/files/file_path.h"
#include "shell/browser/ui/win/taskbar_host.h"
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "ui/base/cocoa/secure_password_input.h"
#endif
@ -82,7 +82,7 @@ class Browser : public WindowListObserver {
// Clear the recent documents list.
void ClearRecentDocuments();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Set the application user model ID.
void SetAppUserModelID(const std::wstring& name);
#endif
@ -101,7 +101,7 @@ class Browser : public WindowListObserver {
std::u16string GetApplicationNameForProtocol(const GURL& url);
#if !defined(OS_LINUX)
#if !BUILDFLAG(IS_LINUX)
// get the name, icon and path for an application
v8::Local<v8::Promise> GetApplicationInfoForProtocol(v8::Isolate* isolate,
const GURL& url);
@ -111,7 +111,7 @@ class Browser : public WindowListObserver {
bool SetBadgeCount(absl::optional<int> count);
int GetBadgeCount();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
struct LaunchItem {
std::wstring name;
std::wstring path;
@ -135,7 +135,7 @@ class Browser : public WindowListObserver {
std::u16string path;
std::vector<std::u16string> args;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// used in browser::setLoginItemSettings
bool enabled = true;
std::wstring name;
@ -152,7 +152,7 @@ class Browser : public WindowListObserver {
void SetLoginItemSettings(LoginItemSettings settings);
LoginItemSettings GetLoginItemSettings(const LoginItemSettings& options);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Set the handler which decides whether to shutdown.
void SetShutdownHandler(base::RepeatingCallback<bool()> handler);
@ -227,16 +227,16 @@ class Browser : public WindowListObserver {
// Set docks' icon.
void DockSetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon);
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
void ShowAboutPanel();
void SetAboutPanelOptions(base::DictionaryValue options);
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
void ShowEmojiPanel();
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
struct UserTask {
base::FilePath program;
std::wstring arguments;
@ -258,12 +258,12 @@ class Browser : public WindowListObserver {
// one from app's name.
// The returned string managed by Browser, and should not be modified.
PCWSTR GetAppUserModelID();
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// Whether Unity launcher is running.
bool IsUnityRunning();
#endif // defined(OS_LINUX)
#endif // BUILDFLAG(IS_LINUX)
// Tell the application to open a file.
bool OpenFile(const std::string& file_path);
@ -271,13 +271,13 @@ class Browser : public WindowListObserver {
// Tell the application to open a url.
void OpenURL(const std::string& url);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Tell the application to create a new window for a tab.
void NewWindowForTab();
// Tell the application that application did become active
void DidBecomeActive();
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
// Tell the application that application is activated with visible/invisible
// windows.
@ -302,7 +302,7 @@ class Browser : public WindowListObserver {
void RemoveObserver(BrowserObserver* obs) { observers_.RemoveObserver(obs); }
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Returns whether secure input is enabled
bool IsSecureKeyboardEntryEnabled();
void SetSecureKeyboardEntryEnabled(bool enabled);
@ -355,18 +355,18 @@ class Browser : public WindowListObserver {
std::unique_ptr<gin_helper::Promise<void>> ready_promise_;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
std::unique_ptr<ui::ScopedPasswordInputEnabler> password_input_enabler_;
base::Time last_dock_show_;
#endif
#if defined(OS_LINUX) || defined(OS_WIN)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
base::Value about_panel_options_;
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
base::DictionaryValue about_panel_options_;
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void UpdateBadgeContents(HWND hwnd,
const absl::optional<std::string>& badge_content,
const std::string& badge_alt_string);

View file

@ -15,7 +15,7 @@
#include "shell/browser/window_list.h"
#include "shell/common/application_info.h"
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "shell/browser/linux/unity_service.h"
#include "ui/gtk/gtk_util.h"
#endif

View file

@ -60,7 +60,7 @@ class BrowserObserver : public base::CheckedObserver {
// Refer https://chromium-review.googlesource.com/c/chromium/src/+/2134864
virtual void OnPreCreateThreads() {}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// The browser wants to report that an user activity will resume. (macOS only)
virtual void OnWillContinueUserActivity(bool* prevent_default,
const std::string& type) {}

View file

@ -99,7 +99,7 @@ void BrowserProcessImpl::PostEarlyInitialization() {
PrefServiceFactory prefs_factory;
auto pref_registry = base::MakeRefCounted<PrefRegistrySimple>();
PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get());
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
OSCrypt::RegisterLocalPrefs(pref_registry.get());
#endif

View file

@ -97,7 +97,7 @@ class BrowserProcessImpl : public BrowserProcess {
void CreateDevToolsAutoOpener() override {}
void set_background_mode_manager_for_test(
std::unique_ptr<BackgroundModeManager> manager) override {}
#if (defined(OS_WIN) || defined(OS_LINUX))
#if (BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX))
void StartAutoupdateTimer() override {}
#endif
void SetApplicationLocale(const std::string& locale) override;

View file

@ -4,7 +4,7 @@
#include "shell/browser/electron_browser_client.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <shlobj.h>
#endif
@ -50,9 +50,11 @@
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "crypto/crypto_buildflags.h"
#include "electron/buildflags/buildflags.h"
#include "electron/grit/electron_resources.h"
#include "electron/shell/common/api/api.mojom.h"
#include "extensions/browser/api/messaging/messaging_api_message_filter.h"
#include "mojo/public/cpp/bindings/binder_map.h"
#include "net/base/escape.h"
#include "net/ssl/ssl_cert_request_info.h"
@ -112,15 +114,15 @@
#include "ui/native_theme/native_theme.h"
#include "v8/include/v8.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "sandbox/win/src/sandbox_policy.h"
#endif
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
#include "net/ssl/client_cert_store_nss.h"
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
#include "net/ssl/client_cert_store_win.h"
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
#include "net/ssl/client_cert_store_mac.h"
#elif defined(USE_OPENSSL)
#include "net/ssl/client_cert_store.h"
@ -173,12 +175,12 @@
#include "shell/browser/plugins/plugin_utils.h"
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "content/common/mac_helpers.h"
#include "content/public/common/child_process_host.h"
#endif
#if defined(OS_LINUX) && !defined(MAS_BUILD)
#if BUILDFLAG(IS_LINUX) && !defined(MAS_BUILD)
#include "base/debug/leak_annotations.h"
#include "components/crash/content/browser/crash_handler_host_linux.h"
#include "components/crash/core/app/breakpad_linux.h" // nogncheck
@ -186,7 +188,7 @@
#include "components/crash/core/app/crashpad.h" // nogncheck
#endif
#if BUILDFLAG(ENABLE_PICTURE_IN_PICTURE) && defined(OS_WIN)
#if BUILDFLAG(ENABLE_PICTURE_IN_PICTURE) && BUILDFLAG(IS_WIN)
#include "chrome/browser/ui/views/overlay/overlay_window_views.h"
#include "shell/browser/browser.h"
#include "ui/aura/window.h"
@ -293,7 +295,7 @@ const extensions::Extension* GetEnabledExtensionFromEffectiveURL(
}
#endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
const std::string& process_type) {
base::FilePath dumps_path;
@ -356,7 +358,7 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
return -1;
}
#endif // defined(OS_LINUX)
#endif // BUILDFLAG(IS_LINUX)
} // namespace
@ -413,18 +415,19 @@ bool ElectronBrowserClient::IsRendererSubFrame(int process_id) const {
void ElectronBrowserClient::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
// When a render process is crashed, it might be reused.
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
int process_id = host->GetID();
auto* browser_context = host->GetBrowserContext();
ALLOW_UNUSED_LOCAL(browser_context);
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
host->AddFilter(
new extensions::ExtensionMessageFilter(process_id, browser_context));
host->AddFilter(new extensions::ExtensionsGuestViewMessageFilter(
process_id, browser_context));
host->AddFilter(
new ElectronExtensionMessageFilter(process_id, browser_context));
host->AddFilter(
new extensions::MessagingAPIMessageFilter(process_id, browser_context));
#endif
// ensure the ProcessPreferences is removed later
@ -506,7 +509,7 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
base::FilePath child_path;
base::FilePath program =
base::MakeAbsoluteFilePath(command_line->GetProgram());
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
auto renderer_child_path = content::ChildProcessHost::GetChildPath(
content::ChildProcessHost::CHILD_RENDERER);
auto gpu_child_path = content::ChildProcessHost::GetChildPath(
@ -540,7 +543,7 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType);
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
bool enable_crash_reporter = false;
if (crash_reporter::IsCrashpadEnabled()) {
command_line->AppendSwitch(::switches::kEnableCrashpad);
@ -603,7 +606,7 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
}
if (process_type == ::switches::kRendererProcess) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Append --app-user-model-id.
PWSTR current_app_id;
if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&current_app_id))) {
@ -747,7 +750,7 @@ std::unique_ptr<content::OverlayWindow>
ElectronBrowserClient::CreateWindowForPictureInPicture(
content::PictureInPictureWindowController* controller) {
auto overlay_window = content::OverlayWindow::Create(controller);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
std::wstring app_user_model_id = Browser::Get()->GetAppUserModelID();
if (!app_user_model_id.empty()) {
auto* overlay_window_view =
@ -874,12 +877,12 @@ void ElectronBrowserClient::SiteInstanceDeleting(
std::unique_ptr<net::ClientCertStore>
ElectronBrowserClient::CreateClientCertStore(
content::BrowserContext* browser_context) {
#if defined(USE_NSS_CERTS)
#if BUILDFLAG(USE_NSS_CERTS)
return std::make_unique<net::ClientCertStoreNSS>(
net::ClientCertStoreNSS::PasswordDelegateFactory());
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
return std::make_unique<net::ClientCertStoreWin>();
#elif defined(OS_MAC)
#elif BUILDFLAG(IS_MAC)
return std::make_unique<net::ClientCertStoreMac>();
#elif defined(USE_OPENSSL)
return std::unique_ptr<net::ClientCertStore>();
@ -921,7 +924,7 @@ ElectronBrowserClient::CreateBrowserMainParts(
auto browser_main_parts =
std::make_unique<ElectronBrowserMainParts>(std::move(params));
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
browser_main_parts_ = browser_main_parts.get();
#endif
@ -1007,6 +1010,7 @@ bool ElectronBrowserClient::HandleExternalProtocol(
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
base::PostTask(
FROM_HERE, {BrowserThread::UI},
@ -1193,6 +1197,7 @@ class FileURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
void ElectronBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
const absl::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) {
auto* render_process_host =
content::RenderProcessHost::FromID(render_process_id);
@ -1263,6 +1268,21 @@ void ElectronBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
#endif
}
void ElectronBrowserClient::
RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories(
content::BrowserContext* browser_context,
NonNetworkURLLoaderFactoryMap* factories) {
DCHECK(browser_context);
DCHECK(factories);
#if BUILDFLAG(ENABLE_EXTENSIONS)
factories->emplace(
extensions::kExtensionScheme,
extensions::CreateExtensionServiceWorkerScriptURLLoaderFactory(
browser_context));
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
}
bool ElectronBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
base::StringPiece scheme,
bool is_embedded_origin_secure) {
@ -1436,7 +1456,7 @@ void ElectronBrowserClient::OverrideURLLoaderFactoryParams(
browser_context, origin, is_for_isolated_world, factory_params);
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool ElectronBrowserClient::PreSpawnChild(sandbox::TargetPolicy* policy,
sandbox::mojom::Sandbox sandbox_type,
ChildSpawnFlags flags) {
@ -1448,61 +1468,59 @@ bool ElectronBrowserClient::PreSpawnChild(sandbox::TargetPolicy* policy,
return false;
return true;
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
void BindElectronBrowser(
mojo::PendingAssociatedReceiver<electron::mojom::ElectronBrowser> receiver,
content::RenderFrameHost* frame_host) {
ElectronBrowserHandlerImpl::Create(frame_host, std::move(receiver));
}
bool ElectronBrowserClient::BindAssociatedReceiverFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle* handle) {
if (interface_name == mojom::ElectronAutofillDriver::Name_) {
AutofillDriverFactory::BindAutofillDriver(
mojo::PendingAssociatedReceiver<mojom::ElectronAutofillDriver>(
std::move(*handle)),
render_frame_host);
return true;
}
if (interface_name == electron::mojom::ElectronBrowser::Name_) {
BindElectronBrowser(
mojo::PendingAssociatedReceiver<electron::mojom::ElectronBrowser>(
std::move(*handle)),
render_frame_host);
return true;
}
void ElectronBrowserClient::
RegisterAssociatedInterfaceBindersForRenderFrameHost(
content::RenderFrameHost&
render_frame_host, // NOLINT(runtime/references)
blink::AssociatedInterfaceRegistry&
associated_registry) { // NOLINT(runtime/references)
associated_registry.AddInterface(base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<electron::mojom::ElectronBrowser>
receiver) {
ElectronBrowserHandlerImpl::Create(render_frame_host,
std::move(receiver));
},
&render_frame_host));
associated_registry.AddInterface(base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<mojom::ElectronAutofillDriver>
receiver) {
AutofillDriverFactory::BindAutofillDriver(std::move(receiver),
render_frame_host);
},
&render_frame_host));
#if BUILDFLAG(ENABLE_PRINTING)
if (interface_name == printing::mojom::PrintManagerHost::Name_) {
mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost> receiver(
std::move(*handle));
PrintViewManagerElectron::BindPrintManagerHost(std::move(receiver),
render_frame_host);
return true;
}
associated_registry.AddInterface(base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost>
receiver) {
PrintViewManagerElectron::BindPrintManagerHost(std::move(receiver),
render_frame_host);
},
&render_frame_host));
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (interface_name == extensions::mojom::LocalFrameHost::Name_) {
extensions::ExtensionWebContentsObserver::BindLocalFrameHost(
mojo::PendingAssociatedReceiver<extensions::mojom::LocalFrameHost>(
std::move(*handle)),
render_frame_host);
return true;
}
associated_registry.AddInterface(base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<extensions::mojom::LocalFrameHost>
receiver) {
extensions::ExtensionWebContentsObserver::BindLocalFrameHost(
std::move(receiver), render_frame_host);
},
&render_frame_host));
#endif
#if BUILDFLAG(ENABLE_PDF_VIEWER)
if (interface_name == pdf::mojom::PdfService::Name_) {
pdf::PDFWebContentsHelper::BindPdfService(
mojo::PendingAssociatedReceiver<pdf::mojom::PdfService>(
std::move(*handle)),
render_frame_host);
return true;
}
associated_registry.AddInterface(base::BindRepeating(
[](content::RenderFrameHost* render_frame_host,
mojo::PendingAssociatedReceiver<pdf::mojom::PdfService> receiver) {
pdf::PDFWebContentsHelper::BindPdfService(std::move(receiver),
render_frame_host);
},
&render_frame_host));
#endif
return false;
}
std::string ElectronBrowserClient::GetApplicationLocale() {
@ -1613,7 +1631,7 @@ void ElectronBrowserClient::RegisterBrowserInterfaceBindersForFrame(
#endif
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void ElectronBrowserClient::GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
int child_process_id,
@ -1683,12 +1701,6 @@ content::BluetoothDelegate* ElectronBrowserClient::GetBluetoothDelegate() {
return bluetooth_delegate_.get();
}
content::FontAccessDelegate* ElectronBrowserClient::GetFontAccessDelegate() {
if (!font_access_delegate_)
font_access_delegate_ = std::make_unique<ElectronFontAccessDelegate>();
return font_access_delegate_.get();
}
void BindBadgeServiceForServiceWorker(
const content::ServiceWorkerVersionBaseInfo& info,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {
@ -1711,7 +1723,7 @@ void ElectronBrowserClient::RegisterBrowserInterfaceBindersForServiceWorker(
}
device::GeolocationManager* ElectronBrowserClient::GetGeolocationManager() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
return browser_main_parts_->GetGeolocationManager();
#else
return nullptr;

View file

@ -20,7 +20,6 @@
#include "net/ssl/client_cert_identity.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "shell/browser/bluetooth/electron_bluetooth_delegate.h"
#include "shell/browser/font/electron_font_access_delegate.h"
#include "shell/browser/hid/electron_hid_delegate.h"
#include "shell/browser/serial/electron_serial_delegate.h"
#include "third_party/blink/public/mojom/badging/badging.mojom-forward.h"
@ -85,7 +84,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
void RegisterBrowserInterfaceBindersForServiceWorker(
mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*
map) override;
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
int child_process_id,
@ -97,8 +96,6 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
content::SerialDelegate* GetSerialDelegate() override;
content::FontAccessDelegate* GetFontAccessDelegate() override;
content::BluetoothDelegate* GetBluetoothDelegate() override;
content::HidDelegate* GetHidDelegate() override;
@ -198,6 +195,10 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
void RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
const absl::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) override;
void RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories(
content::BrowserContext* browser_context,
NonNetworkURLLoaderFactoryMap* factories) override;
void CreateWebSocket(
content::RenderFrameHost* frame,
@ -230,15 +231,14 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
const url::Origin& origin,
bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) override;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool PreSpawnChild(sandbox::TargetPolicy* policy,
sandbox::mojom::Sandbox sandbox_type,
ChildSpawnFlags flags) override;
#endif
bool BindAssociatedReceiverFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle* handle) override;
void RegisterAssociatedInterfaceBindersForRenderFrameHost(
content::RenderFrameHost& render_frame_host,
blink::AssociatedInterfaceRegistry& associated_registry) override;
bool HandleExternalProtocol(
const GURL& url,
@ -251,6 +251,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
ui::PageTransition page_transition,
bool has_user_gesture,
const absl::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
@ -316,10 +317,9 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
std::unique_ptr<ElectronSerialDelegate> serial_delegate_;
std::unique_ptr<ElectronBluetoothDelegate> bluetooth_delegate_;
std::unique_ptr<ElectronFontAccessDelegate> font_access_delegate_;
std::unique_ptr<ElectronHidDelegate> hid_delegate_;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
ElectronBrowserMainParts* browser_main_parts_ = nullptr;
#endif
};

View file

@ -17,6 +17,9 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/os_crypt/key_storage_config_linux.h"
#include "components/os_crypt/os_crypt.h"
#include "content/browser/browser_main_loop.h" // nogncheck
#include "content/public/browser/browser_thread.h"
@ -61,7 +64,7 @@
#include "ui/wm/core/wm_state.h"
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "base/environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
@ -75,14 +78,14 @@
#include "ui/views/linux_ui/linux_ui.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "ui/base/l10n/l10n_util_win.h"
#include "ui/display/win/dpi.h"
#include "ui/gfx/system_fonts_win.h"
#include "ui/strings/grit/app_locale_settings.h"
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "services/device/public/cpp/geolocation/geolocation_manager.h"
#include "shell/browser/ui/cocoa/views_delegate_mac.h"
#else
@ -111,7 +114,7 @@ void Erase(T* container, typename T::iterator iter) {
container->erase(iter);
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// gfx::Font callbacks
void AdjustUIFont(gfx::win::FontAdjustment* font_adjustment) {
l10n_util::NeedOverrideDefaultUIFont(&font_adjustment->font_family_override,
@ -131,7 +134,7 @@ std::u16string MediaStringProvider(media::MessageId id) {
switch (id) {
case media::DEFAULT_AUDIO_DEVICE_NAME:
return u"Default";
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
case media::COMMUNICATIONS_AUDIO_DEVICE_NAME:
return u"Communications";
#endif
@ -140,7 +143,7 @@ std::u16string MediaStringProvider(media::MessageId id) {
}
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// GTK does not provide a way to check if current theme is dark, so we compare
// the text and background luminosity to get a result.
// This trick comes from FireFox.
@ -158,7 +161,7 @@ void UpdateDarkThemeSetting() {
} // namespace
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
class DarkThemeObserver : public ui::NativeThemeObserver {
public:
DarkThemeObserver() = default;
@ -208,10 +211,10 @@ int ElectronBrowserMainParts::GetExitCode() const {
int ElectronBrowserMainParts::PreEarlyInitialization() {
field_trial_list_ = std::make_unique<base::FieldTrialList>(nullptr);
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
HandleSIGCHLD();
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
ui::OzonePlatform::PreEarlyInitialization();
#endif
@ -272,7 +275,7 @@ int ElectronBrowserMainParts::PreCreateThreads() {
#if defined(USE_AURA)
screen_ = views::CreateDesktopScreen();
display::Screen::SetScreenInstance(screen_.get());
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
views::LinuxUI::instance()->UpdateDeviceScaleFactor();
#endif
#endif
@ -283,13 +286,13 @@ int ElectronBrowserMainParts::PreCreateThreads() {
auto* command_line = base::CommandLine::ForCurrentProcess();
std::string locale = command_line->GetSwitchValueASCII(::switches::kLang);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// The browser process only wants to support the language Cocoa will use,
// so force the app locale to be overridden with that value. This must
// happen before the ResourceBundle is loaded
if (locale.empty())
l10n_util::OverrideLocaleWithCocoaLocale();
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
// l10n_util::GetApplicationLocaleInternal uses g_get_language_names(),
// which keys off of getenv("LC_ALL").
// We must set this env first to make ui::ResourceBundle accept the custom
@ -312,7 +315,7 @@ int ElectronBrowserMainParts::PreCreateThreads() {
ElectronBrowserClient::SetApplicationLocale(app_locale);
fake_browser_process_->SetApplicationLocale(app_locale);
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// Reset to the original LC_ALL since we should not be changing it.
if (!locale.empty()) {
if (lc_all)
@ -328,7 +331,7 @@ int ElectronBrowserMainParts::PreCreateThreads() {
// Force MediaCaptureDevicesDispatcher to be created on UI thread.
MediaCaptureDevicesDispatcher::GetInstance();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
ui::InitIdleMonitor();
#endif
@ -351,7 +354,7 @@ void ElectronBrowserMainParts::PostDestroyThreads() {
extensions_browser_client_.reset();
extensions::ExtensionsBrowserClient::Set(nullptr);
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
device::BluetoothAdapterFactory::Shutdown();
bluez::DBusBluezManagerWrapperLinux::Shutdown();
#endif
@ -359,7 +362,7 @@ void ElectronBrowserMainParts::PostDestroyThreads() {
}
void ElectronBrowserMainParts::ToolkitInitialized() {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
auto linux_ui = BuildGtkUi();
linux_ui->Initialize();
DCHECK(ui::LinuxInputMethodContextFactory::instance());
@ -384,12 +387,12 @@ void ElectronBrowserMainParts::ToolkitInitialized() {
wm_state_ = std::make_unique<wm::WMState>();
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
gfx::win::SetAdjustFontCallback(&AdjustUIFont);
gfx::win::SetGetMinimumFontSizeCallback(&GetMinimumFontSize);
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
views_delegate_ = std::make_unique<ViewsDelegateMac>();
#else
views_delegate_ = std::make_unique<ViewsDelegate>();
@ -439,7 +442,7 @@ int ElectronBrowserMainParts::PreMainMessageLoopRun() {
DevToolsManagerDelegate::StartHttpHandler();
}
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
// The corresponding call in macOS is in ElectronApplicationDelegate.
Browser::Get()->WillFinishLaunching();
Browser::Get()->DidFinishLaunching(base::DictionaryValue());
@ -459,14 +462,34 @@ void ElectronBrowserMainParts::WillRunMainMessageLoop(
}
void ElectronBrowserMainParts::PostCreateMainMessageLoop() {
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
auto shutdown_cb =
base::BindOnce(base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
ui::OzonePlatform::GetInstance()->PostCreateMainMessageLoop(
std::move(shutdown_cb));
bluez::DBusBluezManagerWrapperLinux::Initialize();
// Set up crypt config. This needs to be done before anything starts the
// network service, as the raw encryption key needs to be shared with the
// network service for encrypted cookie storage.
std::string app_name = electron::Browser::Get()->GetName();
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
std::unique_ptr<os_crypt::Config> config =
std::make_unique<os_crypt::Config>();
// Forward to os_crypt the flag to use a specific password store.
config->store = command_line.GetSwitchValueASCII(::switches::kPasswordStore);
config->product_name = app_name;
config->application_name = app_name;
config->main_thread_runner = base::ThreadTaskRunnerHandle::Get();
// c.f.
// https://source.chromium.org/chromium/chromium/src/+/master:chrome/common/chrome_switches.cc;l=689;drc=9d82515060b9b75fa941986f5db7390299669ef1
config->should_use_preference =
command_line.HasSwitch(::switches::kEnableEncryptionSelection);
base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path);
OSCrypt::SetConfig(std::move(config));
#endif
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// Exit in response to SIGINT, SIGTERM, etc.
InstallShutdownSignalHandlers(
base::BindOnce(&Browser::Quit, base::Unretained(Browser::Get())),
@ -475,7 +498,7 @@ void ElectronBrowserMainParts::PostCreateMainMessageLoop() {
}
void ElectronBrowserMainParts::PostMainMessageLoopRun() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
FreeAppDelegate();
#endif
@ -504,25 +527,25 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
fake_browser_process_->PostMainMessageLoopRun();
content::DevToolsAgentHost::StopRemoteDebuggingPipeHandler();
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
ui::OzonePlatform::GetInstance()->PostMainMessageLoopRun();
#endif
}
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
void ElectronBrowserMainParts::PreCreateMainMessageLoop() {
PreCreateMainMessageLoopCommon();
}
#endif
void ElectronBrowserMainParts::PreCreateMainMessageLoopCommon() {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
InitializeMainNib();
RegisterURLHandler();
#endif
media::SetLocalizedStringProvider(MediaStringProvider);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
auto* local_state = g_browser_process->local_state();
DCHECK(local_state);
@ -540,7 +563,7 @@ ElectronBrowserMainParts::GetGeolocationControl() {
return geolocation_control_.get();
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
device::GeolocationManager* ElectronBrowserMainParts::GetGeolocationManager() {
return geolocation_manager_.get();
}

View file

@ -63,11 +63,11 @@ class ElectronExtensionsBrowserClient;
class ViewsDelegate;
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
class ViewsDelegateMac;
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
class DarkThemeObserver;
#endif
@ -92,7 +92,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
// used to enable the location services once per client.
device::mojom::GeolocationControl* GetGeolocationControl();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
device::GeolocationManager* GetGeolocationManager();
#endif
@ -120,7 +120,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
private:
void PreCreateMainMessageLoopCommon();
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// Set signal handlers.
void HandleSIGCHLD();
void InstallShutdownSignalHandlers(
@ -128,13 +128,13 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void FreeAppDelegate();
void RegisterURLHandler();
void InitializeMainNib();
#endif
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
std::unique_ptr<ViewsDelegateMac> views_delegate_;
#else
std::unique_ptr<ViewsDelegate> views_delegate_;
@ -145,7 +145,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
std::unique_ptr<display::Screen> screen_;
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// Used to notify the native theme of changes to dark mode.
std::unique_ptr<DarkThemeObserver> dark_theme_observer_;
#endif
@ -174,7 +174,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
mojo::Remote<device::mojom::GeolocationControl> geolocation_control_;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
std::unique_ptr<device::GeolocationManager> geolocation_manager_;
#endif

View file

@ -5,11 +5,11 @@
#include "shell/browser/electron_download_manager_delegate.h"
#include <string>
#include <tuple>
#include <utility>
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread_restrictions.h"
@ -138,7 +138,7 @@ void ElectronDownloadManagerDelegate::OnDownloadPathGenerated(
&ElectronDownloadManagerDelegate::OnDownloadSaveDialogDone,
base::Unretained(this), download_id, std::move(callback));
ignore_result(dialog_promise.Then(std::move(dialog_callback)));
std::ignore = dialog_promise.Then(std::move(dialog_callback));
file_dialog::ShowSaveDialog(settings, std::move(dialog_promise));
} else {
std::move(callback).Run(path,

View file

@ -6,7 +6,7 @@
#include "base/environment.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
@ -15,7 +15,7 @@ namespace electron {
ElectronGpuClient::ElectronGpuClient() = default;
void ElectronGpuClient::PreCreateMessageLoop() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
auto env = base::Environment::Create();
if (env->HasVar("ELECTRON_DEFAULT_ERROR_MODE"))
SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX);

View file

@ -4,11 +4,22 @@
#include "shell/browser/electron_pdf_web_contents_helper_client.h"
#include "chrome/browser/pdf/pdf_frame_util.h"
#include "content/public/browser/web_contents.h"
ElectronPDFWebContentsHelperClient::ElectronPDFWebContentsHelperClient() =
default;
ElectronPDFWebContentsHelperClient::~ElectronPDFWebContentsHelperClient() =
default;
content::RenderFrameHost* ElectronPDFWebContentsHelperClient::FindPdfFrame(
content::WebContents* contents) {
content::RenderFrameHost* main_frame = contents->GetMainFrame();
content::RenderFrameHost* pdf_frame =
pdf_frame_util::FindPdfChildFrame(main_frame);
return pdf_frame ? pdf_frame : main_frame;
}
void ElectronPDFWebContentsHelperClient::UpdateContentRestrictions(
content::WebContents* contents,
int content_restrictions) {}

View file

@ -18,6 +18,8 @@ class ElectronPDFWebContentsHelperClient
private:
// pdf::PDFWebContentsHelperClient
content::RenderFrameHost* FindPdfFrame(
content::WebContents* contents) override;
void UpdateContentRestrictions(content::WebContents* contents,
int content_restrictions) override;
void OnPDFHasUnsupportedFeature(content::WebContents* contents) override;

View file

@ -332,7 +332,7 @@ bool ElectronPermissionManager::CheckDevicePermission(
} else if (permission ==
static_cast<content::PermissionType>(
WebContentsPermissionHelper::PermissionType::SERIAL)) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (device->FindStringKey(kDeviceInstanceIdKey) ==
granted_device.FindStringKey(kDeviceInstanceIdKey))
return true;
@ -346,14 +346,14 @@ bool ElectronPermissionManager::CheckDevicePermission(
continue;
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
if (*device->FindStringKey(kUsbDriverKey) !=
*granted_device.FindStringKey(kUsbDriverKey)) {
continue;
}
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
return true;
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
}
}
}

View file

@ -12,7 +12,6 @@ function_registration("api_registration") {
sources = [
"//electron/shell/common/extensions/api/cryptotoken_private.idl",
"//electron/shell/common/extensions/api/extension.json",
"//electron/shell/common/extensions/api/i18n.json",
"//electron/shell/common/extensions/api/resources_private.idl",
"//electron/shell/common/extensions/api/tabs.json",
]

View file

@ -34,10 +34,10 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "url/origin.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "device/fido/features.h"
#include "device/fido/win/webauthn_api.h"
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
namespace extensions {
@ -222,7 +222,7 @@ CryptotokenPrivateCanAppIdGetAttestationFunction::Run() {
return RespondNow(OneArgument(base::Value(true)));
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// If the request was handled by the Windows WebAuthn API on a version of
// Windows that shows an attestation permission prompt, don't show another
// one.
@ -237,7 +237,7 @@ CryptotokenPrivateCanAppIdGetAttestationFunction::Run() {
WEBAUTHN_API_VERSION_2) {
return RespondNow(OneArgument(base::Value(true)));
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
// Otherwise, show a permission prompt and pass the user's decision back.
const GURL app_id_url(app_id);

View file

@ -1,24 +0,0 @@
// Copyright (c) 2020 Samuel Maddock <sam@samuelmaddock.com>.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/extensions/api/i18n/i18n_api.h"
#include <string>
#include <vector>
#include "chrome/browser/browser_process.h"
#include "shell/common/extensions/api/i18n.h"
namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages;
namespace extensions {
ExtensionFunction::ResponseAction I18nGetAcceptLanguagesFunction::Run() {
auto locale = g_browser_process->GetApplicationLocale();
std::vector<std::string> accept_languages = {locale};
return RespondNow(
ArgumentList(GetAcceptLanguages::Results::Create(accept_languages)));
}
} // namespace extensions

View file

@ -1,20 +0,0 @@
// Copyright (c) 2020 Samuel Maddock <sam@samuelmaddock.com>.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
#define ELECTRON_SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
#include "extensions/browser/extension_function.h"
namespace extensions {
class I18nGetAcceptLanguagesFunction : public ExtensionFunction {
~I18nGetAcceptLanguagesFunction() override {}
ResponseAction Run() override;
DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES)
};
} // namespace extensions
#endif // ELECTRON_SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_

View file

@ -212,8 +212,7 @@ void ElectronExtensionSystem::RegisterExtensionWithRequestContexts(
}
void ElectronExtensionSystem::UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionReason reason) {}
const std::string& extension_id) {}
const base::OneShotEvent& ElectronExtensionSystem::ready() const {
return ready_;

View file

@ -76,8 +76,7 @@ class ElectronExtensionSystem : public ExtensionSystem {
const Extension* extension,
base::OnceClosure callback) override;
void UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionReason reason) override;
const std::string& extension_id) override;
const base::OneShotEvent& ready() const override;
bool is_ready() const override;
ContentVerifier* content_verifier() override;

View file

@ -4,9 +4,9 @@
#include "shell/browser/extensions/electron_extensions_browser_api_provider.h"
#include "extensions/browser/api/i18n/i18n_api.h"
#include "extensions/browser/extension_function_registry.h"
#include "shell/browser/extensions/api/generated_api_registration.h"
#include "shell/browser/extensions/api/i18n/i18n_api.h"
#include "shell/browser/extensions/api/tabs/tabs_api.h"
namespace extensions {

View file

@ -32,17 +32,11 @@ void InitializeFeatureList() {
disable_features +=
std::string(",") + features::kSpareRendererForSitePerProcess.name;
// PlzServiceWorker breaks fetching service worker scripts for custom
// protocols or chrome-extension protocols due to a change in the URL loader
// used to fetch the script.
// TODO(MarshallOfSound): Re-enable and fix?
disable_features += std::string(",") + features::kPlzServiceWorker.name;
#if !BUILDFLAG(ENABLE_PICTURE_IN_PICTURE)
disable_features += std::string(",") + media::kPictureInPicture.name;
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Disable async spellchecker suggestions for Windows, which causes
// an empty suggestions list to be returned
disable_features +=

View file

@ -108,14 +108,14 @@ void FileSelectHelper::FileSelectedWithExtraInfo(
std::vector<ui::SelectedFileInfo> files;
files.push_back(file);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
base::ThreadPool::PostTask(
FROM_HERE,
{base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&FileSelectHelper::ProcessSelectedFilesMac, this, files));
#else
ConvertToFileChooserFileInfoList(files);
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
}
void FileSelectHelper::MultiFilesSelected(
@ -130,14 +130,14 @@ void FileSelectHelper::MultiFilesSelected(
void FileSelectHelper::MultiFilesSelectedWithExtraInfo(
const std::vector<ui::SelectedFileInfo>& files,
void* params) {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
base::ThreadPool::PostTask(
FROM_HERE,
{base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&FileSelectHelper::ProcessSelectedFilesMac, this, files));
#else
ConvertToFileChooserFileInfoList(files);
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
}
void FileSelectHelper::FileSelectionCanceled(void* params) {

View file

@ -129,7 +129,7 @@ class FileSelectHelper : public base::RefCountedThreadSafe<
// callback is received from the enumeration code.
void EnumerateDirectoryEnd();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Must be called from a MayBlock() task. Each selected file that is a package
// will be zipped, and the zip will be passed to the render view host in place
// of the package.
@ -145,7 +145,7 @@ class FileSelectHelper : public base::RefCountedThreadSafe<
// temporary destination, if the zip was successful. Otherwise returns an
// empty path.
static base::FilePath ZipPackage(const base::FilePath& path);
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
void ConvertToFileChooserFileInfoList(
const std::vector<ui::SelectedFileInfo>& files);

View file

@ -1,42 +0,0 @@
// Copyright (c) 2021 Microsoft, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include <utility>
#include "shell/browser/font/electron_font_access_delegate.h"
#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/font_access_chooser.h"
#include "content/public/browser/render_frame_host.h"
class ElectronFontAccessChooser : public content::FontAccessChooser {
public:
explicit ElectronFontAccessChooser(base::OnceClosure close_callback) {
base::PostTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(
[](base::OnceClosure closure) { std::move(closure).Run(); },
std::move(close_callback)));
}
~ElectronFontAccessChooser() override = default;
};
ElectronFontAccessDelegate::ElectronFontAccessDelegate() = default;
ElectronFontAccessDelegate::~ElectronFontAccessDelegate() = default;
std::unique_ptr<content::FontAccessChooser>
ElectronFontAccessDelegate::RunChooser(
content::RenderFrameHost* frame,
const std::vector<std::string>& selection,
content::FontAccessChooser::Callback callback) {
// TODO(codebytere) : implement with proper permissions model.
return std::make_unique<ElectronFontAccessChooser>(base::BindOnce(
[](content::FontAccessChooser::Callback callback) {
std::move(callback).Run(
blink::mojom::FontEnumerationStatus::kUnimplemented, {});
},
std::move(callback)));
}

View file

@ -1,31 +0,0 @@
// Copyright (c) 2021 Microsoft, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_FONT_ELECTRON_FONT_ACCESS_DELEGATE_H_
#define ELECTRON_SHELL_BROWSER_FONT_ELECTRON_FONT_ACCESS_DELEGATE_H_
#include <memory>
#include <string>
#include <vector>
#include "content/public/browser/font_access_chooser.h"
#include "content/public/browser/font_access_delegate.h"
class ElectronFontAccessDelegate : public content::FontAccessDelegate {
public:
ElectronFontAccessDelegate();
~ElectronFontAccessDelegate() override;
// disable copy
ElectronFontAccessDelegate(const ElectronFontAccessDelegate&) = delete;
ElectronFontAccessDelegate& operator=(const ElectronFontAccessDelegate&) =
delete;
std::unique_ptr<content::FontAccessChooser> RunChooser(
content::RenderFrameHost* frame,
const std::vector<std::string>& selection,
content::FontAccessChooser::Callback callback) override;
};
#endif // ELECTRON_SHELL_BROWSER_FONT_ELECTRON_FONT_ACCESS_DELEGATE_H_

View file

@ -41,7 +41,7 @@ const FontDefault kFontDefaults[] = {
{prefs::kWebKitSansSerifFontFamily, IDS_SANS_SERIF_FONT_FAMILY},
{prefs::kWebKitCursiveFontFamily, IDS_CURSIVE_FONT_FAMILY},
{prefs::kWebKitFantasyFontFamily, IDS_FANTASY_FONT_FAMILY},
#if defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
{prefs::kWebKitStandardFontFamilyJapanese,
IDS_STANDARD_FONT_FAMILY_JAPANESE},
{prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE},
@ -65,13 +65,13 @@ const FontDefault kFontDefaults[] = {
{prefs::kWebKitSansSerifFontFamilyTraditionalHan,
IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN},
#endif
#if defined(OS_MAC) || defined(OS_WIN)
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
{prefs::kWebKitCursiveFontFamilySimplifiedHan,
IDS_CURSIVE_FONT_FAMILY_SIMPLIFIED_HAN},
{prefs::kWebKitCursiveFontFamilyTraditionalHan,
IDS_CURSIVE_FONT_FAMILY_TRADITIONAL_HAN},
#endif
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS)
{prefs::kWebKitStandardFontFamilyArabic, IDS_STANDARD_FONT_FAMILY_ARABIC},
{prefs::kWebKitSerifFontFamilyArabic, IDS_SERIF_FONT_FAMILY_ARABIC},
{prefs::kWebKitSansSerifFontFamilyArabic,
@ -81,7 +81,7 @@ const FontDefault kFontDefaults[] = {
IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN},
{prefs::kWebKitFixedFontFamilyTraditionalHan,
IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
{prefs::kWebKitFixedFontFamilyArabic, IDS_FIXED_FONT_FAMILY_ARABIC},
{prefs::kWebKitSansSerifFontFamilyArabic,
IDS_SANS_SERIF_FONT_FAMILY_ARABIC},

View file

@ -76,6 +76,13 @@ bool ElectronHidDelegate::HasDevicePermission(
render_frame_host);
}
void ElectronHidDelegate::RevokeDevicePermission(
content::RenderFrameHost* render_frame_host,
const device::mojom::HidDeviceInfo& device) {
// TODO(jkleinsc) implement this for
// https://chromium-review.googlesource.com/c/chromium/src/+/3297868
}
device::mojom::HidManager* ElectronHidDelegate::GetHidManager(
content::RenderFrameHost* render_frame_host) {
auto* chooser_context = GetChooserContext(render_frame_host);
@ -104,7 +111,9 @@ const device::mojom::HidDeviceInfo* ElectronHidDelegate::GetDeviceInfo(
return chooser_context->GetDeviceInfo(guid);
}
bool ElectronHidDelegate::IsFidoAllowedForOrigin(const url::Origin& origin) {
bool ElectronHidDelegate::IsFidoAllowedForOrigin(
content::RenderFrameHost* render_frame_host,
const url::Origin& origin) {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableHidBlocklist);
}

View file

@ -36,6 +36,9 @@ class ElectronHidDelegate : public content::HidDelegate,
content::RenderFrameHost* render_frame_host) override;
bool HasDevicePermission(content::RenderFrameHost* render_frame_host,
const device::mojom::HidDeviceInfo& device) override;
void RevokeDevicePermission(
content::RenderFrameHost* render_frame_host,
const device::mojom::HidDeviceInfo& device) override;
device::mojom::HidManager* GetHidManager(
content::RenderFrameHost* render_frame_host) override;
void AddObserver(content::RenderFrameHost* render_frame_host,
@ -45,7 +48,8 @@ class ElectronHidDelegate : public content::HidDelegate,
const device::mojom::HidDeviceInfo* GetDeviceInfo(
content::RenderFrameHost* render_frame_host,
const std::string& guid) override;
bool IsFidoAllowedForOrigin(const url::Origin& origin) override;
bool IsFidoAllowedForOrigin(content::RenderFrameHost* render_frame_host,
const url::Origin& origin) override;
// HidChooserContext::DeviceObserver:
void OnDeviceAdded(const device::mojom::HidDeviceInfo&) override;

View file

@ -76,11 +76,6 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
enum InitializationPolicy { kZeroInitialize, kDontInitialize };
base::PartitionOptions::LazyCommit lazy_commit =
base::FeatureList::IsEnabled(base::features::kPartitionAllocLazyCommit)
? base::PartitionOptions::LazyCommit::kEnabled
: base::PartitionOptions::LazyCommit::kDisabled;
ArrayBufferAllocator() {
// Ref.
// https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/wtf/allocator/partitions.cc;l=94;drc=062c315a858a87f834e16a144c2c8e9591af2beb
@ -89,8 +84,7 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
base::PartitionOptions::Quarantine::kAllowed,
base::PartitionOptions::Cookie::kAllowed,
base::PartitionOptions::BackupRefPtr::kDisabled,
base::PartitionOptions::UseConfigurablePool::kNo,
lazy_commit});
base::PartitionOptions::UseConfigurablePool::kNo});
}
// Allocate() methods return null to signal allocation failure to V8, which

View file

@ -21,7 +21,7 @@
#include "shell/common/options_switches.h"
#include "ui/views/widget/widget.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "ui/base/win/shell.h"
#include "ui/display/win/screen_win.h"
#endif
@ -44,7 +44,7 @@ struct Converter<electron::NativeWindow::TitleBarStyle> {
return false;
if (title_bar_style == "hidden") {
*out = TitleBarStyle::kHidden;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
} else if (title_bar_style == "hiddenInset") {
*out = TitleBarStyle::kHiddenInset;
} else if (title_bar_style == "customButtonsOnHover") {
@ -63,7 +63,7 @@ namespace electron {
namespace {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
if (!window->transparent() || !ui::win::IsAeroGlassEnabled())
return size;
@ -105,7 +105,7 @@ NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
if (titlebar_overlay.Get(options::kOverlayHeight, &height))
titlebar_overlay_height_ = height;
#if !(defined(OS_WIN) || defined(OS_MAC))
#if !(BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC))
DCHECK(false);
#endif
}
@ -144,7 +144,7 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
if (options.Get(options::kX, &x) && options.Get(options::kY, &y)) {
SetPosition(gfx::Point(x, y));
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// FIXME(felixrieseberg): Dirty, dirty workaround for
// https://github.com/electron/electron/issues/10862
// Somehow, we need to call `SetBounds` twice to get
@ -176,7 +176,7 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
} else {
SetSizeConstraints(size_constraints);
}
#if defined(OS_WIN) || defined(OS_LINUX)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
bool resizable;
if (options.Get(options::kResizable, &resizable)) {
SetResizable(resizable);
@ -206,7 +206,7 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
bool fullscreen = false;
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) {
// Disable fullscreen button if 'fullscreen' is specified to false.
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
fullscreenable = false;
#endif
}
@ -224,7 +224,7 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
if (options.Get(options::kKiosk, &kiosk) && kiosk) {
SetKiosk(kiosk);
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
std::string type;
if (options.Get(options::kVibrancyType, &type)) {
SetVibrancy(type);
@ -355,7 +355,7 @@ gfx::Size NativeWindow::GetContentMinimumSize() const {
gfx::Size NativeWindow::GetContentMaximumSize() const {
gfx::Size maximum_size = GetContentSizeConstraints().GetMaximumSize();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return GetContentSizeConstraints().HasMaximumSize()
? GetExpandedWindowSize(this, maximum_size)
: maximum_size;
@ -676,7 +676,7 @@ void NativeWindow::NotifyLayoutWindowControlsOverlay() {
}
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void NativeWindow::NotifyWindowMessage(UINT message,
WPARAM w_param,
LPARAM l_param) {

View file

@ -46,7 +46,7 @@ namespace electron {
class ElectronMenuModel;
class NativeBrowserView;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
typedef NSView* NativeWindowHandle;
#else
typedef gfx::AcceleratedWidget NativeWindowHandle;
@ -138,7 +138,7 @@ class NativeWindow : public base::SupportsUserData,
virtual void Invalidate() = 0;
virtual void SetTitle(const std::string& title) = 0;
virtual std::string GetTitle() = 0;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
virtual std::string GetAlwaysOnTopLevel() = 0;
virtual void SetActive(bool is_key) = 0;
virtual bool IsActive() const = 0;
@ -209,7 +209,7 @@ class NativeWindow : public base::SupportsUserData,
virtual void SetVibrancy(const std::string& type);
// Traffic Light API
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
virtual void SetWindowButtonVisibility(bool visible) = 0;
virtual bool GetWindowButtonVisibility() const = 0;
virtual void SetTrafficLightPosition(absl::optional<gfx::Point> position) = 0;
@ -308,7 +308,7 @@ class NativeWindow : public base::SupportsUserData,
void NotifyWindowSystemContextMenu(int x, int y, bool* prevent_default);
void NotifyLayoutWindowControlsOverlay();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param);
#endif

View file

@ -11,7 +11,7 @@
#include "base/values.h"
#include "ui/base/window_open_disposition.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
@ -98,7 +98,7 @@ class NativeWindowObserver : public base::CheckedObserver {
virtual void OnSystemContextMenu(int x, int y, bool* prevent_default) {}
// Called when window message received
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
virtual void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {}
#endif

View file

@ -4,7 +4,7 @@
#include "shell/browser/native_window_views.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <wrl/client.h>
#endif
@ -44,7 +44,7 @@
#include "ui/wm/core/shadow_types.h"
#include "ui/wm/core/window_util.h"
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "base/strings/string_util.h"
#include "shell/browser/browser.h"
#include "shell/browser/linux/unity_service.h"
@ -71,7 +71,7 @@
#include "ui/base/ui_base_features.h"
#endif
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
#include "base/win/win_util.h"
#include "content/public/common/color_parser.h"
#include "shell/browser/ui/views/win_frame_view.h"
@ -85,7 +85,7 @@
namespace electron {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Similar to the ones in display::win::ScreenWin, but with rounded values
// These help to avoid problems that arise from unresizable windows where the
@ -103,7 +103,7 @@ gfx::Rect ScreenToDIPRect(HWND hwnd, const gfx::Rect& pixel_bounds) {
namespace {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
const LPCWSTR kUniqueTaskBarClassName = L"Shell_TrayWnd";
void FlipWindowStyle(HWND handle, bool on, DWORD flag) {
@ -165,7 +165,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
if (options.Get(options::kAutoHideMenuBar, &menu_bar_autohide))
root_view_->SetAutoHideMenuBar(menu_bar_autohide);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// On Windows we rely on the CanResize() to indicate whether window can be
// resized, and it should be set before window is created.
options.Get(options::kResizable, &resizable_);
@ -244,12 +244,12 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
if (options.Get(options::kFocusable, &focusable) && !focusable)
params.activatable = views::Widget::InitParams::Activatable::kNo;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (parent)
params.parent = parent->GetNativeWindow();
params.native_widget = new ElectronDesktopNativeWidgetAura(this);
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
std::string name = Browser::Get()->GetName();
// Set WM_WINDOW_ROLE.
params.wm_role_name = "browser-window";
@ -285,7 +285,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
}
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
if (parent)
SetParentWindow(parent);
#endif
@ -324,7 +324,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
window_type);
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (!has_frame()) {
// Set Window style so that we get a minimize and maximize animation when
// frameless.
@ -351,7 +351,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
// we should check whether setting it in InitParams can work.
widget()->set_frame_type(views::Widget::FrameType::kForceNative);
widget()->FrameTypeChanged();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// thickFrame also works for normal window.
if (!thick_frame_)
FlipWindowStyle(GetAcceleratedWidget(), false, WS_THICKFRAME);
@ -369,7 +369,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
widget()->CenterWindow(size);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Save initial window state.
if (fullscreen)
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
@ -382,7 +382,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
if (window)
window->AddPreTargetHandler(this);
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
// On linux after the widget is initialized we might have to force set the
// bounds if the bounds are smaller than the current display
SetBounds(gfx::Rect(GetPosition(), bounds.size()), false);
@ -407,7 +407,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
NativeWindowViews::~NativeWindowViews() {
widget()->RemoveObserver(this);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Disable mouse forwarding to relinquish resources, should any be held.
SetForwardMouseMessages(false);
#endif
@ -507,7 +507,7 @@ void NativeWindowViews::Hide() {
global_menu_bar_->OnWindowUnmapped();
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// When the window is removed from the taskbar via win.hide(),
// the thumbnail buttons need to be set up again.
// Ensure that when the window is hidden,
@ -521,9 +521,9 @@ bool NativeWindowViews::IsVisible() {
}
bool NativeWindowViews::IsEnabled() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return ::IsWindowEnabled(GetAcceleratedWidget());
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
#if defined(USE_X11)
return !event_disabler_.get();
#endif
@ -562,7 +562,7 @@ void NativeWindowViews::SetEnabledInternal(bool enable) {
return;
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
::EnableWindow(GetAcceleratedWidget(), enable);
#elif defined(USE_X11)
views::DesktopWindowTreeHostPlatform* tree_host =
@ -578,7 +578,7 @@ void NativeWindowViews::SetEnabledInternal(bool enable) {
#endif
}
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
void NativeWindowViews::Maximize() {
if (IsVisible())
widget()->Maximize();
@ -590,7 +590,7 @@ void NativeWindowViews::Maximize() {
void NativeWindowViews::Unmaximize() {
if (IsMaximized()) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (transparent()) {
SetBounds(restore_bounds_, false);
NotifyWindowUnmaximize();
@ -606,7 +606,7 @@ bool NativeWindowViews::IsMaximized() {
if (widget()->IsMaximized()) {
return true;
} else {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (transparent()) {
// Compare the size of the window with the size of the display
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
@ -641,7 +641,7 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
if (!IsFullScreenable())
return;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// There is no native fullscreen state on Windows.
bool leaving_fullscreen = IsFullscreen() && !fullscreen;
@ -697,7 +697,7 @@ bool NativeWindowViews::IsFullscreen() const {
}
void NativeWindowViews::SetBounds(const gfx::Rect& bounds, bool animate) {
#if defined(OS_WIN) || defined(OS_LINUX)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
// On Linux and Windows the minimum and maximum size should be updated with
// window size when window is not resizable.
if (!resizable_) {
@ -710,7 +710,7 @@ void NativeWindowViews::SetBounds(const gfx::Rect& bounds, bool animate) {
}
gfx::Rect NativeWindowViews::GetBounds() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (IsMinimized())
return widget()->GetRestoredBounds();
#endif
@ -723,7 +723,7 @@ gfx::Rect NativeWindowViews::GetContentBounds() {
}
gfx::Size NativeWindowViews::GetContentSize() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (IsMinimized())
return NativeWindow::GetContentSize();
#endif
@ -738,7 +738,7 @@ gfx::Rect NativeWindowViews::GetNormalBounds() {
void NativeWindowViews::SetContentSizeConstraints(
const extensions::SizeConstraints& size_constraints) {
NativeWindow::SetContentSizeConstraints(size_constraints);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Changing size constraints would force adding the WS_THICKFRAME style, so
// do nothing if thickFrame is false.
if (!thick_frame_)
@ -767,7 +767,7 @@ void NativeWindowViews::SetResizable(bool resizable) {
extensions::SizeConstraints(content_size, content_size));
}
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (has_frame() && thick_frame_)
FlipWindowStyle(GetAcceleratedWidget(), resizable, WS_THICKFRAME);
#endif
@ -780,7 +780,7 @@ bool NativeWindowViews::MoveAbove(const std::string& sourceId) {
if (id.type != content::DesktopMediaID::TYPE_WINDOW)
return false;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
const HWND otherWindow = reinterpret_cast<HWND>(id.id);
if (!::IsWindow(otherWindow))
return false;
@ -802,7 +802,7 @@ bool NativeWindowViews::MoveAbove(const std::string& sourceId) {
void NativeWindowViews::MoveTop() {
// TODO(julien.isorce): fix chromium in order to use existing
// widget()->StackAtTop().
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
gfx::Point pos = GetPosition();
gfx::Size size = GetSize();
::SetWindowPos(GetAcceleratedWidget(), HWND_TOP, pos.x(), pos.y(),
@ -815,7 +815,7 @@ void NativeWindowViews::MoveTop() {
}
bool NativeWindowViews::IsResizable() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (has_frame())
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME;
#endif
@ -837,7 +837,7 @@ void NativeWindowViews::SetMovable(bool movable) {
}
bool NativeWindowViews::IsMovable() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return movable_;
#else
return true; // Not implemented on Linux.
@ -845,14 +845,14 @@ bool NativeWindowViews::IsMovable() {
}
void NativeWindowViews::SetMinimizable(bool minimizable) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
FlipWindowStyle(GetAcceleratedWidget(), minimizable, WS_MINIMIZEBOX);
#endif
minimizable_ = minimizable;
}
bool NativeWindowViews::IsMinimizable() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_MINIMIZEBOX;
#else
return true; // Not implemented on Linux.
@ -860,14 +860,14 @@ bool NativeWindowViews::IsMinimizable() {
}
void NativeWindowViews::SetMaximizable(bool maximizable) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
FlipWindowStyle(GetAcceleratedWidget(), maximizable, WS_MAXIMIZEBOX);
#endif
maximizable_ = maximizable;
}
bool NativeWindowViews::IsMaximizable() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_MAXIMIZEBOX;
#else
return true; // Not implemented on Linux.
@ -890,7 +890,7 @@ bool NativeWindowViews::IsFullScreenable() {
}
void NativeWindowViews::SetClosable(bool closable) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
HMENU menu = GetSystemMenu(GetAcceleratedWidget(), false);
if (closable) {
EnableMenuItem(menu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED);
@ -901,7 +901,7 @@ void NativeWindowViews::SetClosable(bool closable) {
}
bool NativeWindowViews::IsClosable() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
HMENU menu = GetSystemMenu(GetAcceleratedWidget(), false);
MENUITEMINFO info;
memset(&info, 0, sizeof(info));
@ -911,7 +911,7 @@ bool NativeWindowViews::IsClosable() {
return false;
}
return !(info.fState & MFS_DISABLED);
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
return true;
#endif
}
@ -922,7 +922,7 @@ void NativeWindowViews::SetAlwaysOnTop(ui::ZOrderLevel z_order,
bool level_changed = z_order != widget()->GetZOrderLevel();
widget()->SetZOrderLevel(z_order);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Reset the placement flag.
behind_task_bar_ = false;
if (z_order != ui::ZOrderLevel::kNormal) {
@ -963,7 +963,7 @@ std::string NativeWindowViews::GetTitle() {
}
void NativeWindowViews::FlashFrame(bool flash) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// The Chromium's implementation has a bug stopping flash.
if (!flash) {
FLASHWINFO fwi;
@ -979,7 +979,7 @@ void NativeWindowViews::FlashFrame(bool flash) {
}
void NativeWindowViews::SetSkipTaskbar(bool skip) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
Microsoft::WRL::ComPtr<ITaskbarList> taskbar;
if (FAILED(::CoCreateInstance(CLSID_TaskbarList, nullptr,
CLSCTX_INPROC_SERVER,
@ -1015,8 +1015,8 @@ bool NativeWindowViews::IsKiosk() {
}
bool NativeWindowViews::IsTabletMode() const {
#if defined(OS_WIN)
return base::win::IsWindows10TabletMode(GetAcceleratedWidget());
#if BUILDFLAG(IS_WIN)
return base::win::IsWindows10OrGreaterTabletMode(GetAcceleratedWidget());
#else
return false;
#endif
@ -1033,7 +1033,7 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) {
// web views' background color.
root_view_->SetBackground(views::CreateSolidBackground(background_color));
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Set the background color of native window.
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
ULONG_PTR previous_brush =
@ -1057,7 +1057,7 @@ bool NativeWindowViews::HasShadow() {
}
void NativeWindowViews::SetOpacity(const double opacity) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
const double boundedOpacity = base::clamp(opacity, 0.0, 1.0);
HWND hwnd = GetAcceleratedWidget();
if (!layered_) {
@ -1078,7 +1078,7 @@ double NativeWindowViews::GetOpacity() {
}
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
if (ignore)
ex_style |= (WS_EX_TRANSPARENT | WS_EX_LAYERED);
@ -1117,7 +1117,7 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
}
void NativeWindowViews::SetContentProtection(bool enable) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
HWND hwnd = GetAcceleratedWidget();
DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE;
::SetWindowDisplayAffinity(hwnd, affinity);
@ -1134,7 +1134,7 @@ void NativeWindowViews::SetContentProtection(bool enable) {
void NativeWindowViews::SetFocusable(bool focusable) {
widget()->widget_delegate()->SetCanActivate(focusable);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
if (focusable)
ex_style &= ~WS_EX_NOACTIVATE;
@ -1148,7 +1148,7 @@ void NativeWindowViews::SetFocusable(bool focusable) {
bool NativeWindowViews::IsFocusable() {
bool can_activate = widget()->widget_delegate()->CanActivate();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
bool no_activate = ex_style & WS_EX_NOACTIVATE;
return !no_activate && can_activate;
@ -1260,7 +1260,7 @@ void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
x11::Atom::WM_TRANSIENT_FOR, x11::Atom::WINDOW,
parent ? static_cast<x11::Window>(parent->GetAcceleratedWidget())
: ui::GetX11RootWindow());
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
// To set parentship between windows into Windows is better to play with the
// owner instead of the parent, as Windows natively seems to do if a parent
// is specified at window creation time.
@ -1295,9 +1295,9 @@ gfx::NativeWindow NativeWindowViews::GetNativeWindow() const {
void NativeWindowViews::SetProgressBar(double progress,
NativeWindow::ProgressState state) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
taskbar_host_.SetProgressBar(GetAcceleratedWidget(), progress, state);
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
if (unity::IsRunning()) {
unity::SetProgressFraction(progress);
}
@ -1306,7 +1306,7 @@ void NativeWindowViews::SetProgressBar(double progress,
void NativeWindowViews::SetOverlayIcon(const gfx::Image& overlay,
const std::string& description) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
SkBitmap overlay_bitmap = overlay.AsBitmap();
taskbar_host_.SetOverlayIcon(GetAcceleratedWidget(), overlay_bitmap,
description);
@ -1355,10 +1355,10 @@ content::DesktopMediaID NativeWindowViews::GetDesktopMediaID() const {
const gfx::AcceleratedWidget accelerated_widget = GetAcceleratedWidget();
content::DesktopMediaID::Id window_handle = content::DesktopMediaID::kNullId;
content::DesktopMediaID::Id aura_id = content::DesktopMediaID::kNullId;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
window_handle =
reinterpret_cast<content::DesktopMediaID::Id>(accelerated_widget);
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
window_handle = static_cast<uint32_t>(accelerated_widget);
#endif
aura::WindowTreeHost* const host =
@ -1399,7 +1399,7 @@ gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
return bounds;
gfx::Rect window_bounds(bounds);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (widget()->non_client_view()) {
HWND hwnd = GetAcceleratedWidget();
gfx::Rect dpi_bounds = DIPToScreenRect(hwnd, bounds);
@ -1423,7 +1423,7 @@ gfx::Rect NativeWindowViews::WindowBoundsToContentBounds(
return bounds;
gfx::Rect content_bounds(bounds);
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
HWND hwnd = GetAcceleratedWidget();
content_bounds.set_size(DIPToScreenRect(hwnd, content_bounds).size());
RECT rect;
@ -1449,7 +1449,7 @@ void NativeWindowViews::UpdateDraggableRegions(
draggable_region_ = DraggableRegionsToSkRegion(regions);
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) {
// We are responsible for storing the images.
window_icon_ = base::win::ScopedHICON(CopyIcon(window_icon));
@ -1461,7 +1461,7 @@ void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) {
SendMessage(hwnd, WM_SETICON, ICON_BIG,
reinterpret_cast<LPARAM>(app_icon_.get()));
}
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) {
auto* tree_host = views::DesktopWindowTreeHostLinux::GetHostForWidget(
GetAcceleratedWidget());
@ -1529,9 +1529,9 @@ bool NativeWindowViews::CanMaximize() const {
}
bool NativeWindowViews::CanMinimize() const {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return minimizable_;
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
return true;
#endif
}
@ -1578,7 +1578,7 @@ views::ClientView* NativeWindowViews::CreateClientView(views::Widget* widget) {
std::unique_ptr<views::NonClientFrameView>
NativeWindowViews::CreateNonClientFrameView(views::Widget* widget) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
auto frame_view = std::make_unique<WinFrameView>();
frame_view->Init(this, widget);
return frame_view;
@ -1605,7 +1605,7 @@ void NativeWindowViews::HandleKeyboardEvent(
if (widget_destroyed_)
return;
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
if (event.windows_key_code == ui::VKEY_BROWSER_BACK)
NotifyWindowExecuteAppCommand(kBrowserBackward);
else if (event.windows_key_code == ui::VKEY_BROWSER_FORWARD)
@ -1624,7 +1624,7 @@ void NativeWindowViews::OnMouseEvent(ui::MouseEvent* event) {
// Alt+Click should not toggle menu bar.
root_view_->ResetAltState();
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
if (event->changed_button_flags() == ui::EF_BACK_MOUSE_BUTTON)
NotifyWindowExecuteAppCommand(kBrowserBackward);
else if (event->changed_button_flags() == ui::EF_FORWARD_MOUSE_BUTTON)
@ -1634,7 +1634,7 @@ void NativeWindowViews::OnMouseEvent(ui::MouseEvent* event) {
ui::WindowShowState NativeWindowViews::GetRestoredState() {
if (IsMaximized()) {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Only restore Maximized state when window is NOT transparent style
if (!transparent()) {
return ui::SHOW_STATE_MAXIMIZED;
@ -1651,7 +1651,7 @@ ui::WindowShowState NativeWindowViews::GetRestoredState() {
}
void NativeWindowViews::MoveBehindTaskBarIfNeeded() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
if (behind_task_bar_) {
const HWND task_bar_hwnd = ::FindWindow(kUniqueTaskBarClassName, nullptr);
::SetWindowPos(GetAcceleratedWidget(), task_bar_hwnd, 0, 0, 0, 0,

View file

@ -15,7 +15,7 @@
#include "shell/common/api/api.mojom.h"
#include "ui/views/widget/widget_observer.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_gdi_object.h"
#include "shell/browser/ui/win/taskbar_host.h"
@ -35,7 +35,7 @@ class WindowStateWatcher;
class EventDisabler;
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
gfx::Rect ScreenToDIPRect(HWND hwnd, const gfx::Rect& pixel_bounds);
#endif
@ -153,7 +153,7 @@ class NativeWindowViews : public NativeWindow,
void IncrementChildModals();
void DecrementChildModals();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Catch-all message handling and filtering. Called before
// HWNDMessageHandler's built-in handling, which may pre-empt some
// expectations in Views/Aura if messages are consumed. Returns true if the
@ -165,17 +165,17 @@ class NativeWindowViews : public NativeWindow,
LPARAM l_param,
LRESULT* result);
void SetIcon(HICON small_icon, HICON app_icon);
#elif defined(OS_LINUX)
#elif BUILDFLAG(IS_LINUX)
void SetIcon(const gfx::ImageSkia& icon);
#endif
SkRegion* draggable_region() const { return draggable_region_.get(); }
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
TaskbarHost& taskbar_host() { return taskbar_host_; }
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool IsWindowControlsOverlayEnabled() const {
return (title_bar_style_ == NativeWindowViews::TitleBarStyle::kHidden) &&
titlebar_overlay_;
@ -205,11 +205,11 @@ class NativeWindowViews : public NativeWindow,
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override;
void OnWidgetMove() override;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
bool ExecuteWindowsCommand(int command_id) override;
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
void HandleSizeEvent(WPARAM w_param, LPARAM l_param);
void SetForwardMouseMessages(bool forward);
static LRESULT CALLBACK SubclassProc(HWND hwnd,
@ -262,7 +262,7 @@ class NativeWindowViews : public NativeWindow,
std::unique_ptr<EventDisabler> event_disabler_;
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
ui::WindowShowState last_window_state_;

View file

@ -4,13 +4,14 @@
#include <dwmapi.h>
#include <shellapi.h>
#include <wrl/client.h>
#include "base/win/atl.h" // Must be before UIAutomationCore.h
#include "content/public/browser/browser_accessibility_state.h"
#include "shell/browser/browser.h"
#include "shell/browser/native_window_views.h"
#include "shell/browser/ui/views/root_view.h"
#include "shell/common/electron_constants.h"
#include "ui/base/win/accessibility_misc_utils.h"
#include "ui/display/display.h"
#include "ui/display/win/screen_win.h"
#include "ui/gfx/geometry/insets.h"
@ -18,6 +19,7 @@
#include "ui/views/widget/native_widget_private.h"
// Must be included after other Windows headers.
#include <UIAutomationClient.h>
#include <UIAutomationCoreApi.h>
namespace electron {

View file

@ -270,7 +270,8 @@ class AsarURLLoader : public network::mojom::URLLoader {
head->headers->AddHeader(net::HttpRequestHeaders::kContentType,
head->mime_type.c_str());
}
client_->OnReceiveResponse(std::move(head));
client_->OnReceiveResponse(std::move(head),
mojo::ScopedDataPipeConsumerHandle());
client_->OnStartLoadingResponseBody(std::move(consumer_handle));
if (total_bytes_to_send == 0) {

View file

@ -559,7 +559,8 @@ void ElectronURLLoaderFactory::StartLoadingStream(
//
// Note that We must submit a empty body otherwise NetworkService would
// crash.
client_remote->OnReceiveResponse(std::move(head));
client_remote->OnReceiveResponse(std::move(head),
mojo::ScopedDataPipeConsumerHandle());
mojo::ScopedDataPipeProducerHandle producer;
mojo::ScopedDataPipeConsumerHandle consumer;
if (mojo::CreateDataPipe(nullptr, producer, consumer) != MOJO_RESULT_OK) {
@ -604,7 +605,8 @@ void ElectronURLLoaderFactory::SendContents(
// Add header to ignore CORS.
head->headers->AddHeader("Access-Control-Allow-Origin", "*");
client_remote->OnReceiveResponse(std::move(head));
client_remote->OnReceiveResponse(std::move(head),
mojo::ScopedDataPipeConsumerHandle());
// Code below follows the pattern of data_url_loader_factory.cc.
mojo::ScopedDataPipeProducerHandle producer;

View file

@ -23,11 +23,11 @@ namespace electron {
namespace {
bool ShouldTriggerNetworkDataMigration() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// On Windows, if sandbox enabled means data must be migrated.
if (SystemNetworkContextManager::IsNetworkSandboxEnabled())
return true;
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
if (base::FeatureList::IsEnabled(features::kTriggerNetworkDataMigration))
return true;
return false;

View file

@ -59,7 +59,8 @@ void NodeStreamLoader::Start(network::mojom::URLResponseHeadPtr head) {
}
producer_ = std::make_unique<mojo::DataPipeProducer>(std::move(producer));
client_->OnReceiveResponse(std::move(head));
client_->OnReceiveResponse(std::move(head),
mojo::ScopedDataPipeConsumerHandle());
client_->OnStartLoadingResponseBody(std::move(consumer));
auto weak = weak_factory_.GetWeakPtr();

View file

@ -242,7 +242,9 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveEarlyHints(
}
void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveResponse(
network::mojom::URLResponseHeadPtr head) {
network::mojom::URLResponseHeadPtr head,
mojo::ScopedDataPipeConsumerHandle body) {
current_body_ = std::move(body);
if (current_request_uses_header_client_) {
// Use the headers we got from OnHeadersReceived as that'll contain
// Set-Cookie if it existed.
@ -673,7 +675,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
proxied_client_receiver_.Resume();
factory_->web_request_api()->OnResponseStarted(&info_.value(), request_);
target_client_->OnReceiveResponse(current_response_.Clone());
target_client_->OnReceiveResponse(current_response_.Clone(),
std::move(current_body_));
}
void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(

View file

@ -88,7 +88,8 @@ class ProxyingURLLoaderFactory
// network::mojom::URLLoaderClient:
void OnReceiveEarlyHints(
network::mojom::EarlyHintsPtr early_hints) override;
void OnReceiveResponse(network::mojom::URLResponseHeadPtr head) override;
void OnReceiveResponse(network::mojom::URLResponseHeadPtr head,
mojo::ScopedDataPipeConsumerHandle body) override;
void OnReceiveRedirect(const net::RedirectInfo& redirect_info,
network::mojom::URLResponseHeadPtr head) override;
void OnUploadProgress(int64_t current_position,
@ -148,6 +149,7 @@ class ProxyingURLLoaderFactory
network::mojom::URLLoaderPtr target_loader_;
network::mojom::URLResponseHeadPtr current_response_;
mojo::ScopedDataPipeConsumerHandle current_body_;
scoped_refptr<net::HttpResponseHeaders> override_headers_;
GURL redirect_url_;

View file

@ -42,23 +42,23 @@
#include "shell/common/options_switches.h"
#include "url/gurl.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "components/os_crypt/keychain_password_mac.h"
#endif
#if defined(OS_LINUX)
#if BUILDFLAG(IS_LINUX)
#include "components/os_crypt/key_storage_config_linux.h"
#endif
namespace {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
namespace {
const char kNetworkServiceSandboxEnabled[] = "net.network_service_sandbox";
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
// The global instance of the SystemNetworkContextmanager.
SystemNetworkContextManager* g_system_network_context_manager = nullptr;
@ -67,9 +67,6 @@ network::mojom::HttpAuthStaticParamsPtr CreateHttpAuthStaticParams() {
network::mojom::HttpAuthStaticParamsPtr auth_static_params =
network::mojom::HttpAuthStaticParams::New();
auth_static_params->supported_schemes = {"basic", "digest", "ntlm",
"negotiate"};
return auth_static_params;
}
@ -86,6 +83,8 @@ network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams() {
command_line->HasSwitch(electron::switches::kEnableAuthNegotiatePort);
auth_dynamic_params->ntlm_v2_enabled =
!command_line->HasSwitch(electron::switches::kDisableNTLMv2);
auth_dynamic_params->allowed_schemes = {"basic", "digest", "ntlm",
"negotiate"};
return auth_dynamic_params;
}
@ -233,12 +232,12 @@ void SystemNetworkContextManager::DeleteInstance() {
// c.f.
// https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/net/system_network_context_manager.cc;l=730-740;drc=15a616c8043551a7cb22c4f73a88e83afb94631c;bpv=1;bpt=1
bool SystemNetworkContextManager::IsNetworkSandboxEnabled() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
auto* local_state = g_browser_process->local_state();
if (local_state && local_state->HasPrefPath(kNetworkServiceSandboxEnabled)) {
return local_state->GetBoolean(kNetworkServiceSandboxEnabled);
}
#endif // defined(OS_WIN)
#endif // BUILDFLAG(IS_WIN)
// If no policy is specified, then delegate to global sandbox configuration.
return sandbox::policy::features::IsNetworkSandboxEnabled();
}
@ -298,52 +297,18 @@ void SystemNetworkContextManager::OnNetworkServiceCreated(
additional_dns_query_types_enabled);
std::string app_name = electron::Browser::Get()->GetName();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
KeychainPassword::GetServiceName() = app_name + " Safe Storage";
KeychainPassword::GetAccountName() = app_name;
#endif
#if defined(OS_LINUX)
// c.f.
// https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/net/system_network_context_manager.cc;l=515;drc=9d82515060b9b75fa941986f5db7390299669ef1;bpv=1;bpt=1
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
auto config = std::make_unique<os_crypt::Config>();
config->store = command_line.GetSwitchValueASCII(::switches::kPasswordStore);
config->product_name = app_name;
config->application_name = app_name;
config->main_thread_runner = base::ThreadTaskRunnerHandle::Get();
// c.f.
// https://source.chromium.org/chromium/chromium/src/+/master:chrome/common/chrome_switches.cc;l=689;drc=9d82515060b9b75fa941986f5db7390299669ef1
config->should_use_preference =
command_line.HasSwitch(::switches::kEnableEncryptionSelection);
base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path);
#endif
// The OSCrypt keys are process bound, so if network service is out of
// process, send it the required key.
if (content::IsOutOfProcessNetworkService() &&
electron::fuses::IsCookieEncryptionEnabled()) {
#if defined(OS_LINUX)
network::mojom::CryptConfigPtr network_crypt_config =
network::mojom::CryptConfig::New();
network_crypt_config->application_name = config->application_name;
network_crypt_config->product_name = config->product_name;
network_crypt_config->store = config->store;
network_crypt_config->should_use_preference = config->should_use_preference;
network_crypt_config->user_data_path = config->user_data_path;
network_service->SetCryptConfig(std::move(network_crypt_config));
#else
network_service->SetEncryptionKey(OSCrypt::GetRawEncryptionKey());
#endif
}
#if defined(OS_LINUX)
OSCrypt::SetConfig(std::move(config));
#endif
#if DCHECK_IS_ON()
electron::safestorage::SetElectronCryptoReady(true);
#endif

View file

@ -70,7 +70,8 @@ void URLPipeLoader::OnResponseStarted(
producer_ = std::make_unique<mojo::DataPipeProducer>(std::move(producer));
client_->OnReceiveResponse(response_head.Clone());
client_->OnReceiveResponse(response_head.Clone(),
mojo::ScopedDataPipeConsumerHandle());
client_->OnStartLoadingResponseBody(std::move(consumer));
}

View file

@ -12,6 +12,7 @@
#include <wrl\wrappers\corewrappers.h>
#include "base/environment.h"
#include "base/logging.h"
#include "base/strings/string_util_win.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"

View file

@ -15,7 +15,7 @@
#include "third_party/skia/src/core/SkDevice.h"
#include "ui/gfx/skia_util.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "skia/ext/skia_utils_win.h"
#endif
@ -97,7 +97,7 @@ void OffScreenHostDisplayClient::CreateLayeredWindowUpdater(
layered_window_updater_->SetActive(active_);
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS)
void OffScreenHostDisplayClient::DidCompleteSwapWithNewSize(
const gfx::Size& size) {}
#endif

View file

@ -63,7 +63,7 @@ class OffScreenHostDisplayClient : public viz::HostDisplayClient {
void SetActive(bool active);
private:
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void OnDisplayReceivedCALayerParams(
const gfx::CALayerParams& ca_layer_params) override;
#endif
@ -72,7 +72,7 @@ class OffScreenHostDisplayClient : public viz::HostDisplayClient {
mojo::PendingReceiver<viz::mojom::LayeredWindowUpdater> receiver)
override;
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS)
void DidCompleteSwapWithNewSize(const gfx::Size& size) override;
#endif

View file

@ -651,7 +651,7 @@ bool OffScreenRenderWidgetHostView::InstallTransparency() {
return false;
}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void OffScreenRenderWidgetHostView::SetActive(bool active) {}
void OffScreenRenderWidgetHostView::ShowDefinitionForSelection() {}

View file

@ -10,7 +10,9 @@
#include <string>
#include <vector>
#if defined(OS_WIN)
#include "build/build_config.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
@ -38,7 +40,7 @@
#include "components/viz/host/host_display_client.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "ui/gfx/win/window_impl.h"
#endif
@ -101,7 +103,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
bool request_unadjusted_movement) override;
void UnlockMouse(void) override;
void TakeFallbackContentFrom(content::RenderWidgetHostView* view) override;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void SetActive(bool active) override;
void ShowDefinitionForSelection() override;
void SpeakSelection() override;
@ -113,7 +115,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
const std::vector<std::string>& file_paths,
blink::mojom::ShareService::ShareCallback callback) override;
bool UpdateNSViewAndDisplay();
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
// content::RenderWidgetHostViewBase:

View file

@ -15,7 +15,7 @@ OffScreenWebContentsView::OffScreenWebContentsView(
bool transparent,
const OnPaintCallback& callback)
: transparent_(transparent), callback_(callback) {
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
PlatformCreate();
#endif
}
@ -24,7 +24,7 @@ OffScreenWebContentsView::~OffScreenWebContentsView() {
if (native_window_)
native_window_->RemoveObserver(this);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
PlatformDestroy();
#endif
}
@ -66,7 +66,7 @@ gfx::Size OffScreenWebContentsView::GetSize() {
return native_window_ ? native_window_->GetSize() : gfx::Size();
}
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
if (!native_window_)
return gfx::NativeView();
@ -154,11 +154,11 @@ void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {}
void OffScreenWebContentsView::OnCapturerCountChanged() {}
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool OffScreenWebContentsView::CloseTabAfterEventTrackingIfNeeded() {
return false;
}
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
void OffScreenWebContentsView::StartDragging(
const content::DropData& drop_data,

View file

@ -14,7 +14,7 @@
#include "shell/browser/osr/osr_render_widget_host_view.h"
#include "third_party/blink/public/common/page/drag_mojom_traits.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#ifdef __OBJC__
@class OffScreenView;
#else
@ -64,7 +64,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
void SetOverscrollControllerEnabled(bool enabled) override;
void OnCapturerCountChanged() override;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
bool CloseTabAfterEventTrackingIfNeeded() override;
#endif
@ -82,7 +82,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
int GetFrameRate() const;
private:
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
void PlatformCreate();
void PlatformDestroy();
#endif
@ -99,7 +99,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
// Weak refs.
content::WebContents* web_contents_ = nullptr;
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
OffScreenView* offScreenView_;
#endif
};

View file

@ -34,6 +34,7 @@ class PrefStoreDelegate : public PrefValueStore::Delegate {
void Init(PrefStore* managed_prefs,
PrefStore* supervised_user_prefs,
PrefStore* extension_prefs,
PrefStore* standalone_browser_prefs,
PrefStore* command_line_prefs,
PrefStore* user_prefs,
PrefStore* recommended_prefs,

View file

@ -47,7 +47,7 @@ void ProtocolRegistry::RegisterURLLoaderFactories(
bool ProtocolRegistry::RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
return base::TryEmplace(handlers_, scheme, type, handler).second;
return handlers_.try_emplace(scheme, type, handler).second;
}
bool ProtocolRegistry::UnregisterProtocol(const std::string& scheme) {
@ -61,7 +61,7 @@ bool ProtocolRegistry::IsProtocolRegistered(const std::string& scheme) {
bool ProtocolRegistry::InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
return base::TryEmplace(intercept_handlers_, scheme, type, handler).second;
return intercept_handlers_.try_emplace(scheme, type, handler).second;
}
bool ProtocolRegistry::UninterceptProtocol(const std::string& scheme) {

View file

@ -6,7 +6,7 @@
#include <utility>
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
@ -19,7 +19,7 @@
#include "content/public/common/main_function_params.h"
#include "shell/common/electron_command_line.h"
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
#include "base/posix/eintr_wrapper.h"
#endif
@ -27,7 +27,7 @@ namespace relauncher {
namespace internal {
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
const int kRelauncherSyncFD = STDERR_FILENO + 1;
#endif
@ -72,7 +72,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
relaunch_argv.insert(relaunch_argv.end(), argv.begin(), argv.end());
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
int pipe_fds[2];
if (HANDLE_EINTR(pipe(pipe_fds)) != 0) {
PLOG(ERROR) << "pipe";
@ -98,11 +98,11 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
#endif
base::LaunchOptions options;
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
options.fds_to_remap.push_back(
std::make_pair(pipe_write_fd.get(), internal::kRelauncherSyncFD));
base::Process process = base::LaunchProcess(relaunch_argv, options);
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
base::Process process = base::LaunchProcess(
internal::ArgvToCommandLineString(relaunch_argv), options);
#endif
@ -114,7 +114,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
// The relauncher process is now starting up, or has started up. The
// original parent process continues.
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Synchronize with the relauncher process.
StringType name = internal::GetWaitEventName(process.Pid());
HANDLE wait_event = ::CreateEventW(NULL, TRUE, FALSE, name.c_str());
@ -122,7 +122,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
WaitForSingleObject(wait_event, 1000);
CloseHandle(wait_event);
}
#elif defined(OS_POSIX)
#elif BUILDFLAG(IS_POSIX)
pipe_write_fd.reset(); // close(pipe_fds[1]);
// Synchronize with the relauncher process.

View file

@ -31,7 +31,7 @@
#include "base/command_line.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "base/process/process_handle.h"
#endif
@ -76,7 +76,7 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters);
namespace internal {
#if defined(OS_POSIX)
#if BUILDFLAG(IS_POSIX)
// The "magic" file descriptor that the relauncher process' write side of the
// pipe shows up on. Chosen to avoid conflicting with stdin, stdout, and
// stderr.
@ -95,7 +95,7 @@ extern const CharType* kRelauncherTypeArg;
// reporting.
extern const CharType* kRelauncherArgSeparator;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
StringType GetWaitEventName(base::ProcessId pid);
StringType ArgvToCommandLineString(const StringVector& argv);

Some files were not shown because too many files have changed in this diff Show more