Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jkleinsc committed May 13, 2022
1 parent dd38312 commit 604e853
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions shell/browser/api/electron_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3494,17 +3494,16 @@ bool WebContents::DoesDeviceMatch(const base::Value* device,
if (permission_type ==
static_cast<content::PermissionType>(
WebContentsPermissionHelper::PermissionType::HID)) {
if (device->FindIntKey(kHidVendorIdKey) !=
device_to_compare->FindIntKey(kHidVendorIdKey) ||
device->FindIntKey(kHidProductIdKey) !=
device_to_compare->FindIntKey(kHidProductIdKey)) {
if (device->FindInt(kHidVendorIdKey) !=
device_to_compare->FindInt(kHidVendorIdKey) ||
device->FindInt(kHidProductIdKey) !=
device_to_compare->FindInt(kHidProductIdKey)) {
return false;
}

const auto* serial_number =
device_to_compare->FindStringKey(kHidSerialNumberKey);
const auto* device_serial_number =
device->FindStringKey(kHidSerialNumberKey);
device_to_compare->FindString(kHidSerialNumberKey);
const auto* device_serial_number = device->FindString(kHidSerialNumberKey);

if (serial_number && device_serial_number &&
*device_serial_number == *serial_number)
Expand All @@ -3513,22 +3512,22 @@ bool WebContents::DoesDeviceMatch(const base::Value* device,
static_cast<content::PermissionType>(
WebContentsPermissionHelper::PermissionType::SERIAL)) {
#if BUILDFLAG(IS_WIN)
if (device->FindStringKey(kDeviceInstanceIdKey) ==
device_to_compare->FindStringKey(kDeviceInstanceIdKey))
if (device->FindString(kDeviceInstanceIdKey) ==
device_to_compare->FindString(kDeviceInstanceIdKey))
return true;
#else
if (device->FindIntKey(kVendorIdKey) !=
device_to_compare->FindIntKey(kVendorIdKey) ||
device->FindIntKey(kProductIdKey) !=
device_to_compare->FindIntKey(kProductIdKey) ||
*device->FindStringKey(kSerialNumberKey) !=
*device_to_compare->FindStringKey(kSerialNumberKey)) {
if (device->FindInt(kVendorIdKey) !=
device_to_compare->FindInt(kVendorIdKey) ||
device->FindInt(kProductIdKey) !=
device_to_compare->FindInt(kProductIdKey) ||
*device->FindString(kSerialNumberKey) !=
*device_to_compare->FindString(kSerialNumberKey)) {
return false;
}

#if BUILDFLAG(IS_MAC)
if (*device->FindStringKey(kUsbDriverKey) !=
*device_to_compare->FindStringKey(kUsbDriverKey)) {
if (*device->FindString(kUsbDriverKey) !=
*device_to_compare->FindString(kUsbDriverKey)) {
return false;
}
#endif // BUILDFLAG(IS_MAC)
Expand Down

0 comments on commit 604e853

Please sign in to comment.