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

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