chore: bump chromium to 104.0.5073.0 (main) (#34272)
This commit is contained in:
parent
3849d19e14
commit
470396d6ac
112 changed files with 663 additions and 589 deletions
|
@ -108,21 +108,34 @@ class DataPipeReader {
|
|||
// Note that the lifetime of the native buffer belongs to us, and we will
|
||||
// free memory when JS buffer gets garbage collected.
|
||||
v8::HandleScope handle_scope(promise_.isolate());
|
||||
#if defined(V8_SANDBOX)
|
||||
v8::Local<v8::Value> buffer =
|
||||
node::Buffer::Copy(promise_.isolate(), &buffer_.front(), buffer_.size())
|
||||
.ToLocalChecked();
|
||||
promise_.Resolve(buffer);
|
||||
#else
|
||||
v8::Local<v8::Value> buffer =
|
||||
node::Buffer::New(promise_.isolate(), &buffer_.front(), buffer_.size(),
|
||||
&DataPipeReader::FreeBuffer, this)
|
||||
.ToLocalChecked();
|
||||
promise_.Resolve(buffer);
|
||||
#endif
|
||||
|
||||
// Destroy data pipe.
|
||||
handle_watcher_.Cancel();
|
||||
#if defined(V8_SANDBOX)
|
||||
delete this;
|
||||
#else
|
||||
data_pipe_.reset();
|
||||
data_pipe_getter_.reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(V8_SANDBOX)
|
||||
static void FreeBuffer(char* data, void* self) {
|
||||
delete static_cast<DataPipeReader*>(self);
|
||||
}
|
||||
#endif
|
||||
|
||||
gin_helper::Promise<v8::Local<v8::Value>> promise_;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "base/containers/contains.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/common/extensions/command.h"
|
||||
#include "extensions/common/command.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "shell/browser/api/electron_api_system_preferences.h"
|
||||
|
|
|
@ -54,7 +54,7 @@ bool WebContents::PlatformHandleKeyboardEvent(
|
|||
return false;
|
||||
|
||||
// Send the event to the menu before sending it to the window
|
||||
if (event.os_event.type == NSKeyDown &&
|
||||
if (event.os_event.type == NSEventTypeKeyDown &&
|
||||
[[NSApp mainMenu] performKeyEquivalent:event.os_event])
|
||||
return true;
|
||||
|
||||
|
|
|
@ -277,9 +277,6 @@ int ElectronBrowserMainParts::PreCreateThreads() {
|
|||
#if defined(USE_AURA)
|
||||
screen_ = views::CreateDesktopScreen();
|
||||
display::Screen::SetScreenInstance(screen_.get());
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
views::LinuxUI::instance()->UpdateDeviceScaleFactor();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!views::LayoutProvider::Get())
|
||||
|
|
|
@ -150,7 +150,7 @@ void ElectronPermissionManager::RequestPermissionWithDetails(
|
|||
StatusCallback response_callback) {
|
||||
RequestPermissionsWithDetails(
|
||||
std::vector<blink::PermissionType>(1, permission), render_frame_host,
|
||||
requesting_origin, user_gesture, details,
|
||||
user_gesture, details,
|
||||
base::BindOnce(PermissionRequestResponseCallbackWrapper,
|
||||
std::move(response_callback)));
|
||||
}
|
||||
|
@ -161,15 +161,13 @@ void ElectronPermissionManager::RequestPermissions(
|
|||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
StatusesCallback response_callback) {
|
||||
RequestPermissionsWithDetails(permissions, render_frame_host,
|
||||
requesting_origin, user_gesture, nullptr,
|
||||
std::move(response_callback));
|
||||
RequestPermissionsWithDetails(permissions, render_frame_host, user_gesture,
|
||||
nullptr, std::move(response_callback));
|
||||
}
|
||||
|
||||
void ElectronPermissionManager::RequestPermissionsWithDetails(
|
||||
const std::vector<blink::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::DictionaryValue* details,
|
||||
StatusesCallback response_callback) {
|
||||
|
@ -236,6 +234,16 @@ void ElectronPermissionManager::ResetPermission(
|
|||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) {}
|
||||
|
||||
void ElectronPermissionManager::RequestPermissionsFromCurrentDocument(
|
||||
const std::vector<blink::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
bool user_gesture,
|
||||
base::OnceCallback<void(const std::vector<blink::mojom::PermissionStatus>&)>
|
||||
callback) {
|
||||
RequestPermissionsWithDetails(permissions, render_frame_host, user_gesture,
|
||||
nullptr, std::move(callback));
|
||||
}
|
||||
|
||||
blink::mojom::PermissionStatus ElectronPermissionManager::GetPermissionStatus(
|
||||
blink::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
|
@ -351,18 +359,6 @@ void ElectronPermissionManager::RevokeDevicePermission(
|
|||
render_frame_host);
|
||||
}
|
||||
|
||||
blink::mojom::PermissionStatus
|
||||
ElectronPermissionManager::GetPermissionStatusForFrame(
|
||||
blink::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin) {
|
||||
base::DictionaryValue details;
|
||||
bool granted = CheckPermissionWithDetails(permission, render_frame_host,
|
||||
requesting_origin, &details);
|
||||
return granted ? blink::mojom::PermissionStatus::GRANTED
|
||||
: blink::mojom::PermissionStatus::DENIED;
|
||||
}
|
||||
|
||||
blink::mojom::PermissionStatus
|
||||
ElectronPermissionManager::GetPermissionStatusForCurrentDocument(
|
||||
blink::PermissionType permission,
|
||||
|
|
|
@ -76,14 +76,10 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
|
|||
void RequestPermissionsWithDetails(
|
||||
const std::vector<blink::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::DictionaryValue* details,
|
||||
StatusesCallback callback);
|
||||
blink::mojom::PermissionStatus GetPermissionStatusForFrame(
|
||||
blink::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin) override;
|
||||
|
||||
blink::mojom::PermissionStatus GetPermissionStatusForCurrentDocument(
|
||||
blink::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host) override;
|
||||
|
@ -122,6 +118,13 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
|
|||
blink::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) override;
|
||||
void RequestPermissionsFromCurrentDocument(
|
||||
const std::vector<blink::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
bool user_gesture,
|
||||
base::OnceCallback<
|
||||
void(const std::vector<blink::mojom::PermissionStatus>&)> callback)
|
||||
override;
|
||||
blink::mojom::PermissionStatus GetPermissionStatusForWorker(
|
||||
blink::PermissionType permission,
|
||||
content::RenderProcessHost* render_process_host,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "shell/browser/extensions/electron_extensions_browser_client.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
|
@ -297,7 +298,7 @@ ElectronExtensionsBrowserClient::GetComponentExtensionResourceManager() {
|
|||
void ElectronExtensionsBrowserClient::BroadcastEventToRenderers(
|
||||
extensions::events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> args,
|
||||
base::Value::List args,
|
||||
bool dispatch_to_off_the_record_profiles) {
|
||||
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
|
||||
content::GetUIThreadTaskRunner({})->PostTask(
|
||||
|
@ -309,8 +310,11 @@ void ElectronExtensionsBrowserClient::BroadcastEventToRenderers(
|
|||
return;
|
||||
}
|
||||
|
||||
auto event = std::make_unique<extensions::Event>(
|
||||
histogram_value, event_name, std::move(*args).TakeListDeprecated());
|
||||
std::vector<base::Value> event_args(args.size());
|
||||
std::transform(args.begin(), args.end(), event_args.begin(),
|
||||
[](const base::Value& arg) { return arg.Clone(); });
|
||||
auto event = std::make_unique<extensions::Event>(histogram_value, event_name,
|
||||
std::move(event_args));
|
||||
auto& context_map = ElectronBrowserContext::browser_context_map();
|
||||
for (auto const& entry : context_map) {
|
||||
if (entry.second) {
|
||||
|
|
|
@ -109,7 +109,7 @@ class ElectronExtensionsBrowserClient
|
|||
void BroadcastEventToRenderers(
|
||||
extensions::events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> args,
|
||||
base::Value::List args,
|
||||
bool dispatch_to_off_the_record_profiles) override;
|
||||
extensions::ExtensionCache* GetExtensionCache() override;
|
||||
bool IsBackgroundUpdateAllowed() override;
|
||||
|
|
|
@ -73,81 +73,6 @@ struct base::trace_event::TraceValue::Helper<
|
|||
|
||||
namespace electron {
|
||||
|
||||
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
public:
|
||||
enum InitializationPolicy { kZeroInitialize, kDontInitialize };
|
||||
|
||||
ArrayBufferAllocator() {
|
||||
// Ref.
|
||||
// https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/wtf/allocator/partitions.cc;l=94;drc=062c315a858a87f834e16a144c2c8e9591af2beb
|
||||
allocator_->init({base::PartitionOptions::AlignedAlloc::kDisallowed,
|
||||
base::PartitionOptions::ThreadCache::kDisabled,
|
||||
base::PartitionOptions::Quarantine::kAllowed,
|
||||
base::PartitionOptions::Cookie::kAllowed,
|
||||
base::PartitionOptions::BackupRefPtr::kDisabled,
|
||||
base::PartitionOptions::UseConfigurablePool::kNo});
|
||||
}
|
||||
|
||||
// Allocate() methods return null to signal allocation failure to V8, which
|
||||
// should respond by throwing a RangeError, per
|
||||
// http://www.ecma-international.org/ecma-262/6.0/#sec-createbytedatablock.
|
||||
void* Allocate(size_t size) override {
|
||||
void* result = AllocateMemoryOrNull(size, kZeroInitialize);
|
||||
return result;
|
||||
}
|
||||
|
||||
void* AllocateUninitialized(size_t size) override {
|
||||
void* result = AllocateMemoryOrNull(size, kDontInitialize);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Free(void* data, size_t size) override {
|
||||
allocator_->root()->Free(data);
|
||||
}
|
||||
|
||||
private:
|
||||
static void* AllocateMemoryOrNull(size_t size, InitializationPolicy policy) {
|
||||
return AllocateMemoryWithFlags(size, policy,
|
||||
partition_alloc::AllocFlags::kReturnNull);
|
||||
}
|
||||
|
||||
static void* AllocateMemoryWithFlags(size_t size,
|
||||
InitializationPolicy policy,
|
||||
int flags) {
|
||||
// The array buffer contents are sometimes expected to be 16-byte aligned in
|
||||
// order to get the best optimization of SSE, especially in case of audio
|
||||
// and video buffers. Hence, align the given size up to 16-byte boundary.
|
||||
// Technically speaking, 16-byte aligned size doesn't mean 16-byte aligned
|
||||
// address, but this heuristics works with the current implementation of
|
||||
// PartitionAlloc (and PartitionAlloc doesn't support a better way for now).
|
||||
if (base::kAlignment <
|
||||
16) { // base::kAlignment is a compile-time constant.
|
||||
size_t aligned_size = base::bits::AlignUp(size, 16);
|
||||
if (size == 0) {
|
||||
aligned_size = 16;
|
||||
}
|
||||
if (aligned_size >= size) { // Only when no overflow
|
||||
size = aligned_size;
|
||||
}
|
||||
}
|
||||
|
||||
if (policy == kZeroInitialize) {
|
||||
flags |= partition_alloc::AllocFlags::kZeroFill;
|
||||
}
|
||||
void* data = allocator_->root()->AllocWithFlags(flags, size, "Electron");
|
||||
if (base::kAlignment < 16) {
|
||||
char* ptr = reinterpret_cast<char*>(data);
|
||||
DCHECK_EQ(base::bits::AlignUp(ptr, 16), ptr)
|
||||
<< "Pointer " << ptr << " not 16B aligned for size " << size;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static base::NoDestructor<base::PartitionAllocator> allocator_;
|
||||
};
|
||||
|
||||
base::NoDestructor<base::PartitionAllocator> ArrayBufferAllocator::allocator_{};
|
||||
|
||||
JavascriptEnvironment::JavascriptEnvironment(uv_loop_t* event_loop)
|
||||
: isolate_(Initialize(event_loop)),
|
||||
isolate_holder_(base::ThreadTaskRunnerHandle::Get(),
|
||||
|
@ -341,11 +266,12 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
|
|||
tracing_controller, gin::V8Platform::PageAllocator());
|
||||
|
||||
v8::V8::InitializePlatform(platform_);
|
||||
gin::IsolateHolder::Initialize(
|
||||
gin::IsolateHolder::kNonStrictMode, new ArrayBufferAllocator(),
|
||||
nullptr /* external_reference_table */, js_flags,
|
||||
nullptr /* fatal_error_callback */, nullptr /* oom_error_callback */,
|
||||
false /* create_v8_platform */);
|
||||
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
||||
gin::ArrayBufferAllocator::SharedInstance(),
|
||||
nullptr /* external_reference_table */,
|
||||
js_flags, nullptr /* fatal_error_callback */,
|
||||
nullptr /* oom_error_callback */,
|
||||
false /* create_v8_platform */);
|
||||
|
||||
v8::Isolate* isolate = v8::Isolate::Allocate();
|
||||
platform_->RegisterIsolate(isolate, event_loop);
|
||||
|
|
|
@ -60,20 +60,20 @@ MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
|
|||
void MediaCaptureDevicesDispatcher::GetDefaultDevices(
|
||||
bool audio,
|
||||
bool video,
|
||||
blink::MediaStreamDevices* devices) {
|
||||
blink::mojom::StreamDevices& devices) { // NOLINT(runtime/references)
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
DCHECK(audio || video);
|
||||
|
||||
if (audio) {
|
||||
const blink::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
|
||||
if (device)
|
||||
devices->push_back(*device);
|
||||
devices.audio_device = *device;
|
||||
}
|
||||
|
||||
if (video) {
|
||||
const blink::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
|
||||
if (device)
|
||||
devices->push_back(*device);
|
||||
devices.video_device = *device;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "content/public/browser/media_observer.h"
|
||||
#include "content/public/browser/media_stream_request.h"
|
||||
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -29,9 +30,10 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
// If the return list is empty, it means there is no available device on the
|
||||
// OS.
|
||||
// Called on the UI thread.
|
||||
void GetDefaultDevices(bool audio,
|
||||
bool video,
|
||||
blink::MediaStreamDevices* devices);
|
||||
void GetDefaultDevices(
|
||||
bool audio,
|
||||
bool video,
|
||||
blink::mojom::StreamDevices& devices); // NOLINT(runtime/references)
|
||||
|
||||
// Helpers for picking particular requested devices, identified by raw id.
|
||||
// If the device requested is not available it will return NULL.
|
||||
|
|
|
@ -45,7 +45,7 @@ MediaStreamDevicesController::MediaStreamDevicesController(
|
|||
MediaStreamDevicesController::~MediaStreamDevicesController() {
|
||||
if (!callback_.is_null()) {
|
||||
std::move(callback_).Run(
|
||||
blink::MediaStreamDevices(),
|
||||
blink::mojom::StreamDevices(),
|
||||
blink::mojom::MediaStreamRequestResult::FAILED_DUE_TO_SHUTDOWN,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ bool MediaStreamDevicesController::TakeAction() {
|
|||
|
||||
void MediaStreamDevicesController::Accept() {
|
||||
// Get the default devices for the request.
|
||||
blink::MediaStreamDevices devices;
|
||||
blink::mojom::StreamDevices stream_devices;
|
||||
if (microphone_requested_ || webcam_requested_) {
|
||||
switch (request_.request_type) {
|
||||
case blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY: {
|
||||
|
@ -94,6 +94,8 @@ void MediaStreamDevicesController::Accept() {
|
|||
device = MediaCaptureDevicesDispatcher::GetInstance()
|
||||
->GetFirstAvailableAudioDevice();
|
||||
}
|
||||
if (device)
|
||||
stream_devices.audio_device = *device;
|
||||
} else if (request_.video_type ==
|
||||
blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE) {
|
||||
// Pepper API opens only one device at a time.
|
||||
|
@ -105,9 +107,9 @@ void MediaStreamDevicesController::Accept() {
|
|||
device = MediaCaptureDevicesDispatcher::GetInstance()
|
||||
->GetFirstAvailableVideoDevice();
|
||||
}
|
||||
if (device)
|
||||
stream_devices.video_device = *device;
|
||||
}
|
||||
if (device)
|
||||
devices.push_back(*device);
|
||||
break;
|
||||
}
|
||||
case blink::MEDIA_GENERATE_STREAM: {
|
||||
|
@ -120,7 +122,7 @@ void MediaStreamDevicesController::Accept() {
|
|||
MediaCaptureDevicesDispatcher::GetInstance()
|
||||
->GetRequestedAudioDevice(request_.requested_audio_device_id);
|
||||
if (audio_device) {
|
||||
devices.push_back(*audio_device);
|
||||
stream_devices.audio_device = *audio_device;
|
||||
needs_audio_device = false;
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +131,7 @@ void MediaStreamDevicesController::Accept() {
|
|||
MediaCaptureDevicesDispatcher::GetInstance()
|
||||
->GetRequestedVideoDevice(request_.requested_video_device_id);
|
||||
if (video_device) {
|
||||
devices.push_back(*video_device);
|
||||
stream_devices.video_device = *video_device;
|
||||
needs_video_device = false;
|
||||
}
|
||||
}
|
||||
|
@ -138,14 +140,14 @@ void MediaStreamDevicesController::Accept() {
|
|||
// specified by id, get the default devices.
|
||||
if (needs_audio_device || needs_video_device) {
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices(
|
||||
needs_audio_device, needs_video_device, &devices);
|
||||
needs_audio_device, needs_video_device, stream_devices);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case blink::MEDIA_DEVICE_ACCESS: {
|
||||
// Get the default devices for the request.
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices(
|
||||
microphone_requested_, webcam_requested_, &devices);
|
||||
microphone_requested_, webcam_requested_, stream_devices);
|
||||
break;
|
||||
}
|
||||
case blink::MEDIA_DEVICE_UPDATE: {
|
||||
|
@ -154,40 +156,41 @@ void MediaStreamDevicesController::Accept() {
|
|||
}
|
||||
case blink::MEDIA_GET_OPEN_DEVICE: {
|
||||
// Transferred tracks, that use blink::MEDIA_GET_OPEN_DEVICE type, do
|
||||
// not need to get permissions for MediaStreamDevice as those are
|
||||
// controlled by the original context.
|
||||
// not need to get permissions for blink::mojom::StreamDevices as those
|
||||
// are controlled by the original context.
|
||||
NOTREACHED();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::move(callback_).Run(devices, blink::mojom::MediaStreamRequestResult::OK,
|
||||
std::move(callback_).Run(stream_devices,
|
||||
blink::mojom::MediaStreamRequestResult::OK,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::Deny(
|
||||
blink::mojom::MediaStreamRequestResult result) {
|
||||
std::move(callback_).Run(blink::MediaStreamDevices(), result,
|
||||
std::move(callback_).Run(blink::mojom::StreamDevices(), result,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::HandleUserMediaRequest() {
|
||||
blink::MediaStreamDevices devices;
|
||||
blink::mojom::StreamDevices devices;
|
||||
|
||||
if (request_.audio_type ==
|
||||
blink::mojom::MediaStreamType::GUM_TAB_AUDIO_CAPTURE) {
|
||||
devices.emplace_back(blink::mojom::MediaStreamType::GUM_TAB_AUDIO_CAPTURE,
|
||||
"", "");
|
||||
devices.audio_device = blink::MediaStreamDevice(
|
||||
blink::mojom::MediaStreamType::GUM_TAB_AUDIO_CAPTURE, "", "");
|
||||
}
|
||||
if (request_.video_type ==
|
||||
blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE) {
|
||||
devices.emplace_back(blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE,
|
||||
"", "");
|
||||
devices.video_device = blink::MediaStreamDevice(
|
||||
blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE, "", "");
|
||||
}
|
||||
if (request_.audio_type ==
|
||||
blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE) {
|
||||
devices.emplace_back(
|
||||
devices.audio_device = blink::MediaStreamDevice(
|
||||
blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE, "loopback",
|
||||
"System Audio");
|
||||
}
|
||||
|
@ -204,15 +207,17 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
|
|||
content::DesktopMediaID::Parse(request_.requested_video_device_id);
|
||||
}
|
||||
|
||||
devices.emplace_back(
|
||||
devices.video_device = blink::MediaStreamDevice(
|
||||
blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE,
|
||||
screen_id.ToString(), "Screen");
|
||||
}
|
||||
|
||||
bool empty =
|
||||
!devices.audio_device.has_value() && !devices.video_device.has_value();
|
||||
std::move(callback_).Run(
|
||||
devices,
|
||||
devices.empty() ? blink::mojom::MediaStreamRequestResult::NO_HARDWARE
|
||||
: blink::mojom::MediaStreamRequestResult::OK,
|
||||
empty ? blink::mojom::MediaStreamRequestResult::NO_HARDWARE
|
||||
: blink::mojom::MediaStreamRequestResult::OK,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
|
|
|
@ -302,13 +302,13 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
|||
styleMask = 0;
|
||||
|
||||
if (minimizable)
|
||||
styleMask |= NSMiniaturizableWindowMask;
|
||||
styleMask |= NSWindowStyleMaskMiniaturizable;
|
||||
if (closable)
|
||||
styleMask |= NSWindowStyleMaskClosable;
|
||||
if (resizable)
|
||||
styleMask |= NSResizableWindowMask;
|
||||
styleMask |= NSWindowStyleMaskResizable;
|
||||
if (!useStandardWindow || transparent() || !has_frame())
|
||||
styleMask |= NSTexturedBackgroundWindowMask;
|
||||
styleMask |= NSWindowStyleMaskTexturedBackground;
|
||||
|
||||
// Create views::Widget and assign window_ with it.
|
||||
// TODO(zcbenz): Get rid of the window_ in future.
|
||||
|
@ -841,11 +841,11 @@ bool NativeWindowMac::IsMovable() {
|
|||
}
|
||||
|
||||
void NativeWindowMac::SetMinimizable(bool minimizable) {
|
||||
SetStyleMask(minimizable, NSMiniaturizableWindowMask);
|
||||
SetStyleMask(minimizable, NSWindowStyleMaskMiniaturizable);
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsMinimizable() {
|
||||
return [window_ styleMask] & NSMiniaturizableWindowMask;
|
||||
return [window_ styleMask] & NSWindowStyleMaskMiniaturizable;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMaximizable(bool maximizable) {
|
||||
|
@ -901,9 +901,6 @@ void NativeWindowMac::SetAlwaysOnTop(ui::ZOrderLevel z_order,
|
|||
level = NSPopUpMenuWindowLevel;
|
||||
} else if (level_name == "screen-saver") {
|
||||
level = NSScreenSaverWindowLevel;
|
||||
} else if (level_name == "dock") {
|
||||
// Deprecated by macOS, but kept for backwards compatibility
|
||||
level = NSDockWindowLevel;
|
||||
}
|
||||
|
||||
SetWindowLevel(level + relative_level);
|
||||
|
@ -927,8 +924,6 @@ std::string NativeWindowMac::GetAlwaysOnTopLevel() {
|
|||
level_name = "pop-up-menu";
|
||||
} else if (level == NSScreenSaverWindowLevel) {
|
||||
level_name = "screen-saver";
|
||||
} else if (level == NSDockWindowLevel) {
|
||||
level_name = "dock";
|
||||
}
|
||||
|
||||
return level_name;
|
||||
|
|
|
@ -269,9 +269,7 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
|||
head->headers->AddHeader(net::HttpRequestHeaders::kContentType,
|
||||
head->mime_type.c_str());
|
||||
}
|
||||
client_->OnReceiveResponse(std::move(head),
|
||||
mojo::ScopedDataPipeConsumerHandle());
|
||||
client_->OnStartLoadingResponseBody(std::move(consumer_handle));
|
||||
client_->OnReceiveResponse(std::move(head), std::move(consumer_handle));
|
||||
|
||||
if (total_bytes_to_send == 0) {
|
||||
// There's definitely no more data, so we're already done.
|
||||
|
|
|
@ -554,13 +554,6 @@ void ElectronURLLoaderFactory::StartLoadingStream(
|
|||
} else if (stream->IsNullOrUndefined()) {
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
// "data" was explicitly passed as null or undefined, assume the user wants
|
||||
// to send an empty body.
|
||||
//
|
||||
// Note that We must submit a empty body otherwise NetworkService would
|
||||
// crash.
|
||||
client_remote->OnReceiveResponse(std::move(head),
|
||||
mojo::ScopedDataPipeConsumerHandle());
|
||||
mojo::ScopedDataPipeProducerHandle producer;
|
||||
mojo::ScopedDataPipeConsumerHandle consumer;
|
||||
if (mojo::CreateDataPipe(nullptr, producer, consumer) != MOJO_RESULT_OK) {
|
||||
|
@ -568,8 +561,13 @@ void ElectronURLLoaderFactory::StartLoadingStream(
|
|||
network::URLLoaderCompletionStatus(net::ERR_INSUFFICIENT_RESOURCES));
|
||||
return;
|
||||
}
|
||||
// "data" was explicitly passed as null or undefined, assume the user wants
|
||||
// to send an empty body.
|
||||
//
|
||||
// Note that We must submit a empty body otherwise NetworkService would
|
||||
// crash.
|
||||
client_remote->OnReceiveResponse(std::move(head), std::move(consumer));
|
||||
producer.reset(); // The data pipe is empty.
|
||||
client_remote->OnStartLoadingResponseBody(std::move(consumer));
|
||||
client_remote->OnComplete(network::URLLoaderCompletionStatus(net::OK));
|
||||
return;
|
||||
} else if (!stream->IsObject()) {
|
||||
|
@ -605,8 +603,6 @@ void ElectronURLLoaderFactory::SendContents(
|
|||
|
||||
// Add header to ignore CORS.
|
||||
head->headers->AddHeader("Access-Control-Allow-Origin", "*");
|
||||
client_remote->OnReceiveResponse(std::move(head),
|
||||
mojo::ScopedDataPipeConsumerHandle());
|
||||
|
||||
// Code below follows the pattern of data_url_loader_factory.cc.
|
||||
mojo::ScopedDataPipeProducerHandle producer;
|
||||
|
@ -617,7 +613,7 @@ void ElectronURLLoaderFactory::SendContents(
|
|||
return;
|
||||
}
|
||||
|
||||
client_remote->OnStartLoadingResponseBody(std::move(consumer));
|
||||
client_remote->OnReceiveResponse(std::move(head), std::move(consumer));
|
||||
|
||||
auto write_data = std::make_unique<WriteData>();
|
||||
write_data->client = std::move(client_remote);
|
||||
|
|
|
@ -58,9 +58,7 @@ void NodeStreamLoader::Start(network::mojom::URLResponseHeadPtr head) {
|
|||
}
|
||||
|
||||
producer_ = std::make_unique<mojo::DataPipeProducer>(std::move(producer));
|
||||
client_->OnReceiveResponse(std::move(head),
|
||||
mojo::ScopedDataPipeConsumerHandle());
|
||||
client_->OnStartLoadingResponseBody(std::move(consumer));
|
||||
client_->OnReceiveResponse(std::move(head), std::move(consumer));
|
||||
|
||||
auto weak = weak_factory_.GetWeakPtr();
|
||||
On("end",
|
||||
|
|
|
@ -300,11 +300,6 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnTransferSizeUpdated(
|
|||
target_client_->OnTransferSizeUpdated(transfer_size_diff);
|
||||
}
|
||||
|
||||
void ProxyingURLLoaderFactory::InProgressRequest::OnStartLoadingResponseBody(
|
||||
mojo::ScopedDataPipeConsumerHandle body) {
|
||||
target_client_->OnStartLoadingResponseBody(std::move(body));
|
||||
}
|
||||
|
||||
void ProxyingURLLoaderFactory::InProgressRequest::OnComplete(
|
||||
const network::URLLoaderCompletionStatus& status) {
|
||||
if (status.error_code != net::OK) {
|
||||
|
|
|
@ -97,8 +97,6 @@ class ProxyingURLLoaderFactory
|
|||
OnUploadProgressCallback callback) override;
|
||||
void OnReceiveCachedMetadata(mojo_base::BigBuffer data) override;
|
||||
void OnTransferSizeUpdated(int32_t transfer_size_diff) override;
|
||||
void OnStartLoadingResponseBody(
|
||||
mojo::ScopedDataPipeConsumerHandle body) override;
|
||||
void OnComplete(const network::URLLoaderCompletionStatus& status) override;
|
||||
|
||||
void OnLoaderCreated(
|
||||
|
|
|
@ -70,9 +70,7 @@ void URLPipeLoader::OnResponseStarted(
|
|||
|
||||
producer_ = std::make_unique<mojo::DataPipeProducer>(std::move(producer));
|
||||
|
||||
client_->OnReceiveResponse(response_head.Clone(),
|
||||
mojo::ScopedDataPipeConsumerHandle());
|
||||
client_->OnStartLoadingResponseBody(std::move(consumer));
|
||||
client_->OnReceiveResponse(response_head.Clone(), std::move(consumer));
|
||||
}
|
||||
|
||||
void URLPipeLoader::OnWrite(base::OnceClosure resume, MojoResult result) {
|
||||
|
|
|
@ -82,19 +82,19 @@ ui::MouseEvent UiMouseEventFromWebMouseEvent(blink::WebMouseEvent event) {
|
|||
int button_flags = 0;
|
||||
switch (event.button) {
|
||||
case blink::WebMouseEvent::Button::kBack:
|
||||
button_flags |= ui::EventFlags::EF_BACK_MOUSE_BUTTON;
|
||||
button_flags |= ui::EF_BACK_MOUSE_BUTTON;
|
||||
break;
|
||||
case blink::WebMouseEvent::Button::kForward:
|
||||
button_flags |= ui::EventFlags::EF_FORWARD_MOUSE_BUTTON;
|
||||
button_flags |= ui::EF_FORWARD_MOUSE_BUTTON;
|
||||
break;
|
||||
case blink::WebMouseEvent::Button::kLeft:
|
||||
button_flags |= ui::EventFlags::EF_LEFT_MOUSE_BUTTON;
|
||||
button_flags |= ui::EF_LEFT_MOUSE_BUTTON;
|
||||
break;
|
||||
case blink::WebMouseEvent::Button::kMiddle:
|
||||
button_flags |= ui::EventFlags::EF_MIDDLE_MOUSE_BUTTON;
|
||||
button_flags |= ui::EF_MIDDLE_MOUSE_BUTTON;
|
||||
break;
|
||||
case blink::WebMouseEvent::Button::kRight:
|
||||
button_flags |= ui::EventFlags::EF_RIGHT_MOUSE_BUTTON;
|
||||
button_flags |= ui::EF_RIGHT_MOUSE_BUTTON;
|
||||
break;
|
||||
default:
|
||||
button_flags = 0;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
NSString* str = @"No content under offscreen mode";
|
||||
NSMutableParagraphStyle* paragraphStyle =
|
||||
[[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
|
||||
[paragraphStyle setAlignment:NSCenterTextAlignment];
|
||||
[paragraphStyle setAlignment:NSTextAlignmentCenter];
|
||||
NSDictionary* attributes =
|
||||
[NSDictionary dictionaryWithObject:paragraphStyle
|
||||
forKey:NSParagraphStyleAttributeName];
|
||||
|
|
|
@ -226,7 +226,7 @@ void PrintPreviewMessageHandler::PrintToPDF(
|
|||
print_render_frame_->SetPrintPreviewUI(
|
||||
receiver_.BindNewEndpointAndPassRemote());
|
||||
}
|
||||
print_render_frame_->PrintPreview(options.Clone());
|
||||
print_render_frame_->PrintPreview(options.GetDict().Clone());
|
||||
}
|
||||
|
||||
gin_helper::Promise<v8::Local<v8::Value>>
|
||||
|
|
|
@ -176,8 +176,9 @@
|
|||
auto devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView();
|
||||
if (!docked) {
|
||||
auto styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
||||
NSMiniaturizableWindowMask | NSWindowStyleMaskResizable |
|
||||
NSTexturedBackgroundWindowMask |
|
||||
NSWindowStyleMaskMiniaturizable |
|
||||
NSWindowStyleMaskResizable |
|
||||
NSWindowStyleMaskTexturedBackground |
|
||||
NSWindowStyleMaskUnifiedTitleAndToolbar;
|
||||
devtools_window_.reset([[EventDispatchingWindow alloc]
|
||||
initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
||||
|
|
|
@ -70,7 +70,7 @@ using FullScreenTransitionState =
|
|||
}
|
||||
|
||||
// If the shift key is down, maximize.
|
||||
if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask)
|
||||
if ([[NSApp currentEvent] modifierFlags] & NSEventModifierFlagShift)
|
||||
return frame;
|
||||
|
||||
// Get preferred width from observers. Usually the page width.
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
- (void)redispatchKeyEvent:(NSEvent*)event {
|
||||
NSEventType eventType = [event type];
|
||||
if (eventType != NSKeyDown && eventType != NSKeyUp &&
|
||||
eventType != NSFlagsChanged) {
|
||||
if (eventType != NSEventTypeKeyDown && eventType != NSEventTypeKeyUp &&
|
||||
eventType != NSEventTypeFlagsChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ void AddFilesToPasteboard(NSPasteboard* pasteboard,
|
|||
void DragFileItems(const std::vector<base::FilePath>& files,
|
||||
const gfx::Image& icon,
|
||||
gfx::NativeView view) {
|
||||
NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
|
||||
NSPasteboard* pasteboard =
|
||||
[NSPasteboard pasteboardWithName:NSPasteboardNameDrag];
|
||||
AddFilesToPasteboard(pasteboard, files);
|
||||
|
||||
// Synthesize a drag event, since we don't have access to the actual event
|
||||
|
@ -38,9 +39,9 @@ void DragFileItems(const std::vector<base::FilePath>& files,
|
|||
NSWindow* window = [view.GetNativeNSView() window];
|
||||
NSPoint position = [window mouseLocationOutsideOfEventStream];
|
||||
NSTimeInterval eventTime = [[NSApp currentEvent] timestamp];
|
||||
NSEvent* dragEvent = [NSEvent mouseEventWithType:NSLeftMouseDragged
|
||||
NSEvent* dragEvent = [NSEvent mouseEventWithType:NSEventTypeLeftMouseDragged
|
||||
location:position
|
||||
modifierFlags:NSLeftMouseDraggedMask
|
||||
modifierFlags:NSEventMaskLeftMouseDragged
|
||||
timestamp:eventTime
|
||||
windowNumber:[window windowNumber]
|
||||
context:nil
|
||||
|
|
|
@ -232,7 +232,7 @@ void SetupSaveDialogForProperties(NSSavePanel* dialog, int properties) {
|
|||
|
||||
// Run modal dialog with parent window and return user's choice.
|
||||
int RunModalDialog(NSSavePanel* dialog, const DialogSettings& settings) {
|
||||
__block int chosen = NSFileHandlingPanelCancelButton;
|
||||
__block int chosen = NSModalResponseCancel;
|
||||
if (!settings.parent_window || !settings.parent_window->GetNativeWindow() ||
|
||||
settings.force_detached) {
|
||||
chosen = [dialog runModal];
|
||||
|
@ -324,7 +324,7 @@ bool ShowOpenDialogSync(const DialogSettings& settings,
|
|||
SetupOpenDialogForProperties(dialog, settings.properties);
|
||||
|
||||
int chosen = RunModalDialog(dialog, settings);
|
||||
if (chosen == NSFileHandlingPanelCancelButton)
|
||||
if (chosen == NSModalResponseCancel)
|
||||
return false;
|
||||
|
||||
ReadDialogPaths(dialog, paths);
|
||||
|
@ -337,7 +337,7 @@ void OpenDialogCompletion(int chosen,
|
|||
gin_helper::Promise<gin_helper::Dictionary> promise) {
|
||||
v8::HandleScope scope(promise.isolate());
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
if (chosen == NSModalResponseCancel) {
|
||||
dict.Set("canceled", true);
|
||||
dict.Set("filePaths", std::vector<base::FilePath>());
|
||||
#if defined(MAS_BUILD)
|
||||
|
@ -402,7 +402,7 @@ bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path) {
|
|||
SetupSaveDialogForProperties(dialog, settings.properties);
|
||||
|
||||
int chosen = RunModalDialog(dialog, settings);
|
||||
if (chosen == NSFileHandlingPanelCancelButton || ![[dialog URL] isFileURL])
|
||||
if (chosen == NSModalResponseCancel || ![[dialog URL] isFileURL])
|
||||
return false;
|
||||
|
||||
*path = base::FilePath(base::SysNSStringToUTF8([[dialog URL] path]));
|
||||
|
@ -415,7 +415,7 @@ void SaveDialogCompletion(int chosen,
|
|||
gin_helper::Promise<gin_helper::Dictionary> promise) {
|
||||
v8::HandleScope scope(promise.isolate());
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
|
||||
if (chosen == NSFileHandlingPanelCancelButton) {
|
||||
if (chosen == NSModalResponseCancel) {
|
||||
dict.Set("canceled", true);
|
||||
dict.Set("filePath", base::FilePath());
|
||||
#if defined(MAS_BUILD)
|
||||
|
|
|
@ -45,14 +45,14 @@ NSAlert* CreateNSAlert(const MessageBoxSettings& settings) {
|
|||
|
||||
switch (settings.type) {
|
||||
case MessageBoxType::kInformation:
|
||||
alert.alertStyle = NSInformationalAlertStyle;
|
||||
alert.alertStyle = NSAlertStyleInformational;
|
||||
break;
|
||||
case MessageBoxType::kWarning:
|
||||
case MessageBoxType::kError:
|
||||
// NSWarningAlertStyle shows the app icon while NSCriticalAlertStyle
|
||||
// NSWarningAlertStyle shows the app icon while NSAlertStyleCritical
|
||||
// shows a warning icon with an app icon badge. Since there is no
|
||||
// error variant, lets just use NSCriticalAlertStyle.
|
||||
alert.alertStyle = NSCriticalAlertStyle;
|
||||
// error variant, lets just use NSAlertStyleCritical.
|
||||
alert.alertStyle = NSAlertStyleCritical;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -198,7 +198,7 @@ void ShowErrorBox(const std::u16string& title, const std::u16string& content) {
|
|||
NSAlert* alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText:base::SysUTF16ToNSString(title)];
|
||||
[alert setInformativeText:base::SysUTF16ToNSString(content)];
|
||||
[alert setAlertStyle:NSCriticalAlertStyle];
|
||||
[alert setAlertStyle:NSAlertStyleCritical];
|
||||
[alert runModal];
|
||||
[alert release];
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "ui/views/style/typography.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
#include "ui/views/window/frame_buttons.h"
|
||||
#include "ui/views/window/window_button_order_provider.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -83,11 +84,16 @@ ClientFrameViewLinux::ClientFrameViewLinux()
|
|||
AddChildView(title_);
|
||||
|
||||
native_theme_observer_.Observe(theme_);
|
||||
window_button_order_observer_.Observe(views::LinuxUI::instance());
|
||||
|
||||
if (views::LinuxUI* ui = views::LinuxUI::instance()) {
|
||||
ui->AddWindowButtonOrderObserver(this);
|
||||
OnWindowButtonOrderingChange();
|
||||
}
|
||||
}
|
||||
|
||||
ClientFrameViewLinux::~ClientFrameViewLinux() {
|
||||
views::LinuxUI::instance()->RemoveWindowButtonOrderObserver(this);
|
||||
if (views::LinuxUI* ui = views::LinuxUI::instance())
|
||||
ui->RemoveWindowButtonOrderObserver(this);
|
||||
theme_->RemoveObserver(this);
|
||||
}
|
||||
|
||||
|
@ -159,11 +165,10 @@ void ClientFrameViewLinux::OnNativeThemeUpdated(
|
|||
UpdateThemeValues();
|
||||
}
|
||||
|
||||
void ClientFrameViewLinux::OnWindowButtonOrderingChange(
|
||||
const std::vector<views::FrameButton>& leading_buttons,
|
||||
const std::vector<views::FrameButton>& trailing_buttons) {
|
||||
leading_frame_buttons_ = leading_buttons;
|
||||
trailing_frame_buttons_ = trailing_buttons;
|
||||
void ClientFrameViewLinux::OnWindowButtonOrderingChange() {
|
||||
auto* provider = views::WindowButtonOrderProvider::GetInstance();
|
||||
leading_frame_buttons_ = provider->leading_buttons();
|
||||
trailing_frame_buttons_ = provider->trailing_buttons();
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
|
|
@ -45,9 +45,7 @@ class ClientFrameViewLinux : public FramelessView,
|
|||
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
||||
|
||||
// views::WindowButtonOrderObserver:
|
||||
void OnWindowButtonOrderingChange(
|
||||
const std::vector<views::FrameButton>& leading_buttons,
|
||||
const std::vector<views::FrameButton>& trailing_buttons) override;
|
||||
void OnWindowButtonOrderingChange() override;
|
||||
|
||||
// Overriden from FramelessView:
|
||||
int ResizingBorderHitTest(const gfx::Point& point) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue