feat: support serialPort.forget() (#35310)

feat: enable serialPort.revoke()
This commit is contained in:
Shelley Vohr 2022-10-18 02:22:32 -07:00 committed by GitHub
parent 23d4a252c6
commit 4310468513
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 246 additions and 55 deletions

View file

@ -61,6 +61,21 @@ bool ElectronSerialDelegate::HasPortPermission(
frame);
}
void ElectronSerialDelegate::RevokePortPermissionWebInitiated(
content::RenderFrameHost* frame,
const base::UnguessableToken& token) {
auto* web_contents = content::WebContents::FromRenderFrameHost(frame);
return GetChooserContext(frame)->RevokePortPermissionWebInitiated(
web_contents->GetPrimaryMainFrame()->GetLastCommittedOrigin(), token,
frame);
}
const device::mojom::SerialPortInfo* ElectronSerialDelegate::GetPortInfo(
content::RenderFrameHost* frame,
const base::UnguessableToken& token) {
return GetChooserContext(frame)->GetPortInfo(token);
}
device::mojom::SerialPortManager* ElectronSerialDelegate::GetPortManager(
content::RenderFrameHost* frame) {
return GetChooserContext(frame)->GetPortManager();
@ -81,18 +96,6 @@ void ElectronSerialDelegate::RemoveObserver(
observer_list_.RemoveObserver(observer);
}
void ElectronSerialDelegate::RevokePortPermissionWebInitiated(
content::RenderFrameHost* frame,
const base::UnguessableToken& token) {
// TODO(nornagon/jkleinsc): pass this on to the chooser context
}
const device::mojom::SerialPortInfo* ElectronSerialDelegate::GetPortInfo(
content::RenderFrameHost* frame,
const base::UnguessableToken& token) {
return GetChooserContext(frame)->GetPortInfo(token);
}
SerialChooserController* ElectronSerialDelegate::ControllerForFrame(
content::RenderFrameHost* render_frame_host) {
auto mapping = controller_map_.find(render_frame_host);