Add-user-setting-for-DNS-over-HTTPS-custom-URL.patch 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. From: csagan5 <32685696+csagan5@users.noreply.github.com>
  2. Date: Sat, 23 Nov 2019 10:55:16 +0100
  3. Subject: Add user setting for DNS-over-HTTPS custom URL
  4. ---
  5. chrome/android/chrome_java_sources.gni | 2 +
  6. chrome/android/java/res/layout/doh_editor.xml | 65 ++++++++++++++++
  7. chrome/android/java/res/values/values.xml | 2 +
  8. chrome/android/java/res/xml/doh_preferences.xml | 25 ++++++
  9. .../android/java/res/xml/privacy_preferences.xml | 5 ++
  10. .../chrome/browser/preferences/DoHEditor.java | 91 ++++++++++++++++++++++
  11. .../chrome/browser/preferences/DoHPreferences.java | 52 +++++++++++++
  12. .../chrome/browser/util/FeatureUtilities.java | 25 ++++++
  13. .../java/strings/android_chrome_strings.grd | 11 +++
  14. chrome/app/generated_resources.grd | 6 ++
  15. chrome/browser/android/feature_utilities.cc | 23 ++++++
  16. .../browser/net/system_network_context_manager.cc | 36 +--------
  17. chrome/common/chrome_features.cc | 4 +-
  18. 13 files changed, 313 insertions(+), 34 deletions(-)
  19. create mode 100644 chrome/android/java/res/layout/doh_editor.xml
  20. create mode 100644 chrome/android/java/res/xml/doh_preferences.xml
  21. create mode 100644 chrome/android/java/src/org/chromium/chrome/browser/preferences/DoHEditor.java
  22. create mode 100644 chrome/android/java/src/org/chromium/chrome/browser/preferences/DoHPreferences.java
  23. diff --git a/chrome/android/chrome_java_sources.gni b/chrome/android/chrome_java_sources.gni
  24. --- a/chrome/android/chrome_java_sources.gni
  25. +++ b/chrome/android/chrome_java_sources.gni
  26. @@ -1251,7 +1251,9 @@ chrome_java_sources = [
  27. "java/src/org/chromium/chrome/browser/preferences/ClearBrowsingDataCheckBoxPreference.java",
  28. "java/src/org/chromium/chrome/browser/preferences/ExpandablePreferenceGroup.java",
  29. "java/src/org/chromium/chrome/browser/preferences/HomepageEditor.java",
  30. + "java/src/org/chromium/chrome/browser/preferences/DoHEditor.java",
  31. "java/src/org/chromium/chrome/browser/preferences/HomepagePreferences.java",
  32. + "java/src/org/chromium/chrome/browser/preferences/DoHPreferences.java",
  33. "java/src/org/chromium/chrome/browser/preferences/HyperlinkPreference.java",
  34. "java/src/org/chromium/chrome/browser/preferences/LearnMorePreference.java",
  35. "java/src/org/chromium/chrome/browser/preferences/LegalInformationPreferences.java",
  36. diff --git a/chrome/android/java/res/layout/doh_editor.xml b/chrome/android/java/res/layout/doh_editor.xml
  37. new file mode 100644
  38. --- /dev/null
  39. +++ b/chrome/android/java/res/layout/doh_editor.xml
  40. @@ -0,0 +1,65 @@
  41. +<?xml version="1.0" encoding="utf-8"?>
  42. +<!-- Copyright 2015 The Chromium Authors. All rights reserved.
  43. + Use of this source code is governed by a BSD-style license that can be
  44. + found in the LICENSE file. -->
  45. +
  46. +<FrameLayout
  47. + xmlns:android="http://schemas.android.com/apk/res/android"
  48. + xmlns:app="http://schemas.android.com/apk/res-auto"
  49. + xmlns:tools="http://schemas.android.com/tools"
  50. + android:layout_width="match_parent"
  51. + android:layout_height="match_parent" >
  52. +
  53. + <ScrollView
  54. + android:layout_width="match_parent"
  55. + android:layout_height="match_parent"
  56. + android:id="@+id/scroll_view"
  57. + android:fillViewport="true" >
  58. +
  59. + <LinearLayout
  60. + android:layout_width="match_parent"
  61. + android:layout_height="wrap_content"
  62. + android:orientation="vertical"
  63. + android:focusableInTouchMode="true" >
  64. +
  65. + <org.chromium.chrome.browser.widget.ChromeTextInputLayout
  66. + android:id="@+id/doh_url"
  67. + style="@style/PreferenceScreenLayout"
  68. + android:layout_width="match_parent"
  69. + android:layout_height="wrap_content" >
  70. + <!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
  71. + <EditText
  72. + tools:ignore="Autofill"
  73. + android:id="@+id/doh_url_edit"
  74. + android:layout_width="match_parent"
  75. + android:layout_height="wrap_content"
  76. + android:inputType="textUri"
  77. + android:singleLine="true"
  78. + android:hint="@string/options_doh_edit_label" />
  79. + </org.chromium.chrome.browser.widget.ChromeTextInputLayout>
  80. +
  81. + <Space style="@style/ButtonBarTopSpacer" />
  82. + <View style="@style/ButtonBarTopDivider" />
  83. +
  84. + <LinearLayout style="@style/ButtonBar" >
  85. + <org.chromium.ui.widget.ButtonCompat
  86. + android:id="@+id/doh_reset"
  87. + style="@style/ButtonBarButton"
  88. + android:text="@string/reset" />
  89. +
  90. + <org.chromium.ui.widget.ButtonCompat
  91. + android:id="@+id/doh_cancel"
  92. + style="@style/ButtonBarButton"
  93. + android:text="@string/cancel" />
  94. +
  95. + <org.chromium.ui.widget.ButtonCompat
  96. + android:id="@+id/doh_save"
  97. + style="@style/ButtonBarButton"
  98. + android:text="@string/save" />
  99. + </LinearLayout>
  100. + </LinearLayout>
  101. + </ScrollView>
  102. +
  103. + <include layout="@layout/preferences_action_bar_shadow"/>
  104. +
  105. +</FrameLayout>
  106. diff --git a/chrome/android/java/res/values/values.xml b/chrome/android/java/res/values/values.xml
  107. --- a/chrome/android/java/res/values/values.xml
  108. +++ b/chrome/android/java/res/values/values.xml
  109. @@ -88,6 +88,8 @@
  110. <integer name="download_infobar_bar_fill_in_delay">400</integer>
  111. <integer name="download_infobar_bar_fill_out_delay">200</integer>
  112. + <string name="doh_help_url">https://www.bromite.org/doh</string>
  113. +
  114. <!-- Bottom navigation bar styling. -->
  115. <bool name="window_light_navigation_bar">true</bool>
  116. diff --git a/chrome/android/java/res/xml/doh_preferences.xml b/chrome/android/java/res/xml/doh_preferences.xml
  117. new file mode 100644
  118. --- /dev/null
  119. +++ b/chrome/android/java/res/xml/doh_preferences.xml
  120. @@ -0,0 +1,25 @@
  121. +<?xml version="1.0" encoding="utf-8"?>
  122. +<!-- Copyright 2015 The Chromium Authors. All rights reserved.
  123. + Use of this source code is governed by a BSD-style license that can be
  124. + found in the LICENSE file. -->
  125. +
  126. +<PreferenceScreen
  127. + xmlns:android="http://schemas.android.com/apk/res/android"
  128. + xmlns:app="http://schemas.android.com/apk/res-auto">
  129. +
  130. + <org.chromium.chrome.browser.preferences.ChromeSwitchPreference
  131. + android:key="doh_switch"
  132. + android:summaryOn="@string/text_on"
  133. + android:summaryOff="@string/text_off" />
  134. +
  135. + <org.chromium.chrome.browser.preferences.HyperlinkPreference
  136. + android:key="doh_help"
  137. + android:title="@string/doh_help"
  138. + app:url="@string/doh_help_url" />
  139. +
  140. + <Preference
  141. + android:key="doh_edit"
  142. + android:title="@string/options_doh_edit_label"
  143. + android:fragment="org.chromium.chrome.browser.preferences.DoHEditor" />
  144. +
  145. +</PreferenceScreen>
  146. diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml
  147. --- a/chrome/android/java/res/xml/privacy_preferences.xml
  148. +++ b/chrome/android/java/res/xml/privacy_preferences.xml
  149. @@ -19,6 +19,11 @@
  150. android:key="can_make_payment"
  151. android:title="@string/can_make_payment_title"
  152. android:summary="@string/settings_can_make_payment_toggle_label" />
  153. + <Preference
  154. + android:fragment="org.chromium.chrome.browser.preferences.DoHPreferences"
  155. + android:key="doh"
  156. + android:title="@string/options_doh_title"
  157. + android:summary="@string/options_doh_summary" />
  158. <org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
  159. android:key="preload_pages"
  160. android:title="@string/preload_pages_title"
  161. diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/DoHEditor.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/DoHEditor.java
  162. new file mode 100644
  163. --- /dev/null
  164. +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/DoHEditor.java
  165. @@ -0,0 +1,91 @@
  166. +// Copyright 2015 The Chromium Authors. All rights reserved.
  167. +// Use of this source code is governed by a BSD-style license that can be
  168. +// found in the LICENSE file.
  169. +
  170. +package org.chromium.chrome.browser.preferences;
  171. +
  172. +import android.os.Bundle;
  173. +import android.support.v4.app.Fragment;
  174. +import android.text.Editable;
  175. +import android.text.TextWatcher;
  176. +import android.view.LayoutInflater;
  177. +import android.view.View;
  178. +import android.view.ViewGroup;
  179. +import android.widget.Button;
  180. +import android.widget.EditText;
  181. +
  182. +import org.chromium.chrome.browser.util.FeatureUtilities;
  183. +import org.chromium.chrome.R;
  184. +import org.chromium.components.url_formatter.UrlFormatter;
  185. +
  186. +/**
  187. + * Provides the Java-UI for editing the DNS-over-HTTPS (DoH) preference.
  188. + */
  189. +public class DoHEditor extends Fragment implements TextWatcher {
  190. + private EditText mDoHUrlEdit;
  191. + private Button mSaveButton;
  192. + private Button mResetButton;
  193. +
  194. + @Override
  195. + public View onCreateView(LayoutInflater inflater, ViewGroup container,
  196. + Bundle savedInstanceState) {
  197. + super.onCreate(savedInstanceState);
  198. + getActivity().setTitle(R.string.options_doh_edit_title);
  199. +
  200. + View v = inflater.inflate(R.layout.doh_editor, container, false);
  201. + View scrollView = v.findViewById(R.id.scroll_view);
  202. + scrollView.getViewTreeObserver().addOnScrollChangedListener(
  203. + PreferenceUtils.getShowShadowOnScrollListener(v, v.findViewById(R.id.shadow)));
  204. + mDoHUrlEdit = (EditText) v.findViewById(R.id.doh_url_edit);
  205. + mDoHUrlEdit.setText(FeatureUtilities.getDoHTemplates());
  206. + mDoHUrlEdit.addTextChangedListener(this);
  207. + mDoHUrlEdit.requestFocus();
  208. +
  209. + initializeSaveCancelResetButtons(v);
  210. + return v;
  211. + }
  212. +
  213. + @Override
  214. + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  215. + }
  216. +
  217. + @Override
  218. + public void onTextChanged(CharSequence s, int start, int before, int count) {
  219. + mSaveButton.setEnabled(true);
  220. + mResetButton.setEnabled(true);
  221. + }
  222. +
  223. + @Override
  224. + public void afterTextChanged(Editable s) {
  225. + }
  226. +
  227. + private void initializeSaveCancelResetButtons(View v) {
  228. + mResetButton = (Button) v.findViewById(R.id.doh_reset);
  229. + mResetButton.setOnClickListener(new View.OnClickListener() {
  230. + @Override
  231. + public void onClick(View v) {
  232. + mDoHUrlEdit.setText(FeatureUtilities.getDoHTemplates());
  233. + getActivity().finish();
  234. + }
  235. + });
  236. +
  237. + mSaveButton = (Button) v.findViewById(R.id.doh_save);
  238. + mSaveButton.setEnabled(false);
  239. + mSaveButton.setOnClickListener(new View.OnClickListener() {
  240. + @Override
  241. + public void onClick(View v) {
  242. + FeatureUtilities.setDoHTemplates(
  243. + mDoHUrlEdit.getText().toString());
  244. + getActivity().finish();
  245. + }
  246. + });
  247. +
  248. + Button button = (Button) v.findViewById(R.id.doh_cancel);
  249. + button.setOnClickListener(new View.OnClickListener() {
  250. + @Override
  251. + public void onClick(View v) {
  252. + getActivity().finish();
  253. + }
  254. + });
  255. + }
  256. +}
  257. diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/DoHPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/DoHPreferences.java
  258. new file mode 100644
  259. --- /dev/null
  260. +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/DoHPreferences.java
  261. @@ -0,0 +1,52 @@
  262. +// Copyright 2015 The Chromium Authors. All rights reserved.
  263. +// Use of this source code is governed by a BSD-style license that can be
  264. +// found in the LICENSE file.
  265. +
  266. +package org.chromium.chrome.browser.preferences;
  267. +
  268. +import android.os.Bundle;
  269. +import android.support.v7.preference.Preference;
  270. +import android.support.v7.preference.PreferenceFragmentCompat;
  271. +
  272. +import org.chromium.chrome.browser.util.FeatureUtilities;
  273. +import org.chromium.base.VisibleForTesting;
  274. +import org.chromium.chrome.R;
  275. +
  276. +/**
  277. + * Fragment that allows the user to configure DoH related preferences.
  278. + */
  279. +public class DoHPreferences extends PreferenceFragmentCompat {
  280. + @VisibleForTesting
  281. + public static final String PREF_DOH_SWITCH = "doh_switch";
  282. + private static final String PREF_DOH_EDIT = "doh_edit";
  283. +
  284. + private Preference mDoHEdit;
  285. +
  286. + @Override
  287. + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
  288. + getActivity().setTitle(R.string.options_doh_title);
  289. + PreferenceUtils.addPreferencesFromResource(this, R.xml.doh_preferences);
  290. +
  291. + ChromeSwitchPreference mDoHSwitch =
  292. + (ChromeSwitchPreference) findPreference(PREF_DOH_SWITCH);
  293. + boolean isDoHEnabled = FeatureUtilities.getDoHEnabled();
  294. + mDoHSwitch.setChecked(isDoHEnabled);
  295. + mDoHSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
  296. + FeatureUtilities.setDoHEnabled((boolean) newValue);
  297. + return true;
  298. + });
  299. +
  300. + mDoHEdit = findPreference(PREF_DOH_EDIT);
  301. + updateCurrentDoHUrl();
  302. + }
  303. +
  304. + private void updateCurrentDoHUrl() {
  305. + mDoHEdit.setSummary(FeatureUtilities.getDoHTemplates());
  306. + }
  307. +
  308. + @Override
  309. + public void onResume() {
  310. + super.onResume();
  311. + updateCurrentDoHUrl();
  312. + }
  313. +}
  314. diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/FeatureUtilities.java b/chrome/android/java/src/org/chromium/chrome/browser/util/FeatureUtilities.java
  315. --- a/chrome/android/java/src/org/chromium/chrome/browser/util/FeatureUtilities.java
  316. +++ b/chrome/android/java/src/org/chromium/chrome/browser/util/FeatureUtilities.java
  317. @@ -163,6 +163,27 @@ public class FeatureUtilities {
  318. nativeSetCustomTabVisible(visible);
  319. }
  320. + /**
  321. + * Records whether custom URL for DoH is enabled with native-side feature utilities.
  322. + * @param url Whether custom URL is enabled or not.
  323. + */
  324. + public static void setDoHEnabled(boolean enabled) {
  325. + nativeSetDoHEnabled(enabled);
  326. + }
  327. +
  328. + public static boolean getDoHEnabled() {
  329. + return nativeGetDoHEnabled();
  330. + }
  331. +
  332. + public static void setDoHTemplates(String t) {
  333. + nativeSetDoHTemplates(t);
  334. + }
  335. +
  336. + public static String getDoHTemplates() {
  337. + return nativeGetDoHTemplates();
  338. + }
  339. +
  340. +
  341. /**
  342. * Records whether the activity is in multi-window mode with native-side feature utilities.
  343. * @param isInMultiWindowMode Whether the activity is in Android N multi-window mode.
  344. @@ -897,6 +918,10 @@ public class FeatureUtilities {
  345. }
  346. private static native void nativeSetCustomTabVisible(boolean visible);
  347. + private static native void nativeSetDoHEnabled(boolean enabled);
  348. + private static native boolean nativeGetDoHEnabled();
  349. + private static native void nativeSetDoHTemplates(String templates);
  350. + private static native String nativeGetDoHTemplates();
  351. private static native void nativeSetIsInMultiWindowMode(boolean isInMultiWindowMode);
  352. private static native boolean nativeIsNetworkServiceWarmUpEnabled();
  353. }
  354. diff --git a/chrome/android/java/strings/android_chrome_strings.grd b/chrome/android/java/strings/android_chrome_strings.grd
  355. --- a/chrome/android/java/strings/android_chrome_strings.grd
  356. +++ b/chrome/android/java/strings/android_chrome_strings.grd
  357. @@ -656,6 +656,17 @@ CHAR-LIMIT guidelines:
  358. Chrome Passwords
  359. </message>
  360. + <!-- DoH preferences -->
  361. + <message name="IDS_OPTIONS_DOH_EDIT_TITLE" desc="The title of the screen that allows users to change the URL that is used for DNS-over-HTTPS queries.">
  362. + Edit DoH template URLs
  363. + </message>
  364. + <message name="IDS_OPTIONS_DOH_EDIT_LABEL" desc="The label for the edit text field that allows the user to change the URL that is used for DNS-over-HTTPS queries.">
  365. + DoH template URLs
  366. + </message>
  367. + <message name="IDS_DOH_HELP" desc="The title of the hyperlink that allows users to visit the wiki page with instructions for DNS-over-HTTPS configuration.">
  368. + Visit help page
  369. + </message>
  370. +
  371. <!-- Homepage preferences -->
  372. <message name="IDS_OPTIONS_HOMEPAGE_EDIT_TITLE" desc="The title of the screen that allows users to change the URL that opens when they tap on the home page button in the omnibox.">
  373. Edit home page
  374. diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
  375. --- a/chrome/app/generated_resources.grd
  376. +++ b/chrome/app/generated_resources.grd
  377. @@ -6507,6 +6507,12 @@ the Bookmarks menu.">
  378. <message name="IDS_OPTIONS_HOMEPAGE_TITLE" desc="The title of the home page overlay on Android" formatter_data="android_java">
  379. Home page
  380. </message>
  381. + <message name="IDS_OPTIONS_DOH_TITLE" desc="The title of the DNS-over-HTTPS option on Android" formatter_data="android_java">
  382. + Secure DNS
  383. + </message>
  384. + <message name="IDS_OPTIONS_DOH_SUMMARY" desc="The title of the DNS-over-HTTPS summary on Android" formatter_data="android_java">
  385. + Configure DNS-over-HTTPS (DoH) secure DNS
  386. + </message>
  387. </if>
  388. <!-- Autofill dialog: field labels. -->
  389. diff --git a/chrome/browser/android/feature_utilities.cc b/chrome/browser/android/feature_utilities.cc
  390. --- a/chrome/browser/android/feature_utilities.cc
  391. +++ b/chrome/browser/android/feature_utilities.cc
  392. @@ -7,6 +7,9 @@
  393. #include "chrome/android/chrome_jni_headers/FeatureUtilities_jni.h"
  394. #include "base/android/jni_string.h"
  395. +#include "chrome/browser/browser_process.h"
  396. +#include "components/prefs/pref_service.h"
  397. +#include "chrome/common/pref_names.h"
  398. #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
  399. #include "chrome/browser/profiles/profile_manager.h"
  400. #include "components/ntp_snippets/content_suggestions_service.h"
  401. @@ -73,3 +76,23 @@ static jboolean JNI_FeatureUtilities_IsNetworkServiceWarmUpEnabled(
  402. return content::IsOutOfProcessNetworkService() &&
  403. base::FeatureList::IsEnabled(features::kWarmUpNetworkProcess);
  404. }
  405. +
  406. +static jboolean JNI_FeatureUtilities_GetDoHEnabled(JNIEnv* env) {
  407. + std::string doh_mode = g_browser_process->local_state()->GetString(prefs::kDnsOverHttpsMode);
  408. + return ((doh_mode == "secure") || (doh_mode == "auto"));
  409. +}
  410. +
  411. +static void JNI_FeatureUtilities_SetDoHEnabled(JNIEnv* env, jboolean enabled) {
  412. + if (enabled)
  413. + g_browser_process->local_state()->SetString(prefs::kDnsOverHttpsMode, "secure");
  414. + else
  415. + g_browser_process->local_state()->SetString(prefs::kDnsOverHttpsMode, "off");
  416. +}
  417. +
  418. +static ScopedJavaLocalRef<jstring> JNI_FeatureUtilities_GetDoHTemplates(JNIEnv* env) {
  419. + return base::android::ConvertUTF8ToJavaString(env, g_browser_process->local_state()->GetString(prefs::kDnsOverHttpsTemplates));
  420. +}
  421. +
  422. +static void JNI_FeatureUtilities_SetDoHTemplates(JNIEnv* env, const JavaParamRef<jstring>& templates) {
  423. + g_browser_process->local_state()->SetString(prefs::kDnsOverHttpsTemplates, base::android::ConvertJavaStringToUTF8(env, templates));
  424. +}
  425. diff --git a/chrome/browser/net/system_network_context_manager.cc b/chrome/browser/net/system_network_context_manager.cc
  426. --- a/chrome/browser/net/system_network_context_manager.cc
  427. +++ b/chrome/browser/net/system_network_context_manager.cc
  428. @@ -134,6 +134,7 @@ void GetStubResolverConfig(
  429. std::string doh_templates =
  430. local_state->GetString(prefs::kDnsOverHttpsTemplates);
  431. + LOG(INFO) << "DoH templates: '" << doh_templates << "' with mode " << doh_mode;
  432. std::string server_method;
  433. if (!doh_templates.empty() &&
  434. *secure_dns_mode != net::DnsConfig::SecureDnsMode::OFF) {
  435. @@ -404,40 +405,11 @@ SystemNetworkContextManager::SystemNetworkContextManager(
  436. // features before registering change callbacks for these preferences.
  437. local_state_->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled,
  438. base::Value(ShouldEnableAsyncDns()));
  439. - std::string default_doh_mode = chrome_browser_net::kDnsOverHttpsModeOff;
  440. - std::string default_doh_templates = "";
  441. - if (base::FeatureList::IsEnabled(features::kDnsOverHttps)) {
  442. - if (features::kDnsOverHttpsFallbackParam.Get()) {
  443. - default_doh_mode = chrome_browser_net::kDnsOverHttpsModeAutomatic;
  444. - } else {
  445. - default_doh_mode = chrome_browser_net::kDnsOverHttpsModeSecure;
  446. - }
  447. - default_doh_templates = features::kDnsOverHttpsTemplatesParam.Get();
  448. - }
  449. + //NOTE: DoH fallback feature to insecure mode is not evaluated
  450. local_state_->SetDefaultPrefValue(prefs::kDnsOverHttpsMode,
  451. - base::Value(default_doh_mode));
  452. + base::Value(chrome_browser_net::kDnsOverHttpsModeOff));
  453. local_state_->SetDefaultPrefValue(prefs::kDnsOverHttpsTemplates,
  454. - base::Value(default_doh_templates));
  455. -
  456. - // If the user has explicitly enabled or disabled the DoH experiment in
  457. - // chrome://flags, store that choice in the user prefs so that it can be
  458. - // persisted after the experiment ends. Also make sure to remove the stored
  459. - // prefs value if the user has changed their chrome://flags selection to the
  460. - // default.
  461. - flags_ui::PrefServiceFlagsStorage flags_storage(local_state_);
  462. - std::set<std::string> entries = flags_storage.GetFlags();
  463. - if (entries.count("dns-over-https@1")) {
  464. - // The user has "Enabled" selected.
  465. - local_state_->SetString(prefs::kDnsOverHttpsMode,
  466. - chrome_browser_net::kDnsOverHttpsModeAutomatic);
  467. - } else if (entries.count("dns-over-https@2")) {
  468. - // The user has "Disabled" selected.
  469. - local_state_->SetString(prefs::kDnsOverHttpsMode,
  470. - chrome_browser_net::kDnsOverHttpsModeOff);
  471. - } else {
  472. - // The user has "Default" selected.
  473. - local_state_->ClearPref(prefs::kDnsOverHttpsMode);
  474. - }
  475. + base::Value(features::kDnsOverHttpsTemplatesParam.Get()));
  476. PrefChangeRegistrar::NamedChangeCallback dns_pref_callback =
  477. base::BindRepeating(&OnStubResolverConfigChanged,
  478. diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc
  479. --- a/chrome/common/chrome_features.cc
  480. +++ b/chrome/common/chrome_features.cc
  481. @@ -271,12 +271,12 @@ const char kDisallowUnsafeHttpDownloadsParamName[] = "MimeTypeList";
  482. // Enable DNS over HTTPS (DoH).
  483. const base::Feature kDnsOverHttps{"DnsOverHttps",
  484. - base::FEATURE_DISABLED_BY_DEFAULT};
  485. + base::FEATURE_ENABLED_BY_DEFAULT};
  486. // Set whether fallback to insecure DNS is allowed by default. This setting may
  487. // be overridden for individual transactions.
  488. const base::FeatureParam<bool> kDnsOverHttpsFallbackParam{&kDnsOverHttps,
  489. - "Fallback", true};
  490. + "Fallback", false};
  491. // Supply one or more space-separated DoH server URI templates to use when this
  492. // feature is enabled. If no templates are specified, then a hardcoded mapping
  493. --
  494. 2.11.0