From d5a658bbe4858be7f8506db11ae493d493c7ef93 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 8 Mar 2017 22:06:26 -0500 Subject: [PATCH] Fixed pass by reference and added spec --- atom/browser/api/atom_api_web_contents.cc | 4 ++-- atom/browser/api/atom_api_web_contents.h | 4 ++-- spec/api-web-contents-spec.js | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index bfe8a78..6ba23b3 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1067,13 +1067,13 @@ void WebContents::GoToOffset(int offset) { web_contents()->GetController().GoToOffset(offset); } -const std::string& WebContents::GetWebRTCIPHandlingPolicy() const { +const std::string WebContents::GetWebRTCIPHandlingPolicy() const { return web_contents()-> GetMutableRendererPrefs()->webrtc_ip_handling_policy; } void WebContents::SetWebRTCIPHandlingPolicy( - const std::string webrtc_ip_handling_policy) { + const std::string& webrtc_ip_handling_policy) { if (GetWebRTCIPHandlingPolicy() == webrtc_ip_handling_policy) return; web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy = diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 5aecab0..2513dc7 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -92,8 +92,8 @@ class WebContents : public mate::TrackableObject, void GoBack(); void GoForward(); void GoToOffset(int offset); - const std::string& GetWebRTCIPHandlingPolicy() const; - void SetWebRTCIPHandlingPolicy(const std::string webrtc_ip_handling_policy); + 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(); diff --git a/spec/api-web-contents-spec.js b/spec/api-web-contents-spec.js index 448d255..9005cce 100644 --- a/spec/api-web-contents-spec.js +++ b/spec/api-web-contents-spec.js @@ -527,4 +527,20 @@ describe('webContents module', function () { w.loadURL(`file://${fixtures}/pages/c.html`) }) }) + + describe('webrtc ip policy api', () => { + it('can set and get webrtc ip policies', (done) => { + 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) + }) + done() + }) + }) }) -- 2.7.4