dalyk | 272d4b0 | 2019-08-14 00:37:51 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_NET_DNS_UTIL_H_ |
| 6 | #define CHROME_BROWSER_NET_DNS_UTIL_H_ |
| 7 | |
Ben Schwartz | 4e146861 | 2020-03-31 21:23:45 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
| 10 | #include "base/strings/string_piece.h" |
Ben Schwartz | 78ff2568f | 2020-04-30 05:15:18 | [diff] [blame^] | 11 | #include "net/dns/dns_config_overrides.h" |
dalyk | 272d4b0 | 2019-08-14 00:37:51 | [diff] [blame] | 12 | |
Martin Šrámek | 5921f631 | 2020-03-25 09:31:47 | [diff] [blame] | 13 | class PrefRegistrySimple; |
| 14 | class PrefService; |
| 15 | |
Steven Bingler | dd2307b | 2019-08-27 20:44:36 | [diff] [blame] | 16 | namespace chrome_browser_net { |
| 17 | |
Ben Schwartz | 4e146861 | 2020-03-31 21:23:45 | [diff] [blame] | 18 | // Implements the whitespace-delimited group syntax for DoH templates. |
| 19 | std::vector<base::StringPiece> SplitDohTemplateGroup(base::StringPiece group); |
| 20 | |
| 21 | // Returns true if a group of templates are all valid per |
| 22 | // net::dns_util::IsValidDohTemplate(). This should be checked before updating |
| 23 | // stored preferences. |
| 24 | bool IsValidDohTemplateGroup(base::StringPiece group); |
| 25 | |
Ben Schwartz | 78ff2568f | 2020-04-30 05:15:18 | [diff] [blame^] | 26 | // Modifies |overrides| to use the DoH server specified by |server_template|. |
| 27 | void ApplyDohTemplate(net::DnsConfigOverrides* overrides, |
| 28 | base::StringPiece server_template); |
| 29 | |
Steven Bingler | ace5fd2 | 2019-08-20 21:01:20 | [diff] [blame] | 30 | const char kDnsOverHttpsModeOff[] = "off"; |
| 31 | const char kDnsOverHttpsModeAutomatic[] = "automatic"; |
| 32 | const char kDnsOverHttpsModeSecure[] = "secure"; |
| 33 | |
dalyk | 0180bcf | 2020-02-27 01:22:00 | [diff] [blame] | 34 | // Forced management description types. We will check for the override cases in |
| 35 | // the order they are listed in the enum. |
| 36 | enum class SecureDnsUiManagementMode { |
| 37 | // Chrome did not override the secure DNS settings. |
| 38 | kNoOverride, |
| 39 | // Secure DNS was disabled due to detection of a managed environment. |
| 40 | kDisabledManaged, |
| 41 | // Secure DNS was disabled due to detection of OS-level parental controls. |
| 42 | kDisabledParentalControls, |
| 43 | }; |
| 44 | |
Martin Šrámek | 5921f631 | 2020-03-25 09:31:47 | [diff] [blame] | 45 | // Registers the backup preference required for the DNS probes setting reset. |
| 46 | // TODO(crbug.com/1062698): Remove this once the privacy settings redesign |
| 47 | // is fully launched. |
| 48 | void RegisterDNSProbesSettingBackupPref(PrefRegistrySimple* registry); |
| 49 | |
| 50 | // Backs up the unneeded preference controlling DNS and captive portal probes |
| 51 | // once the privacy settings redesign is enabled, or restores the backup |
| 52 | // in case the feature is rolled back. |
| 53 | // TODO(crbug.com/1062698): Remove this once the privacy settings redesign |
| 54 | // is fully launched. |
| 55 | void MigrateDNSProbesSettingToOrFromBackup(PrefService* prefs); |
| 56 | |
Steven Bingler | dd2307b | 2019-08-27 20:44:36 | [diff] [blame] | 57 | } // namespace chrome_browser_net |
| 58 | |
dalyk | 272d4b0 | 2019-08-14 00:37:51 | [diff] [blame] | 59 | #endif // CHROME_BROWSER_NET_DNS_UTIL_H_ |