fix: iteration issues in hid RevokeEphemeralDevicePermission
(#42851)
fix: iteration issues in hid RevokeEphemeralDevicePermission
This commit is contained in:
parent
1e1dc22e16
commit
ae1a684d10
1 changed files with 11 additions and 13 deletions
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/containers/contains.h"
|
#include "base/containers/contains.h"
|
||||||
|
#include "base/containers/map_util.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
@ -149,21 +150,18 @@ void HidChooserContext::RevokeEphemeralDevicePermission(
|
||||||
const url::Origin& origin,
|
const url::Origin& origin,
|
||||||
const device::mojom::HidDeviceInfo& device) {
|
const device::mojom::HidDeviceInfo& device) {
|
||||||
auto it = ephemeral_devices_.find(origin);
|
auto it = ephemeral_devices_.find(origin);
|
||||||
if (it != ephemeral_devices_.end()) {
|
if (it == ephemeral_devices_.end())
|
||||||
std::set<std::string>& devices = it->second;
|
return;
|
||||||
for (auto guid = devices.begin(); guid != devices.end();) {
|
|
||||||
DCHECK(base::Contains(devices_, *guid));
|
|
||||||
|
|
||||||
if (devices_[*guid]->physical_device_id != device.physical_device_id) {
|
std::set<std::string>& device_guids = it->second;
|
||||||
++guid;
|
std::erase_if(device_guids, [&](const auto& guid) {
|
||||||
continue;
|
auto* device_ptr = base::FindPtrOrNull(devices_, guid);
|
||||||
}
|
return device_ptr &&
|
||||||
|
device_ptr->physical_device_id == device.physical_device_id;
|
||||||
|
});
|
||||||
|
|
||||||
guid = devices.erase(guid);
|
if (device_guids.empty())
|
||||||
if (devices.empty())
|
ephemeral_devices_.erase(it);
|
||||||
ephemeral_devices_.erase(it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HidChooserContext::HasDevicePermission(
|
bool HidChooserContext::HasDevicePermission(
|
||||||
|
|
Loading…
Reference in a new issue