Make additional PPB APIs require ppapi::PERMISSION_SOCKET.

TCPServerSocketPrivate, TCPSocketPrivate, and UDPSocketPrivate now
require this permission in addition to a whitelisted site/URL.

Tidy code a bit while at it:
- use early returns
- use std::make_unique<>
- pull a redundant permission check

Bug: 950005
Change-Id: I6c24c39bf55c08fd538da62d1dc3a8a58610be2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1553877
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#649205}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 6ea3532930ab636c1dc84c966640bf8292093592
diff --git a/thunk/interfaces_ppb_private_no_permissions.h b/thunk/interfaces_ppb_private_no_permissions.h
index 5029225..166540f 100644
--- a/thunk/interfaces_ppb_private_no_permissions.h
+++ b/thunk/interfaces_ppb_private_no_permissions.h
@@ -5,6 +5,9 @@
 // Please see inteface_ppb_public_stable for the documentation on the format of
 // this file.
 
+// no-include-guard-because-multiply-included
+// NOLINT(build/header_guard)
+
 #include "ppapi/thunk/interfaces_preamble.h"
 
 // These interfaces don't require private permissions. However, they only work
@@ -17,22 +20,6 @@
 
 PROXIED_IFACE(PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1,
               PPB_HostResolver_Private_0_1)
-PROXIED_IFACE(PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1,
-              PPB_TCPServerSocket_Private_0_1)
-PROXIED_IFACE(PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_2,
-              PPB_TCPServerSocket_Private_0_2)
-PROXIED_IFACE(PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3,
-              PPB_TCPSocket_Private_0_3)
-PROXIED_IFACE(PPB_TCPSOCKET_PRIVATE_INTERFACE_0_4,
-              PPB_TCPSocket_Private_0_4)
-PROXIED_IFACE(PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5,
-              PPB_TCPSocket_Private_0_5)
-PROXIED_IFACE(PPB_UDPSOCKET_PRIVATE_INTERFACE_0_2,
-              PPB_UDPSocket_Private_0_2)
-PROXIED_IFACE(PPB_UDPSOCKET_PRIVATE_INTERFACE_0_3,
-              PPB_UDPSocket_Private_0_3)
-PROXIED_IFACE(PPB_UDPSOCKET_PRIVATE_INTERFACE_0_4,
-              PPB_UDPSocket_Private_0_4)
 
 PROXIED_IFACE(PPB_NETADDRESS_PRIVATE_INTERFACE_0_1,
               PPB_NetAddress_Private_0_1)
diff --git a/thunk/interfaces_ppb_public_socket.h b/thunk/interfaces_ppb_public_socket.h
index f79f7e7..2558f97 100644
--- a/thunk/interfaces_ppb_public_socket.h
+++ b/thunk/interfaces_ppb_public_socket.h
@@ -15,4 +15,16 @@
 PROXIED_IFACE(PPB_UDPSOCKET_INTERFACE_1_1, PPB_UDPSocket_1_1)
 PROXIED_IFACE(PPB_UDPSOCKET_INTERFACE_1_2, PPB_UDPSocket_1_2)
 
+// These interfaces only work for whitelisted origins.
+PROXIED_IFACE(PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1,
+              PPB_TCPServerSocket_Private_0_1)
+PROXIED_IFACE(PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_2,
+              PPB_TCPServerSocket_Private_0_2)
+PROXIED_IFACE(PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3, PPB_TCPSocket_Private_0_3)
+PROXIED_IFACE(PPB_TCPSOCKET_PRIVATE_INTERFACE_0_4, PPB_TCPSocket_Private_0_4)
+PROXIED_IFACE(PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5, PPB_TCPSocket_Private_0_5)
+PROXIED_IFACE(PPB_UDPSOCKET_PRIVATE_INTERFACE_0_2, PPB_UDPSocket_Private_0_2)
+PROXIED_IFACE(PPB_UDPSOCKET_PRIVATE_INTERFACE_0_3, PPB_UDPSocket_Private_0_3)
+PROXIED_IFACE(PPB_UDPSOCKET_PRIVATE_INTERFACE_0_4, PPB_UDPSocket_Private_0_4)
+
 #include "ppapi/thunk/interfaces_postamble.h"