Android build for ungoogled-chromium. https://uc.droidware.info
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

517 lines
23 KiB

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