Revert "Generate localhost candidate when no STUN/TURN and portallocator has the right flag spefied."

This reverts commit 0a2955f227666efd87b2a303a69c083ef801c528.

Revert "In the past, P2PPortAllocator.enable_multiple_routes is the indicator whether we should bind to the any address. It's easy to translate that into a port allocator flag in P2PPortAllocator's ctor. Going forward, we have to depend on an asynchronous permission check to determine whether gathering local address is allowed or not, hence the current way of passing it through constructor approach won't work any more. The asynchronous check will trigger SignalNetowrksChanged so we could only check that inside DoAllocate."

This reverts commit ba9ab4cd8d2e8fbc068dc36b5e6f6331d7deeccf.

TBR=pthatcher@webrtc.org

Review URL: https://codereview.webrtc.org/1288843003 .

Cr-Commit-Position: refs/heads/master@{#9729}
diff --git a/talk/app/webrtc/peerconnectioninterface.h b/talk/app/webrtc/peerconnectioninterface.h
index debdc0d..bdbc6a7 100644
--- a/talk/app/webrtc/peerconnectioninterface.h
+++ b/talk/app/webrtc/peerconnectioninterface.h
@@ -223,9 +223,6 @@
     // TODO(pthatcher): Rename this ice_servers, but update Chromium
     // at the same time.
     IceServers servers;
-    // A localhost candidate is signaled whenever a candidate with the any
-    // address is allocated.
-    bool enable_localhost_ice_candidate;
     BundlePolicy bundle_policy;
     RtcpMuxPolicy rtcp_mux_policy;
     TcpCandidatePolicy tcp_candidate_policy;
@@ -234,7 +231,6 @@
 
     RTCConfiguration()
         : type(kAll),
-          enable_localhost_ice_candidate(false),
           bundle_policy(kBundlePolicyBalanced),
           rtcp_mux_policy(kRtcpMuxPolicyNegotiate),
           tcp_candidate_policy(kTcpCandidatePolicyEnabled),
diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc
index e3f72e0..c37eadb 100644
--- a/talk/app/webrtc/webrtcsession.cc
+++ b/talk/app/webrtc/webrtcsession.cc
@@ -678,13 +678,6 @@
   }
   port_allocator()->set_candidate_filter(
       ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type));
-
-  if (rtc_configuration.enable_localhost_ice_candidate) {
-    port_allocator()->set_flags(
-        port_allocator()->flags() |
-        cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
-  }
-
   return true;
 }
 
diff --git a/webrtc/base/fakenetwork.h b/webrtc/base/fakenetwork.h
index 4b6bb68..60773b4 100644
--- a/webrtc/base/fakenetwork.h
+++ b/webrtc/base/fakenetwork.h
@@ -78,8 +78,6 @@
     DoUpdateNetworks();
   }
 
-  using NetworkManagerBase::set_enumeration_permission;
-
  private:
   void DoUpdateNetworks() {
     if (!started_)
diff --git a/webrtc/base/ipaddress.cc b/webrtc/base/ipaddress.cc
index 3dd856a..768a709 100644
--- a/webrtc/base/ipaddress.cc
+++ b/webrtc/base/ipaddress.cc
@@ -498,13 +498,4 @@
   return 0;
 }
 
-IPAddress GetLoopbackIP(int family) {
-  if (family == AF_INET) {
-    return rtc::IPAddress(INADDR_LOOPBACK);
-  }
-  if (family == AF_INET6) {
-    return rtc::IPAddress(in6addr_loopback);
-  }
-  return rtc::IPAddress();
-}
-}  // Namespace rtc
+}  // Namespace talk base
diff --git a/webrtc/base/ipaddress.h b/webrtc/base/ipaddress.h
index 0f32d3a..606878b 100644
--- a/webrtc/base/ipaddress.h
+++ b/webrtc/base/ipaddress.h
@@ -179,8 +179,6 @@
 // Returns 'ip' truncated to be 'length' bits long.
 IPAddress TruncateIP(const IPAddress& ip, int length);
 
-IPAddress GetLoopbackIP(int family);
-
 // Returns the number of contiguously set bits, counting from the MSB in network
 // byte order, in this IPAddress. Bits after the first 0 encountered are not
 // counted.
diff --git a/webrtc/base/network.cc b/webrtc/base/network.cc
index 8dda89f..2081c94 100644
--- a/webrtc/base/network.cc
+++ b/webrtc/base/network.cc
@@ -164,9 +164,7 @@
 }
 
 NetworkManagerBase::NetworkManagerBase()
