From: csagan5 <32685696+csagan5@users.noreply.github.com> Date: Tue, 25 May 2021 19:46:14 +0200 Subject: Add flag to disable external intent requests Adds a new flag that allows to control the switch with same name; when flag is disabled no external intent will ever be allowed, for any URL. License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- .../java/res/xml/privacy_preferences.xml | 7 +++- .../ExternalNavigationDelegateImpl.java | 3 +- .../cromite/sAllowExternalIntentRequests.java | 33 +++++++++++++++++++ ...g-to-disable-external-intent-requests.grdp | 9 +++++ ...ag-to-disable-external-intent-requests.inc | 13 ++++++++ ...ag-to-disable-external-intent-requests.inc | 3 ++ 6 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/sAllowExternalIntentRequests.java create mode 100644 chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-flag-to-disable-external-intent-requests.grdp create mode 100644 cromite_flags/chrome/browser/about_flags_cc/Add-flag-to-disable-external-intent-requests.inc create mode 100644 cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/Add-flag-to-disable-external-intent-requests.inc diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml --- a/chrome/android/java/res/xml/privacy_preferences.xml +++ b/chrome/android/java/res/xml/privacy_preferences.xml @@ -83,7 +83,12 @@ found in the LICENSE file. android:title="@string/settings_incognito_tab_lock_title" android:summary="@string/settings_incognito_tab_lock_summary_android_setting_off" android:persistent="false" /> - + diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java --- a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java @@ -19,6 +19,7 @@ import org.chromium.base.IntentUtils; import org.chromium.base.PackageManagerUtils; import org.chromium.base.supplier.Supplier; import org.chromium.chrome.browser.ChromeTabbedActivity2; +import org.chromium.chrome.browser.flags.cromite.sAllowExternalIntentRequests; import org.chromium.chrome.browser.IntentHandler; import org.chromium.chrome.browser.tab.EmptyTabObserver; import org.chromium.chrome.browser.tab.Tab; @@ -103,7 +104,7 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat @Override public boolean shouldDisableExternalIntentRequestsForUrl(GURL url) { - return false; + return !sAllowExternalIntentRequests.getInstance().isEnabled(); } @Override diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/sAllowExternalIntentRequests.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/sAllowExternalIntentRequests.java new file mode 100644 --- /dev/null +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/cromite/sAllowExternalIntentRequests.java @@ -0,0 +1,33 @@ +/* + This file is part of Cromite. + + Cromite is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Cromite is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Cromite. If not, see . +*/ + +package org.chromium.chrome.browser.flags.cromite; + +import org.chromium.base.cached_flags.CachedFlag; +import org.chromium.chrome.browser.flags.ChromeFeatureMap; + +public class sAllowExternalIntentRequests { + private static final CachedFlag sInstance = + new CachedFlag(ChromeFeatureMap.getInstance(), + "AllowExternalIntentRequests", false); + + private sAllowExternalIntentRequests() {} + + public static CachedFlag getInstance() { + return sInstance; + } +} diff --git a/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-flag-to-disable-external-intent-requests.grdp b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-flag-to-disable-external-intent-requests.grdp new file mode 100644 --- /dev/null +++ b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-flag-to-disable-external-intent-requests.grdp @@ -0,0 +1,9 @@ + + + + Allow forward URL requests to external intents + + + If disabled, URL requests will never allow for redirecting to an external intent. + + diff --git a/cromite_flags/chrome/browser/about_flags_cc/Add-flag-to-disable-external-intent-requests.inc b/cromite_flags/chrome/browser/about_flags_cc/Add-flag-to-disable-external-intent-requests.inc new file mode 100644 --- /dev/null +++ b/cromite_flags/chrome/browser/about_flags_cc/Add-flag-to-disable-external-intent-requests.inc @@ -0,0 +1,13 @@ +#if BUILDFLAG(IS_ANDROID) + +#ifdef FLAG_SECTION + + {"allow-external-intent-requests", + "Allow forward URL requests to external intents", + "If disabled, URL requests will never" + "allow for redirecting to an external intent.", kOsAndroid, + SINGLE_DISABLE_VALUE_TYPE("disable-external-intent-requests")}, + +#endif + +#endif diff --git a/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/Add-flag-to-disable-external-intent-requests.inc b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/Add-flag-to-disable-external-intent-requests.inc new file mode 100644 --- /dev/null +++ b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/Add-flag-to-disable-external-intent-requests.inc @@ -0,0 +1,3 @@ +CROMITE_FEATURE(kAllowExternalIntentRequests, + "AllowExternalIntentRequests", + base::FEATURE_DISABLED_BY_DEFAULT); --