Add WebRTCIPPolicy setting to webContents and webview

Resolves #8777
Code to set and get the policy come from the muon framework code:
https://github.com/brave/muon/blob/master/atom/browser/api/atom_api_web_
contents.cc#L1324...L1343
This commit is contained in:
John Kleinschmidt 2017-03-08 09:55:59 -05:00
parent 4f817873f1
commit 1c2a78a896
7 changed files with 57 additions and 1 deletions

View file

@ -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)