-    : enumeration_permission_(NetworkManager::kEnumerationAllowed),
-      max_ipv6_networks_(kMaxIPv6Networks),
-      ipv6_enabled_(true) {
+    : max_ipv6_networks_(kMaxIPv6Networks), ipv6_enabled_(true) {
 }
 
 NetworkManagerBase::~NetworkManagerBase() {
@@ -175,11 +173,6 @@
   }
 }
 
-NetworkManager::EnumerationPermission
-NetworkManagerBase::enumeration_permission() const {
-  return enumeration_permission_;
-}
-
 void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) {
   if (!ipv4_any_address_network_) {
     const rtc::IPAddress ipv4_any_address(INADDR_ANY);
diff --git a/webrtc/base/network.h b/webrtc/base/network.h
index b4d74ec..8e5c8f0 100644
--- a/webrtc/base/network.h
+++ b/webrtc/base/network.h
@@ -56,16 +56,6 @@
  public:
   typedef std::vector<Network*> NetworkList;
 
-  // This enum indicates whether adapter enumeration is allowed.
-  enum EnumerationPermission {
-    kEnumerationAllowed,     // Adapter enumeration is allowed. Getting 0
-                             // network from GetNetworks means that there is no
-                             // network available.
-    kEnumerationDisallowed,  // Adapter enumeration is
-                             // disabled. GetAnyAddressNetworks() should be used
-                             // instead.
-  };
-
   NetworkManager();
   virtual ~NetworkManager();
 
@@ -83,15 +73,12 @@
   virtual void StopUpdating() = 0;
 
   // Returns the current list of networks available on this machine.
-  // StartUpdating() must be called before this method is called.
+  // UpdateNetworks() must be called before this method is called.
   // It makes sure that repeated calls return the same object for a
   // given network, so that quality is tracked appropriately. Does not
   // include ignored networks.
   virtual void GetNetworks(NetworkList* networks) const = 0;
 
-  // return the current permission state of GetNetworks()
-  virtual EnumerationPermission enumeration_permission() const = 0;
-
   // "AnyAddressNetwork" is a network which only contains single "any address"
   // IP address.  (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is
   // useful as binding to such interfaces allow default routing behavior like
@@ -126,8 +113,6 @@
   void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; }
   int max_ipv6_networks() { return max_ipv6_networks_; }
 
-  EnumerationPermission enumeration_permission() const override;
-
  protected:
   typedef std::map<std::string, Network*> NetworkMap;
   // Updates |networks_| with the networks listed in |list|. If
@@ -142,16 +127,10 @@
                         bool* changed,
                         NetworkManager::Stats* stats);
 
-  void set_enumeration_permission(EnumerationPermission state) {
-    enumeration_permission_ = state;
-  }
-
  private:
   friend class NetworkTest;
   void DoUpdateNetworks();
 
-  EnumerationPermission enumeration_permission_;
-
   NetworkList networks_;
   int max_ipv6_networks_;
 
diff --git a/webrtc/base/network_unittest.cc b/webrtc/base/network_unittest.cc
index dc979ae..fdf75ca 100644
--- a/webrtc/base/network_unittest.cc
+++ b/webrtc/base/network_unittest.cc
@@ -177,14 +177,11 @@
   }
 }
 
-// Test StartUpdating() and StopUpdating(). network_permission_state starts with
-// ALLOWED.
+// Test that UpdateNetworks succeeds.
 TEST_F(NetworkTest, TestUpdateNetworks) {
   BasicNetworkManager manager;
   manager.SignalNetworksChanged.connect(
       static_cast<NetworkTest*>(this), &NetworkTest::OnNetworksChanged);
-  EXPECT_EQ(manager.enumeration_permission(),
-            NetworkManager::kEnumerationAllowed);
   manager.StartUpdating();
   Thread::Current()->ProcessMessages(0);
   EXPECT_TRUE(callback_called_);
@@ -198,8 +195,6 @@
   manager.StopUpdating();
   EXPECT_TRUE(manager.started());
   manager.StopUpdating();
-  EXPECT_EQ(manager.enumeration_permission(),
-            NetworkManager::kEnumerationAllowed);
   EXPECT_FALSE(manager.started());
   manager.StopUpdating();
   EXPECT_FALSE(manager.started());
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
index 26e8a87..4877af3 100644
--- a/webrtc/p2p/base/port_unittest.cc
+++ b/webrtc/p2p/base/port_unittest.cc
@@ -433,7 +433,7 @@
                          PacketSocketFactory* socket_factory) {
     UDPPort* port = UDPPort::Create(main_, socket_factory, &network_,
                                     addr.ipaddr(), 0, 0, username_, password_,
-                                    std::string(), false);
+                                    std::string());
     port->SetIceProtocolType(ice_protocol_);
     return port;
   }
diff --git a/webrtc/p2p/base/portallocator.h b/webrtc/p2p/base/portallocator.h
index 556ff5a..a90da38 100644
--- a/webrtc/p2p/base/portallocator.h
+++ b/webrtc/p2p/base/portallocator.h
@@ -38,7 +38,6 @@
   PORTALLOCATOR_ENABLE_SHARED_SOCKET = 0x100,
   PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE = 0x200,
   PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION = 0x400,
-  PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE = 0x800,
 };
 
 const uint32 kDefaultPortAllocatorFlags = 0;
diff --git a/webrtc/p2p/base/stunport.cc b/webrtc/p2p/base/stunport.cc
index 32d7355..953e585 100644
--- a/webrtc/p2p/base/stunport.cc
+++ b/webrtc/p2p/base/stunport.cc
@@ -15,7 +15,6 @@
 #include "webrtc/p2p/base/stun.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/helpers.h"
-#include "webrtc/base/ipaddress.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/nethelpers.h"
 
@@ -165,16 +164,14 @@
                  rtc::AsyncPacketSocket* socket,
                  const std::string& username,
                  const std::string& password,
-                 const std::string& origin,
-                 bool emit_localhost_for_anyaddress)
+                 const std::string& origin)
     : Port(thread, factory, network, socket->GetLocalAddress().ipaddr(),
            username, password),
       requests_(thread),
       socket_(socket),
       error_(0),
       ready_(false),
-      stun_keepalive_delay_(KEEPALIVE_DELAY),
-      emit_localhost_for_anyaddress_(emit_localhost_for_anyaddress) {
+      stun_keepalive_delay_(KEEPALIVE_DELAY) {
   requests_.set_origin(origin);
 }
 
@@ -186,16 +183,14 @@
                  uint16 max_port,
                  const std::string& username,
                  const std::string& password,
-                 const std::string& origin,
-                 bool emit_localhost_for_anyaddress)
+                 const std::string& origin)
     : Port(thread, LOCAL_PORT_TYPE, factory, network, ip, min_port, max_port,
            username, password),
       requests_(thread),
       socket_(NULL),
       error_(0),
       ready_(false),
-      stun_keepalive_delay_(KEEPALIVE_DELAY),
-      emit_localhost_for_anyaddress_(emit_localhost_for_anyaddress) {
+      stun_keepalive_delay_(KEEPALIVE_DELAY) {
   requests_.set_origin(origin);
 }
 
@@ -285,17 +280,9 @@
 
 void UDPPort::OnLocalAddressReady(rtc::AsyncPacketSocket* socket,
                                   const rtc::SocketAddress& address) {
-  // When adapter enumeration is disabled and binding to the any address, the
-  // loopback address will be issued as a candidate instead if
-  // |emit_localhost_for_anyaddress| is true. This is to allow connectivity on
-  // demo pages without STUN/TURN to work.
-  rtc::SocketAddress addr = address;
-  if (addr.IsAnyIP() && emit_localhost_for_anyaddress_) {
-    addr.SetIP(rtc::GetLoopbackIP(addr.family()));
-  }
-
-  AddAddress(addr, addr, rtc::SocketAddress(), UDP_PROTOCOL_NAME, "",
-             LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST, 0, false);
+  AddAddress(address, address, rtc::SocketAddress(),
+             UDP_PROTOCOL_NAME, "", LOCAL_PORT_TYPE,
+             ICE_TYPE_PREFERENCE_HOST, 0, false);
   MaybePrepareStunCandidate();
 }
 
diff --git a/webrtc/p2p/base/stunport.h b/webrtc/p2p/base/stunport.h
index 274f188..d840a97 100644
--- a/webrtc/p2p/base/stunport.h
+++ b/webrtc/p2p/base/stunport.h
@@ -34,11 +34,9 @@
                          rtc::AsyncPacketSocket* socket,
                          const std::string& username,
                          const std::string& password,
-                         const std::string& origin,
-                         bool emit_localhost_for_anyaddress) {
+                         const std::string& origin) {
     UDPPort* port = new UDPPort(thread, factory, network, socket,
-                                username, password, origin,
-                                emit_localhost_for_anyaddress);
+                                username, password, origin);
     if (!port->Init()) {
       delete port;
       port = NULL;
@@ -54,12 +52,10 @@
                          uint16 max_port,
                          const std::string& username,
                          const std::string& password,
-                         const std::string& origin,
-                         bool emit_localhost_for_anyaddress) {
+                         const std::string& origin) {
     UDPPort* port = new UDPPort(thread, factory, network,
                                 ip, min_port, max_port,
-                                username, password, origin,
-                                emit_localhost_for_anyaddress);
+                                username, password, origin);
     if (!port->Init()) {
       delete port;
       port = NULL;
@@ -114,8 +110,7 @@
           uint16 max_port,
           const std::string& username,
           const std::string& password,
-          const std::string& origin,
-          bool emit_localhost_for_anyaddress);
+          const std::string& origin);
 
   UDPPort(rtc::Thread* thread,
           rtc::PacketSocketFactory* factory,
@@ -123,8 +118,7 @@
           rtc::AsyncPacketSocket* socket,
           const std::string& username,
           const std::string& password,
-          const std::string& origin,
-          bool emit_localhost_for_anyaddress);
+          const std::string& origin);
 
   bool Init();
 
@@ -208,10 +202,6 @@
   bool ready_;
   int stun_keepalive_delay_;
 
-  // This is true when no STUN or TURN is specified in AllocationSequence and
-  // PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified.
-  bool emit_localhost_for_anyaddress_;
-
   friend class StunBindingRequest;
 };
 
@@ -255,7 +245,7 @@
            const ServerAddresses& servers,
            const std::string& origin)
      : UDPPort(thread, factory, network, ip, min_port, max_port, username,
-               password, origin, false) {
+               password, origin) {
     // UDPPort will set these to local udp, updating these to STUN.
     set_type(STUN_PORT_TYPE);
     set_server_addresses(servers);
diff --git a/webrtc/p2p/base/stunport_unittest.cc b/webrtc/p2p/base/stunport_unittest.cc
index 115c9ec..8b6e81b 100644
--- a/webrtc/p2p/base/stunport_unittest.cc
+++ b/webrtc/p2p/base/stunport_unittest.cc
@@ -82,7 +82,7 @@
         rtc::Thread::Current(), &socket_factory_,
         &network_, socket_.get(),
         rtc::CreateRandomString(16), rtc::CreateRandomString(22),
-        std::string(), false));
+        std::string()));
     ASSERT_TRUE(stun_port_ != NULL);
     ServerAddresses stun_servers;
     stun_servers.insert(server_addr);
diff --git a/webrtc/p2p/base/turnport_unittest.cc b/webrtc/p2p/base/turnport_unittest.cc
index b280ef1..00a62fa 100644
--- a/webrtc/p2p/base/turnport_unittest.cc
+++ b/webrtc/p2p/base/turnport_unittest.cc
@@ -272,7 +272,7 @@
     udp_port_.reset(UDPPort::Create(main_, &socket_factory_, &network_,
                                     kLocalAddr2.ipaddr(), 0, 0,
                                     kIceUfrag2, kIcePwd2,
-                                    std::string(), false));
+                                    std::string()));
     // Set protocol type to RFC5245, as turn port is also in same mode.
     // UDP port will be controlled.
     udp_port_->SetIceProtocolType(cricket::ICEPROTO_RFC5245);
diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc
index 1351b0e..c5cfbd9 100644
--- a/webrtc/p2p/client/basicportallocator.cc
+++ b/webrtc/p2p/client/basicportallocator.cc
@@ -304,13 +304,6 @@
   bool done_signal_needed = false;
   std::vector<rtc::Network*> networks;
 
-  // If the network permission state is BLOCKED, we just act as if the flag has
-  // been passed in.
-  if (allocator_->network_manager()->enumeration_permission() ==
-      rtc::NetworkManager::kEnumerationDisallowed) {
-    set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
-  }
-
   // If the adapter enumeration is disabled, we'll just bind to any address
   // instead of specific NIC. This is to ensure the same routing for http
   // traffic by OS is also used here to avoid any local or public IP leakage
@@ -562,13 +555,6 @@
       return true;
     }
 
-    // If it's loopback address, we should allow it as it's for demo page
-    // connectivity when no TURN/STUN specified.
-    if (c.address().IsLoopbackIP()) {
-      ASSERT((flags() & PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE) != 0);
-      return true;
-    }
-
     // This is just to prevent the case when binding to any address (all 0s), if
     // somehow the host candidate address is not all 0s. Either because local
     // installed proxy changes the address or a packet has been sent for any
@@ -839,19 +825,20 @@
   // TODO(mallinath) - Remove UDPPort creating socket after shared socket
   // is enabled completely.
   UDPPort* port = NULL;
-  bool emit_localhost_for_anyaddress =
-    IsFlagSet(PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
   if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) {
-    port = UDPPort::Create(
-        session_->network_thread(), session_->socket_factory(), network_,
-        udp_socket_.get(), session_->username(), session_->password(),
-        session_->allocator()->origin(), emit_localhost_for_anyaddress);
+    port = UDPPort::Create(session_->network_thread(),
+                           session_->socket_factory(), network_,
+                           udp_socket_.get(),
+                           session_->username(), session_->password(),
+                           session_->allocator()->origin());
   } else {
-    port = UDPPort::Create(
-        session_->network_thread(), session_->socket_factory(), network_, ip_,
-        session_->allocator()->min_port(), session_->allocator()->max_port(),
-        session_->username(), session_->password(),
-        session_->allocator()->origin(), emit_localhost_for_anyaddress);
+    port = UDPPort::Create(session_->network_thread(),
+                           session_->socket_factory(),
+                           network_, ip_,
+                           session_->allocator()->min_port(),
+                           session_->allocator()->max_port(),
+                           session_->username(), session_->password(),
+                           session_->allocator()->origin());
   }
 
   if (port) {
diff --git a/webrtc/p2p/client/fakeportallocator.h b/webrtc/p2p/client/fakeportallocator.h
index bd85321..89093cf 100644
--- a/webrtc/p2p/client/fakeportallocator.h
+++ b/webrtc/p2p/client/fakeportallocator.h
@@ -53,8 +53,7 @@
                                            0,
                                            username(),
                                            password(),
-                                           std::string(),
-                                           false));
+                                           std::string()));
       AddPort(port_.get());
     }
     ++port_config_count_;
diff --git a/webrtc/p2p/client/portallocator_unittest.cc b/webrtc/p2p/client/portallocator_unittest.cc
index 6a46aa2..5e2c1f8 100644
--- a/webrtc/p2p/client/portallocator_unittest.cc
+++ b/webrtc/p2p/client/portallocator_unittest.cc
@@ -243,15 +243,11 @@
   // it should be ignore.
   void CheckDisableAdapterEnumeration(
       uint32 total_ports,
-      const rtc::IPAddress& host_candidate_addr,
       const rtc::IPAddress& stun_candidate_addr,
       const rtc::IPAddress& relay_candidate_udp_transport_addr,
       const rtc::IPAddress& relay_candidate_tcp_transport_addr) {
-    if (!session_) {
-      EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
-    }
-    session_->set_flags(session_->flags() |
-                        cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
+    EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
+    session_->set_flags(cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION |
                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
     allocator().set_allow_tcp_listen(false);
@@ -259,36 +255,28 @@
     EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
 
     uint32 total_candidates = 0;
-    if (!host_candidate_addr.IsNil()) {
-      EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
-                   cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
-                   rtc::SocketAddress(host_candidate_addr, 0));
-      ++total_candidates;
-    }
     if (!stun_candidate_addr.IsNil()) {
-      EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
+      ++total_candidates;
+      EXPECT_PRED5(CheckCandidate, candidates_[0],
                    cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp",
                    rtc::SocketAddress(stun_candidate_addr, 0));
-      EXPECT_EQ(rtc::EmptySocketAddressWithFamily(
-                    candidates_[total_candidates].address().family()),
-                candidates_[total_candidates].related_address());
-      ++total_candidates;
+      EXPECT_EQ(
+          rtc::EmptySocketAddressWithFamily(candidates_[0].address().family()),
+          candidates_[0].related_address());
     }
     if (!relay_candidate_udp_transport_addr.IsNil()) {
-      EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
+      ++total_candidates;
+      EXPECT_PRED5(CheckCandidate, candidates_[1],
                    cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
                    rtc::SocketAddress(relay_candidate_udp_transport_addr, 0));
-      EXPECT_EQ(stun_candidate_addr,
-                candidates_[total_candidates].related_address().ipaddr());
-      ++total_candidates;
+      EXPECT_EQ(stun_candidate_addr, candidates_[1].related_address().ipaddr());
     }
     if (!relay_candidate_tcp_transport_addr.IsNil()) {
-      EXPECT_PRED5(CheckCandidate, candidates_[total_candidates],
+      ++total_candidates;
+      EXPECT_PRED5(CheckCandidate, candidates_[2],
                    cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
                    rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0));
-      EXPECT_EQ(stun_candidate_addr,
-                candidates_[total_candidates].related_address().ipaddr());
-      ++total_candidates;
+      EXPECT_EQ(stun_candidate_addr, candidates_[2].related_address().ipaddr());
     }
 
     EXPECT_EQ(total_candidates, candidates_.size());
@@ -521,7 +509,7 @@
   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
   // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and both STUN and
   // TURN/UDP candidates.
-  CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kNatUdpAddr.ipaddr(),
+  CheckDisableAdapterEnumeration(3U, kNatUdpAddr.ipaddr(),
                                  kTurnUdpExtAddr.ipaddr(), rtc::IPAddress());
 }
 
@@ -535,7 +523,7 @@
   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress());
   // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and both STUN and
   // TURN/UDP candidates.
-  CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kNatUdpAddr.ipaddr(),
+  CheckDisableAdapterEnumeration(3U, kNatUdpAddr.ipaddr(),
                                  kTurnUdpExtAddr.ipaddr(), rtc::IPAddress());
 }
 
@@ -549,7 +537,7 @@
   AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
   // Expect to see 4 ports - STUN, TURN/UDP, TURN/TCP and TCP port. STUN,
   // TURN/UDP, and TURN/TCP candidates.
-  CheckDisableAdapterEnumeration(4U, rtc::IPAddress(), kNatUdpAddr.ipaddr(),
+  CheckDisableAdapterEnumeration(4U, kNatUdpAddr.ipaddr(),
                                  kTurnUdpExtAddr.ipaddr(),
                                  kTurnUdpExtAddr.ipaddr());
 }
@@ -564,7 +552,7 @@
   // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, but only both STUN and
   // TURN candidates. The STUN candidate should have kClientAddr as srflx
   // address, and TURN candidate with kClientAddr as the related address.
-  CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kClientAddr.ipaddr(),
+  CheckDisableAdapterEnumeration(3U, kClientAddr.ipaddr(),
                                  kTurnUdpExtAddr.ipaddr(), rtc::IPAddress());
 }
 
@@ -575,22 +563,6 @@
   ResetWithNoServersOrNat();
   // Expect to see 2 ports: STUN and TCP ports, but no candidate.
   CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), rtc::IPAddress(),
-                                 rtc::IPAddress(), rtc::IPAddress());
-}
-
-// Test that when adapter enumeration is disabled, with
-// PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind
-// a NAT, there are a localhost candidate in addition to a STUN candidate.
-TEST_F(PortAllocatorTest,
-       TestDisableAdapterEnumerationWithoutNatLocalhostCandidateRequested) {
-  AddInterfaceAsDefaultRoute(kClientAddr);
-  ResetWithStunServerNoNat(kStunAddr);
-  EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
-  session_->set_flags(cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
-  // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN
-  // candidate.
-  CheckDisableAdapterEnumeration(2U, rtc::GetLoopbackIP(AF_INET),
-                                 kClientAddr.ipaddr(), rtc::IPAddress(),
                                  rtc::IPAddress());
 }
 
@@ -1165,32 +1137,6 @@
   EXPECT_EQ(1U, candidates_.size());
 }
 
-// Test that when the NetworkManager doesn't have permission to enumerate
-// adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified
-// automatically.
-TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) {
-  AddInterface(kClientAddr);
-  network_manager_.set_enumeration_permission(
-      rtc::NetworkManager::kEnumerationDisallowed);
-  allocator().set_flags(allocator().flags() |
-                        cricket::PORTALLOCATOR_DISABLE_RELAY |
-                        cricket::PORTALLOCATOR_DISABLE_TCP |
-                        cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
-                        cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
-  EXPECT_EQ(
-      allocator_->flags() & cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION,
-      0U);
-  EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
-  EXPECT_EQ(
-      session_->flags() & cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION,
-      0U);
-  session_->StartGettingPorts();
-  EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout);
-  EXPECT_EQ(0U, candidates_.size());
-  EXPECT_TRUE((session_->flags() &
-               cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0);
-}
-
 // This test verifies allocator can use IPv6 addresses along with IPv4.
 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) {
   allocator().set_flags(allocator().flags() |