Skip to content

Commit

Permalink
Rebase to 107 and address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Eloston committed Oct 30, 2022
1 parent 1aad5fa commit c0b871f
Showing 1 changed file with 31 additions and 143 deletions.
174 changes: 31 additions & 143 deletions patches/extra/ungoogled-chromium/add-flag-to-disable-mdns.patch
Original file line number Diff line number Diff line change
@@ -1,134 +1,3 @@
--- a/chrome/browser/devtools/BUILD.gn
+++ b/chrome/browser/devtools/BUILD.gn
@@ -107,6 +107,7 @@ static_library("devtools") {
"//components/paint_preview/buildflags:buildflags",
"//content/public/browser",
"//net",
+ "//services/network/public/cpp",
"//services/viz/privileged/mojom/compositing",
"//third_party/blink/public:buildflags",
"//ui/events:dom_keycode_converter",
--- a/chrome/browser/devtools/device/devtools_android_bridge.cc
+++ b/chrome/browser/devtools/device/devtools_android_bridge.cc
@@ -17,6 +17,7 @@
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
+#include "base/feature_list.h"
#include "base/json/json_reader.h"
#include "base/lazy_instance.h"
#include "base/memory/singleton.h"
@@ -44,6 +45,7 @@
#include "content/public/browser/devtools_external_agent_proxy_delegate.h"
#include "net/base/host_port_pair.h"
#include "net/base/net_errors.h"
+#include "services/network/public/cpp/features.h"

#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
#include "chrome/browser/devtools/device/cast_device_provider.h"
@@ -372,7 +374,9 @@ void DevToolsAndroidBridge::CreateDevice
device_providers.push_back(provider);

#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
- device_providers.push_back(new CastDeviceProvider());
+ if (!base::FeatureList::IsEnabled(network::features::kDisableMdns)) {
+ device_providers.push_back(new CastDeviceProvider());
+ }
#endif

device_providers.push_back(new AdbDeviceProvider());
--- a/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.cc
+++ b/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.cc
@@ -4,7 +4,9 @@

#include "chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.h"

+#include "base/feature_list.h"
#include "chrome/browser/media/router/discovery/mdns/dns_sd_delegate.h"
+#include "services/network/public/cpp/features.h"

using local_discovery::ServiceDescription;

@@ -28,7 +30,8 @@ DnsSdDeviceLister::DnsSdDeviceLister(
local_discovery::ServiceDiscoveryClient* service_discovery_client,
DnsSdDelegate* delegate,
const std::string& service_type)
- : delegate_(delegate)
+ : delegate_(delegate),
+ enable_mdns_(!base::FeatureList::IsEnabled(network::features::kDisableMdns))
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
,
service_discovery_client_(service_discovery_client),
@@ -41,36 +44,46 @@ DnsSdDeviceLister::~DnsSdDeviceLister()

void DnsSdDeviceLister::Discover() {
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
- if (!device_lister_) {
- device_lister_ = local_discovery::ServiceDiscoveryDeviceLister::Create(
- this, service_discovery_client_, service_type_);
- device_lister_->Start();
+ if (enable_mdns_) {
+ if (!device_lister_) {
+ device_lister_ = local_discovery::ServiceDiscoveryDeviceLister::Create(
+ this, service_discovery_client_, service_type_);
+ device_lister_->Start();
+ }
+ device_lister_->DiscoverNewDevices();
}
- device_lister_->DiscoverNewDevices();
#endif
}

void DnsSdDeviceLister::Reset() {
- device_lister_.reset();
+ if (enable_mdns_) {
+ device_lister_.reset();
+ }
}

void DnsSdDeviceLister::OnDeviceChanged(
const std::string& service_type,
bool added,
const ServiceDescription& service_description) {
- DnsSdService service;
- FillServiceInfo(service_description, &service);
- delegate_->ServiceChanged(device_lister_->service_type(), added, service);
+ if (enable_mdns_) {
+ DnsSdService service;
+ FillServiceInfo(service_description, &service);
+ delegate_->ServiceChanged(device_lister_->service_type(), added, service);
+ }
}

void DnsSdDeviceLister::OnDeviceRemoved(const std::string& service_type,
const std::string& service_name) {
- delegate_->ServiceRemoved(service_type, service_name);
+ if (enable_mdns_) {
+ delegate_->ServiceRemoved(service_type, service_name);
+ }
}

void DnsSdDeviceLister::OnDeviceCacheFlushed(const std::string& service_type) {
- delegate_->ServicesFlushed(device_lister_->service_type());
- device_lister_->DiscoverNewDevices();
+ if (enable_mdns_) {
+ delegate_->ServicesFlushed(device_lister_->service_type());
+ device_lister_->DiscoverNewDevices();
+ }
}

} // namespace media_router
--- a/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.h
+++ b/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.h
@@ -57,6 +57,8 @@ class DnsSdDeviceLister
// Created when Discover() is called, if service discovery is enabled.
std::unique_ptr<local_discovery::ServiceDiscoveryDeviceLister> device_lister_;

+ const bool enable_mdns_;
+
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
// The client and service type used to create |device_lister_|.
const raw_ptr<local_discovery::ServiceDiscoveryClient>
--- a/chrome/browser/ungoogled_flag_entries.h
+++ b/chrome/browser/ungoogled_flag_entries.h
@@ -116,4 +116,8 @@
Expand All @@ -150,23 +19,42 @@
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
@@ -13,6 +14,7 @@
@@ -14,6 +15,7 @@
#include "net/base/ip_endpoint.h"
#include "net/http/http_response_headers.h"
#include "net/net_buildflags.h"
+#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/network_context.mojom.h"
@@ -90,7 +92,7 @@ void ResolveHostAndOpenSocket::Start() {
network::mojom::ResolveHostParametersPtr parameters =
network::mojom::ResolveHostParameters::New();
@@ -31,6 +33,9 @@ constexpr int kHttpsPort = 443;

#if BUILDFLAG(ENABLE_MDNS)
- if (ResemblesMulticastDNSName(*options_->remote_hostname)) {
+ if (!base::FeatureList::IsEnabled(network::features::kDisableMdns) && ResemblesMulticastDNSName(*options_->remote_hostname)) {
parameters->source = net::HostResolverSource::MULTICAST_DNS;
is_mdns_name_ = true;
}
bool ResemblesMulticastDNSName(const std::string& hostname) {
+ if (!base::FeatureList::IsEnabled(network::features::kDisableMdns) {
+ return false;
+ }
return base::EndsWith(hostname, ".local") ||
base::EndsWith(hostname, ".local.");
}
@@ -368,4 +373,4 @@ void ResolveHostAndOpenUDPSocket::OnUdpC
delete this;
}

-} // namespace content
\ No newline at end of file
+} // namespace content
--- a/net/dns/mdns_client_impl.cc
+++ b/net/dns/mdns_client_impl.cc
@@ -452,6 +452,8 @@ MDnsClientImpl::~MDnsClientImpl() {
}

int MDnsClientImpl::StartListening(MDnsSocketFactory* socket_factory) {
+ if (base::FeatureList::IsEnabled(network::features::kDisableMdns))
+ return ERR_ABORTED;
DCHECK(!core_.get());
core_ = std::make_unique<Core>(clock_, cleanup_timer_.get());
int rv = core_->Init(socket_factory);
--- a/services/network/p2p/socket_manager.cc
+++ b/services/network/p2p/socket_manager.cc
@@ -9,6 +9,7 @@
Expand All @@ -177,15 +65,15 @@
#include "base/memory/raw_ptr.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -27,6 +28,7 @@
@@ -29,6 +30,7 @@
#include "net/url_request/url_request_context_getter.h"
#include "services/network/p2p/socket.h"
#include "services/network/proxy_resolving_client_socket_factory.h"
+#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/p2p_param_traits.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/webrtc/media/base/rtp_utils.h"
#include "third_party/webrtc/media/base/turn_utils.h"
@@ -103,7 +105,7 @@ class P2PSocketManager::DnsRequest {
@@ -111,7 +113,7 @@ class P2PSocketManager::DnsRequest {
net::HostPortPair host(host_name_, 0);

net::HostResolver::ResolveHostParameters parameters;
Expand Down

0 comments on commit c0b871f

Please sign in to comment.