mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
chore: bump chromium to 104.0.5112.39 (20-x-y) (#34425)
* chore: bump chromium in DEPS to 104.0.5098.0 * chore: bump chromium in DEPS to 104.0.5100.0 * chore: bump chromium in DEPS to 104.0.5102.0 * chore: bump chromium in DEPS to 104.0.5103.0 * chore: bump chromium in DEPS to 104.0.5104.0 * chore: bump chromium in DEPS to 104.0.5106.0 * chore: bump chromium in DEPS to 104.0.5108.0 * chore: bump chromium in DEPS to 104.0.5110.0 * chore: bump chromium in DEPS to 104.0.5112.0 * chore: bump chromium in DEPS to 104.0.5112.4 * 3651284: Use the entry settings object for window.open navigation https://chromium-review.googlesource.com/c/chromium/src/+/3651284 (cherry picked from commit6ff37a08f7) * 3644598: Make RenderFrameHost used for notification permission decision https://chromium-review.googlesource.com/c/chromium/src/+/3644598 (cherry picked from commit46df809556) * 3642842: Window Placement: Prototype Fullscreen Capability Delegation - Part 2 https://chromium-review.googlesource.com/c/chromium/src/+/3642842 (cherry picked from commit2fe1bc3222) * 3652785: [sandbox] Enable sandboxed pointers on sanitizer builds https://chromium-review.googlesource.com/c/v8/v8/+/3652785 (cherry picked from commitca8a3852f4) * 3611967: webhid: Migrate HidDelegate to use BrowserContext and Origin https://chromium-review.googlesource.com/c/chromium/src/+/3611967 (cherry picked from commit18aac8e93e) * 3665762: Remove RenderFrameHost::IsRenderFrameCreated from //content/. https://chromium-review.googlesource.com/c/chromium/src/+/3665762 (cherry picked from commit070ea1700b) * 3659375: Fold x509_util_ios and most of x509_util_mac into x509_util_apple https://chromium-review.googlesource.com/c/chromium/src/+/3659375 (cherry picked from commit479647e0ac) * 3656234: [CodeHealth] Remove uses of base::ListValue::Append() (Final, take 2) https://chromium-review.googlesource.com/c/chromium/src/+/3656234 (cherry picked from commite15d6110ed) * chore: update patch indices (cherry picked from commit8d666da975) * chore: fix lint (cherry picked from commitf9a9aca456) * 3644598: Make RenderFrameHost used for notification permission decision https://chromium-review.googlesource.com/c/chromium/src/+/3644598 (cherry picked from commit014c4b9212) * webhid: Migrate HidDelegate to use BrowserContext and Origin This is a temporary fix for https://chromium-review.googlesource.com/c/chromium/src/+/3611967 to get the build compiling, but we need to either patch around https://chromium-review.googlesource.com/c/chromium/src/+/3611967 or move our device permissioning to BrowserContext (cherry picked from commit322e9686da) * chore: fix lint (cherry picked from commit12b886cc62) * build: run electron/script/gen-libc++-filenames.js fixes gn check (cherry picked from commit93cebfecb2) * chore: disable flaking tests (cherry picked from commitfd0bc08f44) * 3652749: Delete GLRenderer and related classes https://chromium-review.googlesource.com/c/chromium/src/+/3652749 (cherry picked from commit43024a74c2) * 3682394: Change pipes surrounding code references in comments to backticks https://chromium-review.googlesource.com/c/chromium/src/+/3682394 (cherry picked from commit41026ae4d0) * chore: fixup patch indices (cherry picked from commitfccfc1bb29) * 3671199: Remove ContentMainDelegate::PostFieldTrialInitialization https://chromium-review.googlesource.com/c/chromium/src/+/3671199 (cherry picked from commit6392cfb595) * 3607963: hid: Do not exclude HID device with no collections https://chromium-review.googlesource.com/c/chromium/src/+/3607963 (cherry picked from commit2d81975792) * refactor: use ElectronBrowserContext instead of WebContents to persist devices due to changes like https://chromium-review.googlesource.com/c/chromium/src/+/3611967, we can no longer use WebContents to store device permissions so this commit moves device permission storage to live in memory in ElectronBrowserContext instead. (cherry picked from commit2f95568bfd) * 3557253: Deprecate some signature checks https://chromium-review.googlesource.com/c/v8/v8/+/3557253 (cherry picked from commitda4f0dbd1b) * 3680781: Add policy for Renderer App Container. https://chromium-review.googlesource.com/c/chromium/src/+/3680781 (cherry picked from commitcb901ce489) * chore: update patch indices (cherry picked from commit40c6295a5b) * 3675465: Update NetLog network service API to use mojom::DictionaryValue. https://chromium-review.googlesource.com/c/chromium/src/+/3675465 (cherry picked from commit55a58418e6) * fix: add patch for DCHECK in fullscreen test (cherry picked from commitc65280306d) * build: fix nan build (cherry picked from commitc06ea18698) * build: make the nan spec runner work on macOS (cherry picked from commita22950b126) * chore: update patches (cherry picked from commit7375148f93) * chore: update patches * 3693745: Delete base::LowerCaseEqualsASCII() Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3693745 (cherry picked from commited192f5c9b) * 3653285: Remove OS X 10.11 and macOS 10.12 code from chrome/ https://chromium-review.googlesource.com/c/chromium/src/+/3653285 * 3687395: Remove DictionaryValue::HasKey(). Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3687395 (cherry picked from commit2a6804db60) * 3691014: Prevent unsafe narrowing: ui/accessibility, part 2 Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3691014 (cherry picked from commitfca99a5cf9) * 3560567: [MSC] Porting GenerateStreams clients to handle stream vectors. https://chromium-review.googlesource.com/c/chromium/src/+/3560567 * 3684873: [Bluetooth][Win/Linux] Add bluetooth pair confirmation prompt https://chromium-review.googlesource.com/c/chromium/src/+/3684873 * chore: missing includes in desktop_notification_controller (cherry picked from commit574fb7933d) * 3685951: Reland "Make sure screen object is created once in tests." https://chromium-review.googlesource.com/c/chromium/src/+/3685951 * fixup: Reland "Make sure screen object is created once in tests." * chore: bump chromium in DEPS to 104.0.5110.0 * chore: update patches * Revert "3560567: [MSC] Porting GenerateStreams clients to handle stream vectors." This reverts commit c9c1c534056404be22a2d81ae6df4d184654fa35. * Revert "3691014: Prevent unsafe narrowing: ui/accessibility, part 2" This reverts commit 08f7a35765fde0467ef44d773e943cf5998619ae. * 3687671: [v8] Freeze flags after initialization https://chromium-review.googlesource.com/c/chromium/src/+/3687671 * fixup: 3687671: [v8] Freeze flags after initialization * chore: bump chromium in DEPS to 104.0.5112.14 * chore: update patches * 3691014: Prevent unsafe narrowing: ui/accessibility, part 2 Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3691014 (cherry picked from commitfca99a5cf9) (cherry picked from commit 08f7a35765fde0467ef44d773e943cf5998619ae) * 3560567: [MSC] Porting GenerateStreams clients to handle stream vectors. https://chromium-review.googlesource.com/c/chromium/src/+/3560567 (cherry picked from commit c9c1c534056404be22a2d81ae6df4d184654fa35) * 3669226: Remove printing PostTask usage of IO thread https://chromium-review.googlesource.com/c/chromium/src/+/3669226 * chore: document breaking change (cherry picked from commitd0991597c2) * chore: update patches * chore: remove deprecated AccessorSignatures https://github.com/nodejs/nan/pull/941 * Revert "fixup: 3687671: [v8] Freeze flags after initialization" This reverts commit a473727f39267327c7a77ec5056edd36b7c5b403. * Revert "3687671: [v8] Freeze flags after initialization" This reverts commit 7a8404be3c9d48a2e7ce877d749362f4754a9f17. * 3687671: [v8] Freeze flags after initialization https://chromium-review.googlesource.com/c/chromium/src/+/3687671 (cherry picked from commitf4c53302ea) * 52026: Do not allow md4 or md5 based signatures in X.509 certificates. https://boringssl-review.googlesource.com/c/boringssl/+/52026 * chore: bump chromium in DEPS to 104.0.5112.20 * chore: update patches patches/chromium/chore_expose_v8_initialization_isolate_callbacks.patch is no longer needed because it was upstreamed via: 2527943: Allow static access to WasmCodeGeneration callback https://chromium-review.googlesource.com/c/chromium/src/+/2527943 * 3560567: [MSC] Porting GenerateStreams clients to handle stream vectors. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3560567 (cherry picked from commit797c3a1656) * fixup! 3560567: [MSC] Porting GenerateStreams clients to handle stream vectors. (cherry picked from commit9741ab73cf) * fixup! 3560567: [MSC] Porting GenerateStreams clients to handle stream vectors. (cherry picked from commit558ed59d86) * chore: bump chromium in DEPS to 104.0.5112.29 * chore: update patches * chore: bump chromium in DEPS to 104.0.5112.39 * chore: update patches * chore: update patches * Trigger Build * 3695382: [ext-code-space] Fix CodeRange allocation logic https://chromium-review.googlesource.com/c/v8/v8/+/3695382 fixes https://bugs.chromium.org/p/v8/issues/detail?id=12942 * 3695382: [ext-code-space] Fix CodeRange allocation logic https://chromium-review.googlesource.com/c/v8/v8/+/3695382 * chore: update patches Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: Samuel Attard <sattard@salesforce.com> Co-authored-by: Keeley Hammond <khammond@slack-corp.com> Co-authored-by: VerteDinde <keeleymhammond@gmail.com> Co-authored-by: Jeremy Rose <japthorp@slack-corp.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
3ca5708faa
commit
db0830e0f8
@@ -132,9 +132,8 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
||||
auto command_line_string =
|
||||
base::CommandLine::ForCurrentProcess()->GetCommandLineString();
|
||||
auto channel_string = std::string("Electron " ELECTRON_VERSION);
|
||||
base::Value custom_constants =
|
||||
base::Value::FromUniquePtrValue(net_log::GetPlatformConstantsForNetLog(
|
||||
command_line_string, channel_string));
|
||||
base::Value::Dict custom_constants = net_log::GetPlatformConstantsForNetLog(
|
||||
command_line_string, channel_string);
|
||||
|
||||
auto* network_context =
|
||||
browser_context_->GetDefaultStoragePartition()->GetNetworkContext();
|
||||
@@ -156,7 +155,7 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
||||
|
||||
void NetLog::StartNetLogAfterCreateFile(net::NetLogCaptureMode capture_mode,
|
||||
uint64_t max_file_size,
|
||||
base::Value custom_constants,
|
||||
base::Value::Dict custom_constants,
|
||||
base::File output_file) {
|
||||
if (!net_log_exporter_) {
|
||||
// Theoretically the mojo pipe could have been closed by the time we get
|
||||
@@ -204,7 +203,7 @@ v8::Local<v8::Promise> NetLog::StopLogging(gin::Arguments* args) {
|
||||
// pointer lives long enough to resolve the promise. Moving it into the
|
||||
// callback will cause the instance variable to become empty.
|
||||
net_log_exporter_->Stop(
|
||||
base::Value(base::Value::Type::DICTIONARY),
|
||||
base::Value::Dict(),
|
||||
base::BindOnce(
|
||||
[](mojo::Remote<network::mojom::NetLogExporter>,
|
||||
gin_helper::Promise<void> promise, int32_t error) {
|
||||
|
||||
@@ -57,7 +57,7 @@ class NetLog : public gin::Wrappable<NetLog> {
|
||||
|
||||
void StartNetLogAfterCreateFile(net::NetLogCaptureMode capture_mode,
|
||||
uint64_t max_file_size,
|
||||
base::Value custom_constants,
|
||||
base::Value::Dict custom_constants,
|
||||
base::File output_file);
|
||||
void NetLogStarted(int32_t error);
|
||||
|
||||
|
||||
@@ -945,12 +945,6 @@ void WebContents::InitWithWebContents(
|
||||
}
|
||||
|
||||
WebContents::~WebContents() {
|
||||
// clear out objects that have been granted permissions so that when
|
||||
// WebContents::RenderFrameDeleted is called as a result of WebContents
|
||||
// destruction it doesn't try to clear out a granted_devices_
|
||||
// on a destructed object.
|
||||
granted_devices_.clear();
|
||||
|
||||
if (!inspectable_web_contents_) {
|
||||
WebContentsDestroyed();
|
||||
return;
|
||||
@@ -1558,11 +1552,6 @@ void WebContents::RenderFrameDeleted(
|
||||
// is swapped by content::RenderFrameHostManager.
|
||||
//
|
||||
|
||||
// clear out objects that have been granted permissions
|
||||
if (!granted_devices_.empty()) {
|
||||
granted_devices_.erase(render_frame_host->GetFrameTreeNodeId());
|
||||
}
|
||||
|
||||
// WebFrameMain::FromRenderFrameHost(rfh) will use the RFH's FrameTreeNode ID
|
||||
// to find an existing instance of WebFrameMain. During a cross-origin
|
||||
// navigation, the deleted RFH will be the old host which was swapped out. In
|
||||
@@ -3421,7 +3410,7 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
|
||||
return handle;
|
||||
}
|
||||
|
||||
if (!frame_host->IsRenderFrameCreated()) {
|
||||
if (!frame_host->IsRenderFrameLive()) {
|
||||
promise.RejectWithErrorMessage("takeHeapSnapshot failed");
|
||||
return handle;
|
||||
}
|
||||
@@ -3449,132 +3438,6 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
|
||||
return handle;
|
||||
}
|
||||
|
||||
void WebContents::GrantDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
blink::PermissionType permission_type,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
granted_devices_[render_frame_host->GetFrameTreeNodeId()][permission_type]
|
||||
[origin]
|
||||
.push_back(
|
||||
std::make_unique<base::Value>(device->Clone()));
|
||||
}
|
||||
|
||||
void WebContents::RevokeDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
blink::PermissionType permission_type,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
const auto& devices_for_frame_host_it =
|
||||
granted_devices_.find(render_frame_host->GetFrameTreeNodeId());
|
||||
if (devices_for_frame_host_it == granted_devices_.end())
|
||||
return;
|
||||
|
||||
const auto& current_devices_it =
|
||||
devices_for_frame_host_it->second.find(permission_type);
|
||||
if (current_devices_it == devices_for_frame_host_it->second.end())
|
||||
return;
|
||||
|
||||
const auto& origin_devices_it = current_devices_it->second.find(origin);
|
||||
if (origin_devices_it == current_devices_it->second.end())
|
||||
return;
|
||||
|
||||
for (auto it = origin_devices_it->second.begin();
|
||||
it != origin_devices_it->second.end();) {
|
||||
if (DoesDeviceMatch(device, it->get(), permission_type)) {
|
||||
it = origin_devices_it->second.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool WebContents::DoesDeviceMatch(const base::Value* device,
|
||||
const base::Value* device_to_compare,
|
||||
blink::PermissionType permission_type) {
|
||||
if (permission_type ==
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::HID)) {
|
||||
if (device->GetDict().FindInt(kHidVendorIdKey) !=
|
||||
device_to_compare->GetDict().FindInt(kHidVendorIdKey) ||
|
||||
device->GetDict().FindInt(kHidProductIdKey) !=
|
||||
device_to_compare->GetDict().FindInt(kHidProductIdKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto* serial_number =
|
||||
device_to_compare->GetDict().FindString(kHidSerialNumberKey);
|
||||
const auto* device_serial_number =
|
||||
device->GetDict().FindString(kHidSerialNumberKey);
|
||||
|
||||
if (serial_number && device_serial_number &&
|
||||
*device_serial_number == *serial_number)
|
||||
return true;
|
||||
} else if (permission_type ==
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::SERIAL)) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
const auto* instance_id =
|
||||
device->GetDict().FindString(kDeviceInstanceIdKey);
|
||||
const auto* port_instance_id =
|
||||
device_to_compare->GetDict().FindString(kDeviceInstanceIdKey);
|
||||
if (instance_id && port_instance_id && *instance_id == *port_instance_id)
|
||||
return true;
|
||||
#else
|
||||
const auto* serial_number = device->GetDict().FindString(kSerialNumberKey);
|
||||
const auto* port_serial_number =
|
||||
device_to_compare->GetDict().FindString(kSerialNumberKey);
|
||||
if (device->GetDict().FindInt(kVendorIdKey) !=
|
||||
device_to_compare->GetDict().FindInt(kVendorIdKey) ||
|
||||
device->GetDict().FindInt(kProductIdKey) !=
|
||||
device_to_compare->GetDict().FindInt(kProductIdKey) ||
|
||||
(serial_number && port_serial_number &&
|
||||
*port_serial_number != *serial_number)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
const auto* usb_driver_key = device->GetDict().FindString(kUsbDriverKey);
|
||||
const auto* port_usb_driver_key =
|
||||
device_to_compare->GetDict().FindString(kUsbDriverKey);
|
||||
if (usb_driver_key && port_usb_driver_key &&
|
||||
*usb_driver_key != *port_usb_driver_key) {
|
||||
return false;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
return true;
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WebContents::CheckDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
blink::PermissionType permission_type,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
const auto& devices_for_frame_host_it =
|
||||
granted_devices_.find(render_frame_host->GetFrameTreeNodeId());
|
||||
if (devices_for_frame_host_it == granted_devices_.end())
|
||||
return false;
|
||||
|
||||
const auto& current_devices_it =
|
||||
devices_for_frame_host_it->second.find(permission_type);
|
||||
if (current_devices_it == devices_for_frame_host_it->second.end())
|
||||
return false;
|
||||
|
||||
const auto& origin_devices_it = current_devices_it->second.find(origin);
|
||||
if (origin_devices_it == current_devices_it->second.end())
|
||||
return false;
|
||||
|
||||
for (const auto& device_to_compare : origin_devices_it->second) {
|
||||
if (DoesDeviceMatch(device, device_to_compare.get(), permission_type))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void WebContents::UpdatePreferredSize(content::WebContents* web_contents,
|
||||
const gfx::Size& pref_size) {
|
||||
Emit("preferred-size-changed", pref_size);
|
||||
@@ -3712,7 +3575,8 @@ void WebContents::DevToolsRequestFileSystems() {
|
||||
|
||||
base::ListValue file_system_value;
|
||||
for (const auto& file_system : file_systems)
|
||||
file_system_value.Append(CreateFileSystemValue(file_system));
|
||||
file_system_value.Append(
|
||||
base::Value::FromUniquePtrValue(CreateFileSystemValue(file_system)));
|
||||
inspectable_web_contents_->CallClientFunction(
|
||||
"DevToolsAPI.fileSystemsLoaded", &file_system_value, nullptr, nullptr);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "shell/common/gin_helper/constructible.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/pinnable.h"
|
||||
#include "third_party/blink/public/common/permissions/permission_utils.h"
|
||||
#include "ui/base/models/image_model.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
@@ -96,11 +95,6 @@ class OffScreenWebContentsView;
|
||||
|
||||
namespace api {
|
||||
|
||||
using DevicePermissionMap = std::map<
|
||||
int,
|
||||
std::map<blink::PermissionType,
|
||||
std::map<url::Origin, std::vector<std::unique_ptr<base::Value>>>>>;
|
||||
|
||||
// Wrapper around the content::WebContents.
|
||||
class WebContents : public ExclusiveAccessContext,
|
||||
public gin::Wrappable<WebContents>,
|
||||
@@ -436,28 +430,6 @@ class WebContents : public ExclusiveAccessContext,
|
||||
|
||||
void SetImageAnimationPolicy(const std::string& new_policy);
|
||||
|
||||
// Grants |origin| access to |device|.
|
||||
// To be used in place of ObjectPermissionContextBase::GrantObjectPermission.
|
||||
void GrantDevicePermission(const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
blink::PermissionType permissionType,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
|
||||
// Revokes |origin| access to |device|.
|
||||
// To be used in place of ObjectPermissionContextBase::RevokeObjectPermission.
|
||||
void RevokeDevicePermission(const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
blink::PermissionType permission_type,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
|
||||
// Returns the list of devices that |origin| has been granted permission to
|
||||
// access. To be used in place of
|
||||
// ObjectPermissionContextBase::GetGrantedObjects.
|
||||
bool CheckDevicePermission(const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
blink::PermissionType permissionType,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
|
||||
// disable copy
|
||||
WebContents(const WebContents&) = delete;
|
||||
WebContents& operator=(const WebContents&) = delete;
|
||||
@@ -753,10 +725,6 @@ class WebContents : public ExclusiveAccessContext,
|
||||
// Update the html fullscreen flag in both browser and renderer.
|
||||
void UpdateHtmlApiFullscreen(bool fullscreen);
|
||||
|
||||
bool DoesDeviceMatch(const base::Value* device,
|
||||
const base::Value* device_to_compare,
|
||||
blink::PermissionType permission_type);
|
||||
|
||||
v8::Global<v8::Value> session_;
|
||||
v8::Global<v8::Value> devtools_web_contents_;
|
||||
v8::Global<v8::Value> debugger_;
|
||||
@@ -841,9 +809,6 @@ class WebContents : public ExclusiveAccessContext,
|
||||
// Stores the frame thats currently in fullscreen, nullptr if there is none.
|
||||
content::RenderFrameHost* fullscreen_frame_ = nullptr;
|
||||
|
||||
// In-memory cache that holds objects that have been granted permissions.
|
||||
DevicePermissionMap granted_devices_;
|
||||
|
||||
base::WeakPtrFactory<WebContents> weak_factory_{this};
|
||||
};
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ void WebFrameMain::MaybeSetupMojoConnection() {
|
||||
|
||||
// Wait for RenderFrame to be created in renderer before accessing remote.
|
||||
if (pending_receiver_ && render_frame_ &&
|
||||
render_frame_->IsRenderFrameCreated()) {
|
||||
render_frame_->IsRenderFrameLive()) {
|
||||
render_frame_->GetRemoteInterfaces()->GetInterface(
|
||||
std::move(pending_receiver_));
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ void GPUInfoEnumerator::EndGPUDevice() {
|
||||
auto& top_value = value_stack.top();
|
||||
// GPUDevice can be more than one. So create a list of all.
|
||||
// The first one is the active GPU device.
|
||||
if (top_value->HasKey(kGPUDeviceKey)) {
|
||||
if (top_value->FindKey(kGPUDeviceKey)) {
|
||||
base::ListValue* list;
|
||||
top_value->GetList(kGPUDeviceKey, &list);
|
||||
list->Append(std::move(current));
|
||||
list->Append(base::Value::FromUniquePtrValue(std::move(current)));
|
||||
} else {
|
||||
auto gpus = std::make_unique<base::ListValue>();
|
||||
gpus->Append(std::move(current));
|
||||
std::unique_ptr<base::ListValue> gpus(new base::ListValue());
|
||||
gpus->Append(base::Value::FromUniquePtrValue(std::move(current)));
|
||||
top_value->SetList(kGPUDeviceKey, std::move(gpus));
|
||||
}
|
||||
current = std::move(top_value);
|
||||
|
||||
@@ -138,4 +138,11 @@ ElectronBluetoothDelegate::GetPermittedDevices(
|
||||
return permitted_devices;
|
||||
}
|
||||
|
||||
void ElectronBluetoothDelegate::ShowDevicePairConfirmPrompt(
|
||||
RenderFrameHost* frame,
|
||||
const std::u16string& device_identifier,
|
||||
PairConfirmCallback callback) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -55,6 +55,9 @@ class ElectronBluetoothDelegate : public content::BluetoothDelegate {
|
||||
void ShowDeviceCredentialsPrompt(content::RenderFrameHost* frame,
|
||||
const std::u16string& device_identifier,
|
||||
CredentialsCallback callback) override;
|
||||
void ShowDevicePairConfirmPrompt(content::RenderFrameHost* frame,
|
||||
const std::u16string& device_identifier,
|
||||
PairConfirmCallback callback) override;
|
||||
blink::WebBluetoothDeviceId GetWebBluetoothDeviceId(
|
||||
content::RenderFrameHost* frame,
|
||||
const std::string& device_address) override;
|
||||
|
||||
@@ -80,7 +80,7 @@ AutofillDriver* AutofillDriverFactory::DriverForFrame(
|
||||
// 3. `SomeOtherWebContentsObserver::RenderFrameDeleted(render_frame_host)`
|
||||
// calls `DriverForFrame(render_frame_host)`.
|
||||
// 5. `render_frame_host->~RenderFrameHostImpl()` finishes.
|
||||
if (render_frame_host->IsRenderFrameCreated()) {
|
||||
if (render_frame_host->IsRenderFrameLive()) {
|
||||
driver = std::make_unique<AutofillDriver>(render_frame_host);
|
||||
DCHECK_EQ(driver_map_.find(render_frame_host)->second.get(),
|
||||
driver.get());
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "shell/browser/protocol_registry.h"
|
||||
#include "shell/browser/special_storage_policy.h"
|
||||
#include "shell/browser/ui/inspectable_web_contents.h"
|
||||
#include "shell/browser/web_contents_permission_helper.h"
|
||||
#include "shell/browser/web_view_manager.h"
|
||||
#include "shell/browser/zoom_level_delegate.h"
|
||||
#include "shell/common/application_info.h"
|
||||
@@ -415,6 +416,115 @@ void ElectronBrowserContext::SetSSLConfigClient(
|
||||
ssl_config_client_ = std::move(client);
|
||||
}
|
||||
|
||||
void ElectronBrowserContext::GrantDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const base::Value& device,
|
||||
blink::PermissionType permission_type) {
|
||||
granted_devices_[permission_type][origin].push_back(
|
||||
std::make_unique<base::Value>(device.Clone()));
|
||||
}
|
||||
|
||||
void ElectronBrowserContext::RevokeDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const base::Value& device,
|
||||
blink::PermissionType permission_type) {
|
||||
const auto& current_devices_it = granted_devices_.find(permission_type);
|
||||
if (current_devices_it == granted_devices_.end())
|
||||
return;
|
||||
|
||||
const auto& origin_devices_it = current_devices_it->second.find(origin);
|
||||
if (origin_devices_it == current_devices_it->second.end())
|
||||
return;
|
||||
|
||||
for (auto it = origin_devices_it->second.begin();
|
||||
it != origin_devices_it->second.end();) {
|
||||
if (DoesDeviceMatch(device, it->get(), permission_type)) {
|
||||
it = origin_devices_it->second.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ElectronBrowserContext::DoesDeviceMatch(
|
||||
const base::Value& device,
|
||||
const base::Value* device_to_compare,
|
||||
blink::PermissionType permission_type) {
|
||||
if (permission_type ==
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::HID)) {
|
||||
if (device.GetDict().FindInt(kHidVendorIdKey) !=
|
||||
device_to_compare->GetDict().FindInt(kHidVendorIdKey) ||
|
||||
device.GetDict().FindInt(kHidProductIdKey) !=
|
||||
device_to_compare->GetDict().FindInt(kHidProductIdKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto* serial_number =
|
||||
device_to_compare->GetDict().FindString(kHidSerialNumberKey);
|
||||
const auto* device_serial_number =
|
||||
device.GetDict().FindString(kHidSerialNumberKey);
|
||||
|
||||
if (serial_number && device_serial_number &&
|
||||
*device_serial_number == *serial_number)
|
||||
return true;
|
||||
} else if (permission_type ==
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::SERIAL)) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
const auto* instance_id = device.GetDict().FindString(kDeviceInstanceIdKey);
|
||||
const auto* port_instance_id =
|
||||
device_to_compare->GetDict().FindString(kDeviceInstanceIdKey);
|
||||
if (instance_id && port_instance_id && *instance_id == *port_instance_id)
|
||||
return true;
|
||||
#else
|
||||
const auto* serial_number = device.GetDict().FindString(kSerialNumberKey);
|
||||
const auto* port_serial_number =
|
||||
device_to_compare->GetDict().FindString(kSerialNumberKey);
|
||||
if (device.GetDict().FindInt(kVendorIdKey) !=
|
||||
device_to_compare->GetDict().FindInt(kVendorIdKey) ||
|
||||
device.GetDict().FindInt(kProductIdKey) !=
|
||||
device_to_compare->GetDict().FindInt(kProductIdKey) ||
|
||||
(serial_number && port_serial_number &&
|
||||
*port_serial_number != *serial_number)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
const auto* usb_driver_key = device.GetDict().FindString(kUsbDriverKey);
|
||||
const auto* port_usb_driver_key =
|
||||
device_to_compare->GetDict().FindString(kUsbDriverKey);
|
||||
if (usb_driver_key && port_usb_driver_key &&
|
||||
*usb_driver_key != *port_usb_driver_key) {
|
||||
return false;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
return true;
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ElectronBrowserContext::CheckDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const base::Value& device,
|
||||
blink::PermissionType permission_type) {
|
||||
const auto& current_devices_it = granted_devices_.find(permission_type);
|
||||
if (current_devices_it == granted_devices_.end())
|
||||
return false;
|
||||
|
||||
const auto& origin_devices_it = current_devices_it->second.find(origin);
|
||||
if (origin_devices_it == current_devices_it->second.end())
|
||||
return false;
|
||||
|
||||
for (const auto& device_to_compare : origin_devices_it->second) {
|
||||
if (DoesDeviceMatch(device, device_to_compare.get(), permission_type))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
ElectronBrowserContext* ElectronBrowserContext::From(
|
||||
const std::string& partition,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "chrome/browser/predictors/preconnect_manager.h"
|
||||
@@ -18,6 +19,7 @@
|
||||
#include "services/network/public/mojom/network_context.mojom.h"
|
||||
#include "services/network/public/mojom/url_loader_factory.mojom.h"
|
||||
#include "shell/browser/media/media_device_id_salt.h"
|
||||
#include "third_party/blink/public/common/permissions/permission_utils.h"
|
||||
|
||||
class PrefService;
|
||||
class ValueMapPrefStore;
|
||||
@@ -38,6 +40,10 @@ class ElectronExtensionSystem;
|
||||
|
||||
namespace electron {
|
||||
|
||||
using DevicePermissionMap =
|
||||
std::map<blink::PermissionType,
|
||||
std::map<url::Origin, std::vector<std::unique_ptr<base::Value>>>>;
|
||||
|
||||
class ElectronBrowserContext;
|
||||
class ElectronDownloadManagerDelegate;
|
||||
class ElectronPermissionManager;
|
||||
@@ -149,6 +155,25 @@ class ElectronBrowserContext : public content::BrowserContext {
|
||||
|
||||
~ElectronBrowserContext() override;
|
||||
|
||||
// Grants |origin| access to |device|.
|
||||
// To be used in place of ObjectPermissionContextBase::GrantObjectPermission.
|
||||
void GrantDevicePermission(const url::Origin& origin,
|
||||
const base::Value& device,
|
||||
blink::PermissionType permissionType);
|
||||
|
||||
// Revokes |origin| access to |device|.
|
||||
// To be used in place of ObjectPermissionContextBase::RevokeObjectPermission.
|
||||
void RevokeDevicePermission(const url::Origin& origin,
|
||||
const base::Value& device,
|
||||
blink::PermissionType permission_type);
|
||||
|
||||
// Returns the list of devices that |origin| has been granted permission to
|
||||
// access. To be used in place of
|
||||
// ObjectPermissionContextBase::GetGrantedObjects.
|
||||
bool CheckDevicePermission(const url::Origin& origin,
|
||||
const base::Value& device,
|
||||
blink::PermissionType permissionType);
|
||||
|
||||
private:
|
||||
ElectronBrowserContext(const std::string& partition,
|
||||
bool in_memory,
|
||||
@@ -157,6 +182,10 @@ class ElectronBrowserContext : public content::BrowserContext {
|
||||
// Initialize pref registry.
|
||||
void InitPrefs();
|
||||
|
||||
bool DoesDeviceMatch(const base::Value& device,
|
||||
const base::Value* device_to_compare,
|
||||
blink::PermissionType permission_type);
|
||||
|
||||
ValueMapPrefStore* in_memory_pref_store_ = nullptr;
|
||||
|
||||
std::unique_ptr<content::ResourceContext> resource_context_;
|
||||
@@ -188,6 +217,9 @@ class ElectronBrowserContext : public content::BrowserContext {
|
||||
network::mojom::SSLConfigPtr ssl_config_;
|
||||
mojo::Remote<network::mojom::SSLConfigClient> ssl_config_client_;
|
||||
|
||||
// In-memory cache that holds objects that have been granted permissions.
|
||||
DevicePermissionMap granted_devices_;
|
||||
|
||||
base::WeakPtrFactory<ElectronBrowserContext> weak_factory_{this};
|
||||
};
|
||||
|
||||
|
||||
@@ -219,6 +219,9 @@ int ElectronBrowserMainParts::PreEarlyInitialization() {
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
ui::OzonePlatform::PreEarlyInitialization();
|
||||
#endif
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
screen_ = std::make_unique<display::ScopedNativeScreen>();
|
||||
#endif
|
||||
|
||||
return GetExitCode();
|
||||
}
|
||||
@@ -275,8 +278,9 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
|
||||
|
||||
int ElectronBrowserMainParts::PreCreateThreads() {
|
||||
#if defined(USE_AURA)
|
||||
screen_ = views::CreateDesktopScreen();
|
||||
display::Screen::SetScreenInstance(screen_.get());
|
||||
if (!display::Screen::GetScreen()) {
|
||||
screen_ = views::CreateDesktopScreen();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!views::LayoutProvider::Get())
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "services/device/public/mojom/geolocation_control.mojom.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/views/layout/layout_provider.h"
|
||||
|
||||
class BrowserProcessImpl;
|
||||
@@ -169,6 +170,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
std::unique_ptr<device::GeolocationManager> geolocation_manager_;
|
||||
std::unique_ptr<display::ScopedNativeScreen> screen_;
|
||||
#endif
|
||||
|
||||
static ElectronBrowserMainParts* self_;
|
||||
|
||||
@@ -307,25 +307,17 @@ bool ElectronPermissionManager::CheckPermissionWithDetails(
|
||||
bool ElectronPermissionManager::CheckDevicePermission(
|
||||
blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents);
|
||||
const base::Value& device,
|
||||
ElectronBrowserContext* browser_context) const {
|
||||
if (device_permission_handler_.is_null()) {
|
||||
if (api_web_contents) {
|
||||
return api_web_contents->CheckDevicePermission(origin, device, permission,
|
||||
render_frame_host);
|
||||
}
|
||||
return false;
|
||||
return browser_context->CheckDevicePermission(origin, device, permission);
|
||||
} else {
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::Local<v8::Object> details = gin::DataObjectBuilder(isolate)
|
||||
.Set("deviceType", permission)
|
||||
.Set("origin", origin.Serialize())
|
||||
.Set("device", device->Clone())
|
||||
.Set("frame", render_frame_host)
|
||||
.Set("device", device.Clone())
|
||||
.Build();
|
||||
return device_permission_handler_.Run(details);
|
||||
}
|
||||
@@ -334,29 +326,19 @@ bool ElectronPermissionManager::CheckDevicePermission(
|
||||
void ElectronPermissionManager::GrantDevicePermission(
|
||||
blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
const base::Value& device,
|
||||
ElectronBrowserContext* browser_context) const {
|
||||
if (device_permission_handler_.is_null()) {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents);
|
||||
if (api_web_contents)
|
||||
api_web_contents->GrantDevicePermission(origin, device, permission,
|
||||
render_frame_host);
|
||||
browser_context->GrantDevicePermission(origin, device, permission);
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronPermissionManager::RevokeDevicePermission(
|
||||
blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents);
|
||||
if (api_web_contents)
|
||||
api_web_contents->RevokeDevicePermission(origin, device, permission,
|
||||
render_frame_host);
|
||||
const base::Value& device,
|
||||
ElectronBrowserContext* browser_context) const {
|
||||
browser_context->RevokeDevicePermission(origin, device, permission);
|
||||
}
|
||||
|
||||
blink::mojom::PermissionStatus
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "base/containers/id_map.h"
|
||||
#include "content/public/browser/permission_controller_delegate.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "shell/browser/electron_browser_context.h"
|
||||
|
||||
namespace base {
|
||||
class DictionaryValue;
|
||||
@@ -91,19 +92,18 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
|
||||
|
||||
bool CheckDevicePermission(blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* object,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
const base::Value& object,
|
||||
ElectronBrowserContext* browser_context) const;
|
||||
|
||||
void GrantDevicePermission(blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* object,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
const base::Value& object,
|
||||
ElectronBrowserContext* browser_context) const;
|
||||
|
||||
void RevokeDevicePermission(
|
||||
blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* object,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
void RevokeDevicePermission(blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value& object,
|
||||
ElectronBrowserContext* browser_context) const;
|
||||
|
||||
protected:
|
||||
void OnPermissionResponse(int request_id,
|
||||
|
||||
@@ -10,17 +10,17 @@
|
||||
#include "base/command_line.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "services/device/public/cpp/hid/hid_switches.h"
|
||||
#include "shell/browser/electron_permission_manager.h"
|
||||
#include "shell/browser/hid/hid_chooser_context.h"
|
||||
#include "shell/browser/hid/hid_chooser_context_factory.h"
|
||||
#include "shell/browser/hid/hid_chooser_controller.h"
|
||||
#include "shell/browser/web_contents_permission_helper.h"
|
||||
#include "third_party/blink/public/common/permissions/permission_utils.h"
|
||||
|
||||
namespace {
|
||||
|
||||
electron::HidChooserContext* GetChooserContext(
|
||||
content::RenderFrameHost* frame) {
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(frame);
|
||||
auto* browser_context = web_contents->GetBrowserContext();
|
||||
content::BrowserContext* browser_context) {
|
||||
return electron::HidChooserContextFactory::GetForBrowserContext(
|
||||
browser_context);
|
||||
}
|
||||
@@ -38,8 +38,9 @@ std::unique_ptr<content::HidChooser> ElectronHidDelegate::RunChooser(
|
||||
std::vector<blink::mojom::HidDeviceFilterPtr> filters,
|
||||
std::vector<blink::mojom::HidDeviceFilterPtr> exclusion_filters,
|
||||
content::HidChooser::Callback callback) {
|
||||
electron::HidChooserContext* chooser_context =
|
||||
GetChooserContext(render_frame_host);
|
||||
DCHECK(render_frame_host);
|
||||
auto* chooser_context =
|
||||
GetChooserContext(render_frame_host->GetBrowserContext());
|
||||
if (!device_observation_.IsObserving())
|
||||
device_observation_.Observe(chooser_context);
|
||||
|
||||
@@ -58,65 +59,61 @@ std::unique_ptr<content::HidChooser> ElectronHidDelegate::RunChooser(
|
||||
}
|
||||
|
||||
bool ElectronHidDelegate::CanRequestDevicePermission(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
auto* permission_helper =
|
||||
WebContentsPermissionHelper::FromWebContents(web_contents);
|
||||
return permission_helper->CheckHIDAccessPermission(
|
||||
web_contents->GetMainFrame()->GetLastCommittedOrigin());
|
||||
content::BrowserContext* browser_context,
|
||||
const url::Origin& origin) {
|
||||
base::DictionaryValue details;
|
||||
details.SetString("securityOrigin", origin.GetURL().spec());
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
browser_context->GetPermissionControllerDelegate());
|
||||
return permission_manager->CheckPermissionWithDetails(
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::HID),
|
||||
nullptr, origin.GetURL(), &details);
|
||||
}
|
||||
|
||||
bool ElectronHidDelegate::HasDevicePermission(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
auto* chooser_context = GetChooserContext(render_frame_host);
|
||||
const auto& origin =
|
||||
render_frame_host->GetMainFrame()->GetLastCommittedOrigin();
|
||||
return chooser_context->HasDevicePermission(origin, device,
|
||||
render_frame_host);
|
||||
return GetChooserContext(browser_context)
|
||||
->HasDevicePermission(origin, device);
|
||||
}
|
||||
|
||||
void ElectronHidDelegate::RevokeDevicePermission(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
auto* chooser_context = GetChooserContext(render_frame_host);
|
||||
const auto& origin =
|
||||
render_frame_host->GetMainFrame()->GetLastCommittedOrigin();
|
||||
return chooser_context->RevokeDevicePermission(origin, device,
|
||||
render_frame_host);
|
||||
return GetChooserContext(browser_context)
|
||||
->RevokeDevicePermission(origin, device);
|
||||
}
|
||||
|
||||
device::mojom::HidManager* ElectronHidDelegate::GetHidManager(
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
auto* chooser_context = GetChooserContext(render_frame_host);
|
||||
return chooser_context->GetHidManager();
|
||||
content::BrowserContext* browser_context) {
|
||||
return GetChooserContext(browser_context)->GetHidManager();
|
||||
}
|
||||
|
||||
void ElectronHidDelegate::AddObserver(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
Observer* observer) {
|
||||
void ElectronHidDelegate::AddObserver(content::BrowserContext* browser_context,
|
||||
Observer* observer) {
|
||||
observer_list_.AddObserver(observer);
|
||||
auto* chooser_context = GetChooserContext(render_frame_host);
|
||||
auto* chooser_context = GetChooserContext(browser_context);
|
||||
if (!device_observation_.IsObserving())
|
||||
device_observation_.Observe(chooser_context);
|
||||
}
|
||||
|
||||
void ElectronHidDelegate::RemoveObserver(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::HidDelegate::Observer* observer) {
|
||||
observer_list_.RemoveObserver(observer);
|
||||
}
|
||||
|
||||
const device::mojom::HidDeviceInfo* ElectronHidDelegate::GetDeviceInfo(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
const std::string& guid) {
|
||||
auto* chooser_context = GetChooserContext(render_frame_host);
|
||||
auto* chooser_context = GetChooserContext(browser_context);
|
||||
return chooser_context->GetDeviceInfo(guid);
|
||||
}
|
||||
|
||||
bool ElectronHidDelegate::IsFidoAllowedForOrigin(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
const url::Origin& origin) {
|
||||
return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kDisableHidBlocklist);
|
||||
|
||||
@@ -33,23 +33,24 @@ class ElectronHidDelegate : public content::HidDelegate,
|
||||
std::vector<blink::mojom::HidDeviceFilterPtr> filters,
|
||||
std::vector<blink::mojom::HidDeviceFilterPtr> exclusion_filters,
|
||||
content::HidChooser::Callback callback) override;
|
||||
bool CanRequestDevicePermission(
|
||||
content::RenderFrameHost* render_frame_host) override;
|
||||
bool HasDevicePermission(content::RenderFrameHost* render_frame_host,
|
||||
bool CanRequestDevicePermission(content::BrowserContext* browser_context,
|
||||
const url::Origin& origin) override;
|
||||
bool HasDevicePermission(content::BrowserContext* browser_context,
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device) override;
|
||||
void RevokeDevicePermission(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device) override;
|
||||
device::mojom::HidManager* GetHidManager(
|
||||
content::RenderFrameHost* render_frame_host) override;
|
||||
void AddObserver(content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context) override;
|
||||
void AddObserver(content::BrowserContext* browser_context,
|
||||
content::HidDelegate::Observer* observer) override;
|
||||
void RemoveObserver(content::RenderFrameHost* render_frame_host,
|
||||
content::HidDelegate::Observer* observer) override;
|
||||
void RemoveObserver(content::HidDelegate::Observer* observer) override;
|
||||
const device::mojom::HidDeviceInfo* GetDeviceInfo(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
const std::string& guid) override;
|
||||
bool IsFidoAllowedForOrigin(content::RenderFrameHost* render_frame_host,
|
||||
bool IsFidoAllowedForOrigin(content::BrowserContext* browser_context,
|
||||
const url::Origin& origin) override;
|
||||
|
||||
// HidChooserContext::DeviceObserver:
|
||||
|
||||
@@ -20,12 +20,15 @@
|
||||
#include "services/device/public/cpp/hid/hid_blocklist.h"
|
||||
#include "services/device/public/cpp/hid/hid_switches.h"
|
||||
#include "shell/browser/api/electron_api_session.h"
|
||||
#include "shell/browser/electron_permission_manager.h"
|
||||
#include "shell/browser/web_contents_permission_helper.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/frame_converter.h"
|
||||
#include "shell/common/gin_converters/hid_device_info_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "third_party/blink/public/common/permissions/permission_utils.h"
|
||||
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
namespace electron {
|
||||
@@ -90,16 +93,16 @@ base::Value HidChooserContext::DeviceInfoToValue(
|
||||
|
||||
void HidChooserContext::GrantDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
DCHECK(base::Contains(devices_, device.guid));
|
||||
if (CanStorePersistentEntry(device)) {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
auto* permission_helper =
|
||||
WebContentsPermissionHelper::FromWebContents(web_contents);
|
||||
permission_helper->GrantHIDDevicePermission(
|
||||
origin, DeviceInfoToValue(device), render_frame_host);
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
browser_context_->GetPermissionControllerDelegate());
|
||||
|
||||
permission_manager->GrantDevicePermission(
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::HID),
|
||||
origin, DeviceInfoToValue(device), browser_context_);
|
||||
} else {
|
||||
ephemeral_devices_[origin].insert(device.guid);
|
||||
}
|
||||
@@ -107,40 +110,34 @@ void HidChooserContext::GrantDevicePermission(
|
||||
|
||||
void HidChooserContext::RevokeDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
DCHECK(base::Contains(devices_, device.guid));
|
||||
if (CanStorePersistentEntry(device)) {
|
||||
RevokePersistentDevicePermission(origin, device, render_frame_host);
|
||||
RevokePersistentDevicePermission(origin, device);
|
||||
} else {
|
||||
RevokeEphemeralDevicePermission(origin, device);
|
||||
}
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
|
||||
api::Session* session =
|
||||
api::Session::FromBrowserContext(web_contents->GetBrowserContext());
|
||||
api::Session* session = api::Session::FromBrowserContext(browser_context_);
|
||||
if (session) {
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
gin_helper::Dictionary details =
|
||||
gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
details.Set("device", device.Clone());
|
||||
details.SetGetter("frame", render_frame_host);
|
||||
details.Set("origin", origin.Serialize());
|
||||
session->Emit("hid-device-revoked", details);
|
||||
}
|
||||
}
|
||||
|
||||
void HidChooserContext::RevokePersistentDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
auto* permission_helper =
|
||||
WebContentsPermissionHelper::FromWebContents(web_contents);
|
||||
permission_helper->RevokeHIDDevicePermission(
|
||||
origin, DeviceInfoToValue(device), render_frame_host);
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
browser_context_->GetPermissionControllerDelegate());
|
||||
permission_manager->RevokeDevicePermission(
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::HID),
|
||||
origin, DeviceInfoToValue(device), browser_context_);
|
||||
RevokeEphemeralDevicePermission(origin, device);
|
||||
}
|
||||
|
||||
@@ -167,11 +164,10 @@ void HidChooserContext::RevokeEphemeralDevicePermission(
|
||||
|
||||
bool HidChooserContext::HasDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kDisableHidBlocklist) &&
|
||||
device::HidBlocklist::IsDeviceExcluded(device))
|
||||
device.is_excluded_by_blocklist)
|
||||
return false;
|
||||
|
||||
auto it = ephemeral_devices_.find(origin);
|
||||
@@ -180,12 +176,12 @@ bool HidChooserContext::HasDevicePermission(
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
auto* permission_helper =
|
||||
WebContentsPermissionHelper::FromWebContents(web_contents);
|
||||
return permission_helper->CheckHIDDevicePermission(
|
||||
origin, DeviceInfoToValue(device), render_frame_host);
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
browser_context_->GetPermissionControllerDelegate());
|
||||
return permission_manager->CheckDevicePermission(
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::HID),
|
||||
origin, DeviceInfoToValue(device), browser_context_);
|
||||
}
|
||||
|
||||
void HidChooserContext::AddDeviceObserver(DeviceObserver* observer) {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/unguessable_token.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
@@ -74,14 +73,11 @@ class HidChooserContext : public KeyedService,
|
||||
|
||||
// HID-specific interface for granting and checking permissions.
|
||||
void GrantDevicePermission(const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
const device::mojom::HidDeviceInfo& device);
|
||||
void RevokeDevicePermission(const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
const device::mojom::HidDeviceInfo& device);
|
||||
bool HasDevicePermission(const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
const device::mojom::HidDeviceInfo& device);
|
||||
|
||||
// For ScopedObserver.
|
||||
void AddDeviceObserver(DeviceObserver* observer);
|
||||
@@ -117,8 +113,7 @@ class HidChooserContext : public KeyedService,
|
||||
// HID-specific interface for revoking device permissions.
|
||||
void RevokePersistentDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
const device::mojom::HidDeviceInfo& device);
|
||||
void RevokeEphemeralDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device);
|
||||
|
||||
@@ -196,8 +196,7 @@ void HidChooserController::OnDeviceChosen(gin::Arguments* args) {
|
||||
std::vector<device::mojom::HidDeviceInfoPtr> devices;
|
||||
devices.reserve(device_infos.size());
|
||||
for (auto& device : device_infos) {
|
||||
chooser_context_->GrantDevicePermission(origin_, *device,
|
||||
web_contents()->GetMainFrame());
|
||||
chooser_context_->GrantDevicePermission(origin_, *device);
|
||||
devices.push_back(device->Clone());
|
||||
}
|
||||
RunCallback(std::move(devices));
|
||||
@@ -262,7 +261,7 @@ bool HidChooserController::DisplayDevice(
|
||||
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kDisableHidBlocklist)) {
|
||||
// Do not pass the device to the chooser if it is excluded by the blocklist.
|
||||
if (device::HidBlocklist::IsDeviceExcluded(device))
|
||||
if (device.is_excluded_by_blocklist)
|
||||
return false;
|
||||
|
||||
// Do not pass the device to the chooser if it has a top-level collection
|
||||
|
||||
@@ -109,16 +109,6 @@ static NSDictionary* UNNotificationResponseToNSDictionary(
|
||||
|
||||
electron::Browser::Get()->DidFinishLaunching(
|
||||
electron::NSDictionaryToDictionaryValue(notification_info));
|
||||
|
||||
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
|
||||
// Disable fatal OOM to hack around an OS bug https://crbug.com/654695.
|
||||
if (base::mac::IsOS10_12()) {
|
||||
g_swizzle_imk_input_session = new base::mac::ScopedObjCClassSwizzler(
|
||||
NSClassFromString(@"IMKInputSession"),
|
||||
[OOMDisabledIMKInputSession class],
|
||||
@selector(_coreAttributesFromRange:whichAttributes:completionHandler:));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification*)notification {
|
||||
|
||||
@@ -45,7 +45,7 @@ MediaStreamDevicesController::MediaStreamDevicesController(
|
||||
MediaStreamDevicesController::~MediaStreamDevicesController() {
|
||||
if (!callback_.is_null()) {
|
||||
std::move(callback_).Run(
|
||||
blink::mojom::StreamDevices(),
|
||||
blink::mojom::StreamDevicesSet(),
|
||||
blink::mojom::MediaStreamRequestResult::FAILED_DUE_TO_SHUTDOWN,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
@@ -77,7 +77,13 @@ bool MediaStreamDevicesController::TakeAction() {
|
||||
|
||||
void MediaStreamDevicesController::Accept() {
|
||||
// Get the default devices for the request.
|
||||
blink::mojom::StreamDevices stream_devices;
|
||||
blink::mojom::StreamDevicesSetPtr stream_devices_set =
|
||||
blink::mojom::StreamDevicesSet::New();
|
||||
stream_devices_set->stream_devices.emplace_back(
|
||||
blink::mojom::StreamDevices::New());
|
||||
blink::mojom::StreamDevices& stream_devices =
|
||||
*stream_devices_set->stream_devices[0];
|
||||
|
||||
if (microphone_requested_ || webcam_requested_) {
|
||||
switch (request_.request_type) {
|
||||
case blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY: {
|
||||
@@ -164,19 +170,23 @@ void MediaStreamDevicesController::Accept() {
|
||||
}
|
||||
}
|
||||
|
||||
std::move(callback_).Run(stream_devices,
|
||||
std::move(callback_).Run(*stream_devices_set,
|
||||
blink::mojom::MediaStreamRequestResult::OK,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::Deny(
|
||||
blink::mojom::MediaStreamRequestResult result) {
|
||||
std::move(callback_).Run(blink::mojom::StreamDevices(), result,
|
||||
std::move(callback_).Run(blink::mojom::StreamDevicesSet(), result,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::HandleUserMediaRequest() {
|
||||
blink::mojom::StreamDevices devices;
|
||||
blink::mojom::StreamDevicesSetPtr stream_devices_set =
|
||||
blink::mojom::StreamDevicesSet::New();
|
||||
stream_devices_set->stream_devices.emplace_back(
|
||||
blink::mojom::StreamDevices::New());
|
||||
blink::mojom::StreamDevices& devices = *stream_devices_set->stream_devices[0];
|
||||
|
||||
if (request_.audio_type ==
|
||||
blink::mojom::MediaStreamType::GUM_TAB_AUDIO_CAPTURE) {
|
||||
@@ -215,7 +225,7 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
|
||||
bool empty =
|
||||
!devices.audio_device.has_value() && !devices.video_device.has_value();
|
||||
std::move(callback_).Run(
|
||||
devices,
|
||||
*stream_devices_set,
|
||||
empty ? blink::mojom::MediaStreamRequestResult::NO_HARDWARE
|
||||
: blink::mojom::MediaStreamRequestResult::OK,
|
||||
std::unique_ptr<content::MediaStreamUI>());
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "shell/browser/notifications/win/win32_desktop_notifications/desktop_notification_controller.h"
|
||||
|
||||
#include <windowsx.h>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check.h"
|
||||
@@ -238,7 +239,7 @@ void DesktopNotificationController::AnimateAll() {
|
||||
it = stable_partition(it, it2, is_alive);
|
||||
|
||||
// purge the dead items
|
||||
for_each(it, it2, [this](auto&& inst) { DestroyToast(&inst); });
|
||||
std::for_each(it, it2, [this](auto&& inst) { DestroyToast(&inst); });
|
||||
|
||||
if (it2 == instances_.end()) {
|
||||
instances_.erase(it, it2);
|
||||
|
||||
@@ -41,9 +41,9 @@ void StopWorker(int document_cookie) {
|
||||
std::unique_ptr<printing::PrinterQuery> printer_query =
|
||||
queue->PopPrinterQuery(document_cookie);
|
||||
if (printer_query.get()) {
|
||||
content::GetIOThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE, base::BindOnce(&printing::PrinterQuery::StopWorker,
|
||||
std::move(printer_query)));
|
||||
printer_query->PostTask(FROM_HERE,
|
||||
base::BindOnce(&printing::PrinterQuery::StopWorker,
|
||||
std::move(printer_query)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "content/public/browser/device_service.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "shell/browser/electron_permission_manager.h"
|
||||
#include "shell/browser/web_contents_permission_helper.h"
|
||||
|
||||
namespace electron {
|
||||
@@ -86,7 +87,8 @@ base::Value PortInfoToValue(const device::mojom::SerialPortInfo& port) {
|
||||
return value;
|
||||
}
|
||||
|
||||
SerialChooserContext::SerialChooserContext() = default;
|
||||
SerialChooserContext::SerialChooserContext(ElectronBrowserContext* context)
|
||||
: browser_context_(context) {}
|
||||
|
||||
SerialChooserContext::~SerialChooserContext() = default;
|
||||
|
||||
@@ -99,26 +101,24 @@ void SerialChooserContext::GrantPortPermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::SerialPortInfo& port,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
base::Value value = PortInfoToValue(port);
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
auto* permission_helper =
|
||||
WebContentsPermissionHelper::FromWebContents(web_contents);
|
||||
permission_helper->GrantSerialPortPermission(origin, std::move(value),
|
||||
render_frame_host);
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
browser_context_->GetPermissionControllerDelegate());
|
||||
return permission_manager->GrantDevicePermission(
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::SERIAL),
|
||||
origin, PortInfoToValue(port), browser_context_);
|
||||
}
|
||||
|
||||
bool SerialChooserContext::HasPortPermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::SerialPortInfo& port,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
auto* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
auto* permission_helper =
|
||||
WebContentsPermissionHelper::FromWebContents(web_contents);
|
||||
base::Value value = PortInfoToValue(port);
|
||||
return permission_helper->CheckSerialPortPermission(origin, std::move(value),
|
||||
render_frame_host);
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
browser_context_->GetPermissionControllerDelegate());
|
||||
return permission_manager->CheckDevicePermission(
|
||||
static_cast<blink::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::SERIAL),
|
||||
origin, PortInfoToValue(port), browser_context_);
|
||||
}
|
||||
|
||||
void SerialChooserContext::RevokePortPermissionWebInitiated(
|
||||
|
||||
@@ -48,7 +48,7 @@ class SerialChooserContext : public KeyedService,
|
||||
public:
|
||||
using PortObserver = content::SerialDelegate::Observer;
|
||||
|
||||
SerialChooserContext();
|
||||
explicit SerialChooserContext(ElectronBrowserContext* context);
|
||||
~SerialChooserContext() override;
|
||||
|
||||
// disable copy
|
||||
@@ -104,6 +104,8 @@ class SerialChooserContext : public KeyedService,
|
||||
mojo::Receiver<device::mojom::SerialPortManagerClient> client_receiver_{this};
|
||||
base::ObserverList<PortObserver> port_observer_list_;
|
||||
|
||||
ElectronBrowserContext* browser_context_;
|
||||
|
||||
base::WeakPtrFactory<SerialChooserContext> weak_factory_{this};
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ SerialChooserContextFactory::~SerialChooserContextFactory() = default;
|
||||
|
||||
KeyedService* SerialChooserContextFactory::BuildServiceInstanceFor(
|
||||
content::BrowserContext* context) const {
|
||||
return new SerialChooserContext();
|
||||
auto* browser_context =
|
||||
static_cast<electron::ElectronBrowserContext*>(context);
|
||||
return new SerialChooserContext(browser_context);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "net/cert/cert_database.h"
|
||||
#include "net/cert/x509_util_ios_and_mac.h"
|
||||
#include "net/cert/x509_util_mac.h"
|
||||
#include "net/cert/x509_util_apple.h"
|
||||
#include "shell/browser/native_window.h"
|
||||
|
||||
@interface TrustDelegate : NSObject {
|
||||
|
||||
@@ -622,7 +622,7 @@ void InspectableWebContents::AddDevToolsExtensionsToClient() {
|
||||
"exposeExperimentalAPIs",
|
||||
extension->permissions_data()->HasAPIPermission(
|
||||
extensions::mojom::APIPermissionID::kExperimental));
|
||||
results.Append(std::move(extension_info));
|
||||
results.Append(base::Value::FromUniquePtrValue(std::move(extension_info)));
|
||||
}
|
||||
|
||||
CallClientFunction("DevToolsAPI.addExtensions", &results, NULL, NULL);
|
||||
|
||||
@@ -196,7 +196,7 @@ std::string RecursiveDumpAXPlatformNodeAsString(
|
||||
}
|
||||
}
|
||||
str += "\n";
|
||||
for (int i = 0; i < node->GetDelegate()->GetChildCount(); i++) {
|
||||
for (size_t i = 0; i < node->GetDelegate()->GetChildCount(); i++) {
|
||||
gfx::NativeViewAccessible child = node->GetDelegate()->ChildAtIndex(i);
|
||||
const ui::AXPlatformNode* child_node =
|
||||
ui::AXPlatformNode::FromNativeViewAccessible(child);
|
||||
@@ -286,14 +286,15 @@ void HandleAccessibilityRequestCallback(
|
||||
descriptor->SetBoolean(kWeb, is_web_enabled);
|
||||
descriptor->SetBoolean(kLabelImages,
|
||||
are_accessibility_image_labels_enabled);
|
||||
rvh_list->Append(std::move(descriptor));
|
||||
rvh_list->Append(base::Value::FromUniquePtrValue(std::move(descriptor)));
|
||||
}
|
||||
|
||||
data.Set(kPagesField, std::move(rvh_list));
|
||||
|
||||
auto window_list = std::make_unique<base::ListValue>();
|
||||
for (auto* window : electron::WindowList::GetWindows()) {
|
||||
window_list->Append(BuildTargetDescriptor(window));
|
||||
window_list->Append(
|
||||
base::Value::FromUniquePtrValue(BuildTargetDescriptor(window)));
|
||||
}
|
||||
|
||||
data.Set(kBrowsersField, std::move(window_list));
|
||||
|
||||
@@ -85,39 +85,6 @@ bool WebContentsPermissionHelper::CheckPermission(
|
||||
details);
|
||||
}
|
||||
|
||||
bool WebContentsPermissionHelper::CheckDevicePermission(
|
||||
blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
web_contents_->GetBrowserContext()->GetPermissionControllerDelegate());
|
||||
return permission_manager->CheckDevicePermission(permission, origin, device,
|
||||
render_frame_host);
|
||||
}
|
||||
|
||||
void WebContentsPermissionHelper::GrantDevicePermission(
|
||||
blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
web_contents_->GetBrowserContext()->GetPermissionControllerDelegate());
|
||||
permission_manager->GrantDevicePermission(permission, origin, device,
|
||||
render_frame_host);
|
||||
}
|
||||
|
||||
void WebContentsPermissionHelper::RevokeDevicePermission(
|
||||
blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
web_contents_->GetBrowserContext()->GetPermissionControllerDelegate());
|
||||
permission_manager->RevokeDevicePermission(permission, origin, device,
|
||||
render_frame_host);
|
||||
}
|
||||
|
||||
void WebContentsPermissionHelper::RequestFullscreenPermission(
|
||||
base::OnceCallback<void(bool)> callback) {
|
||||
RequestPermission(
|
||||
@@ -197,59 +164,6 @@ bool WebContentsPermissionHelper::CheckSerialAccessPermission(
|
||||
static_cast<blink::PermissionType>(PermissionType::SERIAL), &details);
|
||||
}
|
||||
|
||||
bool WebContentsPermissionHelper::CheckSerialPortPermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
return CheckDevicePermission(
|
||||
static_cast<blink::PermissionType>(PermissionType::SERIAL), origin,
|
||||
&device, render_frame_host);
|
||||
}
|
||||
|
||||
void WebContentsPermissionHelper::GrantSerialPortPermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
return GrantDevicePermission(
|
||||
static_cast<blink::PermissionType>(PermissionType::SERIAL), origin,
|
||||
&device, render_frame_host);
|
||||
}
|
||||
|
||||
bool WebContentsPermissionHelper::CheckHIDAccessPermission(
|
||||
const url::Origin& embedding_origin) const {
|
||||
base::DictionaryValue details;
|
||||
details.SetString("securityOrigin", embedding_origin.GetURL().spec());
|
||||
return CheckPermission(
|
||||
static_cast<blink::PermissionType>(PermissionType::HID), &details);
|
||||
}
|
||||
|
||||
bool WebContentsPermissionHelper::CheckHIDDevicePermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
return CheckDevicePermission(
|
||||
static_cast<blink::PermissionType>(PermissionType::HID), origin, &device,
|
||||
render_frame_host);
|
||||
}
|
||||
|
||||
void WebContentsPermissionHelper::GrantHIDDevicePermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
return GrantDevicePermission(
|
||||
static_cast<blink::PermissionType>(PermissionType::HID), origin, &device,
|
||||
render_frame_host);
|
||||
}
|
||||
|
||||
void WebContentsPermissionHelper::RevokeHIDDevicePermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const {
|
||||
return RevokeDevicePermission(
|
||||
static_cast<blink::PermissionType>(PermissionType::HID), origin, &device,
|
||||
render_frame_host);
|
||||
}
|
||||
|
||||
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsPermissionHelper);
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -51,27 +51,6 @@ class WebContentsPermissionHelper
|
||||
bool CheckMediaAccessPermission(const GURL& security_origin,
|
||||
blink::mojom::MediaStreamType type) const;
|
||||
bool CheckSerialAccessPermission(const url::Origin& embedding_origin) const;
|
||||
bool CheckSerialPortPermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
void GrantSerialPortPermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
bool CheckHIDAccessPermission(const url::Origin& embedding_origin) const;
|
||||
bool CheckHIDDevicePermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
void GrantHIDDevicePermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
void RevokeHIDDevicePermission(
|
||||
const url::Origin& origin,
|
||||
base::Value device,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
|
||||
private:
|
||||
explicit WebContentsPermissionHelper(content::WebContents* web_contents);
|
||||
@@ -85,22 +64,6 @@ class WebContentsPermissionHelper
|
||||
bool CheckPermission(blink::PermissionType permission,
|
||||
const base::DictionaryValue* details) const;
|
||||
|
||||
bool CheckDevicePermission(blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
|
||||
void GrantDevicePermission(blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
|
||||
void RevokeDevicePermission(
|
||||
blink::PermissionType permission,
|
||||
const url::Origin& origin,
|
||||
const base::Value* device,
|
||||
content::RenderFrameHost* render_frame_host) const;
|
||||
|
||||
// TODO(clavin): refactor to use the WebContents provided by the
|
||||
// WebContentsUserData base class instead of storing a duplicate ref
|
||||
content::WebContents* web_contents_;
|
||||
|
||||
Reference in New Issue
Block a user