Merge pull request #8866 from jkleinsc/master
Add WebRTCIPPolicy setting to webContents
This commit is contained in:
commit
783b5e84f4
4 changed files with 63 additions and 0 deletions
|
@ -1067,6 +1067,23 @@ void WebContents::GoToOffset(int offset) {
|
|||
web_contents()->GetController().GoToOffset(offset);
|
||||
}
|
||||
|
||||
const std::string WebContents::GetWebRTCIPHandlingPolicy() const {
|
||||
return web_contents()->
|
||||
GetMutableRendererPrefs()->webrtc_ip_handling_policy;
|
||||
}
|
||||
|
||||
void WebContents::SetWebRTCIPHandlingPolicy(
|
||||
const std::string& webrtc_ip_handling_policy) {
|
||||
if (GetWebRTCIPHandlingPolicy() == webrtc_ip_handling_policy)
|
||||
return;
|
||||
web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy =
|
||||
webrtc_ip_handling_policy;
|
||||
|
||||
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
|
||||
if (host)
|
||||
host->SyncRendererPrefs();
|
||||
}
|
||||
|
||||
bool WebContents::IsCrashed() const {
|
||||
return web_contents()->IsCrashed();
|
||||
}
|
||||
|
@ -1765,6 +1782,10 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("copyImageAt", &WebContents::CopyImageAt)
|
||||
.SetMethod("capturePage", &WebContents::CapturePage)
|
||||
.SetMethod("setEmbedder", &WebContents::SetEmbedder)
|
||||
.SetMethod("setWebRTCIPHandlingPolicy",
|
||||
&WebContents::SetWebRTCIPHandlingPolicy)
|
||||
.SetMethod("getWebRTCIPHandlingPolicy",
|
||||
&WebContents::GetWebRTCIPHandlingPolicy)
|
||||
.SetProperty("id", &WebContents::ID)
|
||||
.SetProperty("session", &WebContents::Session)
|
||||
.SetProperty("hostWebContents", &WebContents::HostWebContents)
|
||||
|
|
|
@ -92,6 +92,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void GoBack();
|
||||
void GoForward();
|
||||
void GoToOffset(int offset);
|
||||
const std::string GetWebRTCIPHandlingPolicy() const;
|
||||
void SetWebRTCIPHandlingPolicy(const std::string& webrtc_ip_handling_policy);
|
||||
bool IsCrashed() const;
|
||||
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
|
||||
std::string GetUserAgent();
|
||||
|
|
|
@ -1245,6 +1245,31 @@ Schedules a full repaint of the window this web contents is in.
|
|||
If *offscreen rendering* is enabled invalidates the frame and generates a new
|
||||
one through the `'paint'` event.
|
||||
|
||||
#### `contents.getWebRTCIPHandlingPolicy()`
|
||||
|
||||
* Returns `String` - Returns the WebRTC IP Handling Policy.
|
||||
|
||||
#### `contents.setWebRTCIPHandlingPolicy(policy)`
|
||||
|
||||
* `policy` String - Specify the WebRTC IP Handling Policy.
|
||||
* `default` - Exposes user's public and local IPs. This is the default
|
||||
behavior. When this policy is used, WebRTC has the right to enumerate all
|
||||
interfaces and bind them to discover public interfaces.
|
||||
* `default_public_interface_only` - Exposes user's public IP, but does not
|
||||
expose user's local IP. When this policy is used, WebRTC should only use the
|
||||
default route used by http. This doesn't expose any local addresses.
|
||||
* `default_public_and_private_interfaces` - Exposes user's public and local
|
||||
IPs. When this policy is used, WebRTC should only use the default route used
|
||||
by http. This also exposes the associated default private address. Default
|
||||
route is the route chosen by the OS on a multi-homed endpoint.
|
||||
* `disable_non_proxied_udp` - Does not expose public or local IPs. When this
|
||||
policy is used, WebRTC should only use TCP to contact peers or servers unless
|
||||
the proxy server supports UDP.
|
||||
|
||||
Setting the WebRTC IP handling policy allows you to control which IPs are
|
||||
exposed via WebRTC. See [BrowserLeaks](https://browserleaks.com/webrtc) for
|
||||
more details.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `contents.id`
|
||||
|
|
|
@ -527,4 +527,19 @@ describe('webContents module', function () {
|
|||
w.loadURL(`file://${fixtures}/pages/c.html`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('webrtc ip policy api', () => {
|
||||
it('can set and get webrtc ip policies', () => {
|
||||
const policies = [
|
||||
'default',
|
||||
'default_public_interface_only',
|
||||
'default_public_and_private_interfaces',
|
||||
'disable_non_proxied_udp'
|
||||
]
|
||||
policies.forEach((policy) => {
|
||||
w.webContents.setWebRTCIPHandlingPolicy(policy)
|
||||
assert.equal(w.webContents.getWebRTCIPHandlingPolicy(), policy)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue