#include "chrome/browser/net/stub_resolver_config_reader.h"
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/default_dns_over_https_config_source.h"
#include "chrome/browser/net/dns_over_https_config_source.h"
#include "chrome/browser/net/secure_dns_config.h"
#include "chrome/browser/net/secure_dns_util.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "components/flags_ui/pref_service_flags_storage.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/network_service_instance.h"
#include "net/base/features.h"
#include "net/dns/public/dns_over_https_config.h"
#include "net/dns/public/secure_dns_mode.h"
#include "net/dns/public/util.h"
#include "services/network/public/mojom/host_resolver.mojom.h"
#include "services/network/public/mojom/network_service.mojom.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#include "chrome/browser/enterprise/util/android_enterprise_info.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "base/enterprise_util.h"
#include "base/win/win_util.h"
#include "chrome/browser/win/parental_controls.h"
#endif
namespace {
enum class SecureDnsModeDetailsForHistogram { … };
#if BUILDFLAG(IS_WIN)
bool ShouldDisableDohForWindowsParentalControls() {
return GetWinParentalControls().web_filter;
}
#endif
bool ShouldEnableAsyncDns() { … }
}
constexpr base::TimeDelta StubResolverConfigReader::kParentalControlsCheckDelay;
StubResolverConfigReader::StubResolverConfigReader(PrefService* local_state,
bool set_up_pref_defaults)
: … { … }
StubResolverConfigReader::~StubResolverConfigReader() = default;
void StubResolverConfigReader::RegisterPrefs(PrefRegistrySimple* registry) { … }
SecureDnsConfig StubResolverConfigReader::GetSecureDnsConfiguration(
bool force_check_parental_controls_for_automatic_mode) { … }
void StubResolverConfigReader::UpdateNetworkService(bool record_metrics) { … }
bool StubResolverConfigReader::ShouldDisableDohForManaged() { … }
bool StubResolverConfigReader::ShouldDisableDohForParentalControls() { … }
void StubResolverConfigReader::SetOverrideDnsOverHttpsConfigSource(
std::unique_ptr<DnsOverHttpsConfigSource> doh_source) { … }
const DnsOverHttpsConfigSource*
StubResolverConfigReader::GetDnsOverHttpsConfigSource() const { … }
void StubResolverConfigReader::OnParentalControlsDelayTimer() { … }
bool StubResolverConfigReader::GetInsecureStubResolverEnabled() { … }
SecureDnsConfig StubResolverConfigReader::GetAndUpdateConfiguration(
bool force_check_parental_controls_for_automatic_mode,
bool record_metrics,
bool update_network_service) { … }
#if BUILDFLAG(IS_ANDROID)
void StubResolverConfigReader::OnAndroidOwnedStateCheckComplete(
bool has_profile_owner,
bool has_device_owner) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
android_has_owner_ = has_profile_owner || has_device_owner;
if (android_has_owner_.value())
UpdateNetworkService(false );
}
#endif