fix: persist permission granted to serial ports (#30209)
This commit is contained in:
parent
d2989de5d9
commit
461db8f1ab
8 changed files with 138 additions and 38 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "services/device/public/mojom/serial.mojom-forward.h"
|
||||
#include "shell/browser/electron_browser_context.h"
|
||||
#include "third_party/blink/public/mojom/serial/serial.mojom.h"
|
||||
#include "url/gurl.h"
|
||||
#include "url/origin.h"
|
||||
|
@ -33,15 +34,13 @@ class SerialChooserContext : public KeyedService,
|
|||
public:
|
||||
using PortObserver = content::SerialDelegate::Observer;
|
||||
|
||||
SerialChooserContext();
|
||||
explicit SerialChooserContext(ElectronBrowserContext* browser_context);
|
||||
~SerialChooserContext() override;
|
||||
|
||||
// Serial-specific interface for granting and checking permissions.
|
||||
void GrantPortPermission(const url::Origin& requesting_origin,
|
||||
const url::Origin& embedding_origin,
|
||||
void GrantPortPermission(const url::Origin& origin,
|
||||
const device::mojom::SerialPortInfo& port);
|
||||
bool HasPortPermission(const url::Origin& requesting_origin,
|
||||
const url::Origin& embedding_origin,
|
||||
bool HasPortPermission(const url::Origin& origin,
|
||||
const device::mojom::SerialPortInfo& port);
|
||||
static bool CanStorePersistentEntry(
|
||||
const device::mojom::SerialPortInfo& port);
|
||||
|
@ -62,16 +61,11 @@ class SerialChooserContext : public KeyedService,
|
|||
void SetUpPortManagerConnection(
|
||||
mojo::PendingRemote<device::mojom::SerialPortManager> manager);
|
||||
void OnPortManagerConnectionError();
|
||||
void OnGetPorts(const url::Origin& requesting_origin,
|
||||
const url::Origin& embedding_origin,
|
||||
blink::mojom::SerialService::GetPortsCallback callback,
|
||||
std::vector<device::mojom::SerialPortInfoPtr> ports);
|
||||
|
||||
// Tracks the set of ports to which an origin (potentially embedded in another
|
||||
// origin) has access to. Key is (requesting_origin, embedding_origin).
|
||||
std::map<std::pair<url::Origin, url::Origin>,
|
||||
std::set<base::UnguessableToken>>
|
||||
ephemeral_ports_;
|
||||
ElectronBrowserContext* browser_context_;
|
||||
|
||||
// Tracks the set of ports to which an origin has access to.
|
||||
std::map<url::Origin, std::set<base::UnguessableToken>> ephemeral_ports_;
|
||||
|
||||
// Holds information about ports in |ephemeral_ports_|.
|
||||
std::map<base::UnguessableToken, base::Value> port_info_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue