diff --git a/docs/flags.md b/docs/flags.md index e185f8d137..23f2c0f308 100644 --- a/docs/flags.md +++ b/docs/flags.md @@ -63,6 +63,7 @@ These are also available on the `chrome://flags` page. Feature | Description -- | -- + `Mdns` | Enables mDNS and Service Discovery. `MinimalReferrers` | Removes all cross-origin referrers and strips same-origin referrers down to the origin. Has lower precedence than `NoCrossOriginReferrers`. `NoCrossOriginReferrers` | Removes all cross-origin referrers. Has lower precedence than `NoReferrers`. `NoReferrers` | Removes all referrers. diff --git a/flags.gn b/flags.gn index 8578089ae4..4bc82ae58e 100644 --- a/flags.gn +++ b/flags.gn @@ -3,13 +3,11 @@ chrome_pgo_phase=0 clang_use_chrome_plugins=false disable_fieldtrial_testing_config=true enable_hangout_services_extension=false -enable_mdns=false enable_mse_mpeg2ts_stream_parser=true enable_nacl=false enable_reading_list=false enable_remoting=false enable_reporting=false -enable_service_discovery=false enable_widevine=true exclude_unwind_tables=true google_api_key="" diff --git a/patches/extra/ungoogled-chromium/add-flag-to-enable-mdns.patch b/patches/extra/ungoogled-chromium/add-flag-to-enable-mdns.patch new file mode 100644 index 0000000000..8d91b90161 --- /dev/null +++ b/patches/extra/ungoogled-chromium/add-flag-to-enable-mdns.patch @@ -0,0 +1,99 @@ +--- a/chrome/browser/ungoogled_flag_entries.h ++++ b/chrome/browser/ungoogled_flag_entries.h +@@ -132,4 +132,8 @@ + "Minimal Referrers", + "Removes all cross-origin referrers and strips same-origin referrers down to the origin. Has lower precedence than remove-cross-origin-referrers. ungoogled-chromium flag.", + kOsAll, FEATURE_VALUE_TYPE(features::kMinimalReferrers)}, ++ {"enable-mdns", ++ "Enable mDNS", ++ "Enables mDNS and Service Discovery. ungoogled-chromium flag.", ++ kOsAll, FEATURE_VALUE_TYPE(network::features::kMdns)}, + #endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_ +--- a/net/dns/host_resolver_manager.cc ++++ b/net/dns/host_resolver_manager.cc +@@ -110,6 +110,7 @@ + #include "net/log/net_log_with_source.h" + #include "net/socket/client_socket_factory.h" + #include "net/url_request/url_request_context.h" ++#include "services/network/public/cpp/features.h" + #include "third_party/abseil-cpp/absl/types/optional.h" + #include "third_party/abseil-cpp/absl/types/variant.h" + #include "url/scheme_host_port.h" +@@ -179,6 +180,8 @@ bool ContainsIcannNameCollisionIp(const + + // True if |hostname| ends with either ".local" or ".local.". + bool ResemblesMulticastDNSName(base::StringPiece hostname) { ++ if (!base::FeatureList::IsEnabled(network::features::kMdns)) ++ return false; + return base::EndsWith(hostname, ".local") || + base::EndsWith(hostname, ".local."); + } +--- a/net/dns/mdns_client_impl.cc ++++ b/net/dns/mdns_client_impl.cc +@@ -26,6 +26,7 @@ + #include "net/dns/public/util.h" + #include "net/dns/record_rdata.h" + #include "net/socket/datagram_socket.h" ++#include "services/network/public/cpp/features.h" + #include "third_party/abseil-cpp/absl/types/optional.h" + + // TODO(gene): Remove this temporary method of disabling NSEC support once it +@@ -455,6 +456,8 @@ MDnsClientImpl::~MDnsClientImpl() { + } + + int MDnsClientImpl::StartListening(MDnsSocketFactory* socket_factory) { ++ if (!base::FeatureList::IsEnabled(network::features::kMdns)) ++ return ERR_ABORTED; + DCHECK(!core_.get()); + core_ = std::make_unique(clock_, cleanup_timer_.get()); + int rv = core_->Init(socket_factory); +--- a/services/network/p2p/socket_manager.cc ++++ b/services/network/p2p/socket_manager.cc +@@ -8,6 +8,7 @@ + + #include + ++#include "base/feature_list.h" + #include "base/functional/bind.h" + #include "base/memory/raw_ptr.h" + #include "base/task/single_thread_task_runner.h" +@@ -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" +@@ -114,7 +116,7 @@ class P2PSocketManager::DnsRequest { + net::HostPortPair host(host_name_, 0); + + net::HostResolver::ResolveHostParameters parameters; +- if (enable_mdns_ && HasLocalTld(host_name_)) { ++ if (enable_mdns_ && HasLocalTld(host_name_) && base::FeatureList::IsEnabled(features::kMdns)) { + #if BUILDFLAG(ENABLE_MDNS) + // HostResolver/MDnsClient expects a key without a trailing dot. + host.set_host(host_name_.substr(0, host_name_.size() - 1)); +--- a/services/network/public/cpp/features.cc ++++ b/services/network/public/cpp/features.cc +@@ -14,6 +14,10 @@ + + namespace network::features { + ++BASE_FEATURE(kMdns, ++ "Mdns", ++ base::FEATURE_DISABLED_BY_DEFAULT); ++ + BASE_FEATURE(kNetworkErrorLogging, + "NetworkErrorLogging", + base::FEATURE_ENABLED_BY_DEFAULT); +--- a/services/network/public/cpp/features.h ++++ b/services/network/public/cpp/features.h +@@ -13,6 +13,7 @@ + namespace network { + namespace features { + ++COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kMdns); + COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kNetworkErrorLogging); + COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kReporting); + COMPONENT_EXPORT(NETWORK_CPP) BASE_DECLARE_FEATURE(kThrottleDelayable); diff --git a/patches/extra/ungoogled-chromium/fix-building-without-mdns-and-service-discovery.patch b/patches/extra/ungoogled-chromium/fix-building-without-mdns-and-service-discovery.patch deleted file mode 100644 index 2b0ee0bcb5..0000000000 --- a/patches/extra/ungoogled-chromium/fix-building-without-mdns-and-service-discovery.patch +++ /dev/null @@ -1,42 +0,0 @@ -# Fix building with enable_service_discovery=false and enable_mds=false - ---- a/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.cc -+++ b/chrome/browser/media/router/discovery/mdns/dns_sd_device_lister.cc -@@ -40,37 +40,22 @@ DnsSdDeviceLister::DnsSdDeviceLister( - 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(); -- } -- device_lister_->DiscoverNewDevices(); --#endif - } - - void DnsSdDeviceLister::Reset() { -- 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); - } - - void DnsSdDeviceLister::OnDeviceRemoved(const std::string& service_type, - const std::string& service_name) { -- delegate_->ServiceRemoved(service_type, service_name); - } - - void DnsSdDeviceLister::OnDeviceCacheFlushed(const std::string& service_type) { -- delegate_->ServicesFlushed(device_lister_->service_type()); -- device_lister_->DiscoverNewDevices(); - } - - } // namespace media_router diff --git a/patches/series b/patches/series index bda5ac7b95..deaa0e94d5 100644 --- a/patches/series +++ b/patches/series @@ -59,7 +59,6 @@ extra/ungoogled-chromium/remove-disable-setuid-sandbox-as-bad-flag.patch extra/ungoogled-chromium/disable-intranet-redirect-detector.patch extra/ungoogled-chromium/enable-page-saving-on-more-pages.patch extra/ungoogled-chromium/disable-download-quarantine.patch -extra/ungoogled-chromium/fix-building-without-mdns-and-service-discovery.patch extra/ungoogled-chromium/add-flag-to-configure-extension-downloading.patch extra/ungoogled-chromium/add-flag-for-search-engine-collection.patch extra/ungoogled-chromium/add-flag-to-disable-beforeunload.patch @@ -104,3 +103,4 @@ extra/ungoogled-chromium/add-flags-for-referrer-customization.patch extra/ungoogled-chromium/default-webrtc-ip-handling-policy.patch extra/ungoogled-chromium/add-flags-for-existing-switches.patch extra/ungoogled-chromium/first-run-page.patch +extra/ungoogled-chromium/add-flag-to-enable-mdns.patch