Add custom tab intents privacy option and force open external links in incognito flag.
Add-custom-tab-intents-privacy-option.patch and Force-open-external-links-in-incognito.patch have been unified
This commit is contained in:
parent
54ee34f629
commit
68edf66485
2 changed files with 175 additions and 2 deletions
|
@ -53,7 +53,6 @@ Add-flag-to-configure-maximum-connections-per-host.patch
|
|||
Do-not-ignore-download-location-prompt-setting.patch
|
||||
Add-bookmark-import-export-actions.patch
|
||||
Add-an-always-incognito-mode.patch
|
||||
Add-custom-tab-intents-privacy-option.patch
|
||||
Add-option-to-not-persist-tabs-across-sessions.patch
|
||||
Disable-fetching-of-all-field-trials.patch
|
||||
Disable-seed-based-field-trials.patch
|
||||
|
@ -157,8 +156,8 @@ Override-UA-client-hint-for-model.patch
|
|||
Disable-AGSA-by-default.patch
|
||||
Allow-building-without-enable_reporting.patch
|
||||
Disable-lock-icon-in-address-bar-by-default.patch
|
||||
Force-open-external-links-in-incognito.patch
|
||||
Enable-share-intent.patch
|
||||
Site-setting-for-images.patch
|
||||
Bromite-auto-updater.patch
|
||||
Automated-domain-substitution.patch
|
||||
Add-intents-privacy-option.patch
|
174
build/patches/Add-intents-privacy-option.patch
Normal file
174
build/patches/Add-intents-privacy-option.patch
Normal file
|
@ -0,0 +1,174 @@
|
|||
From: csagan5 <32685696+csagan5@users.noreply.github.com>
|
||||
Date: Wed, 29 Aug 2018 11:03:44 +0200
|
||||
Subject: Add custom tab intents privacy option
|
||||
|
||||
Add custom tab intents privacy option and force
|
||||
open external links in incognito flag.
|
||||
|
||||
Flags are mutually exclusive.
|
||||
|
||||
See also: https://github.com/bromite/bromite/issues/1474
|
||||
---
|
||||
.../java/res/xml/privacy_preferences.xml | 10 ++++++
|
||||
.../browser/LaunchIntentDispatcher.java | 19 ++++++++++
|
||||
.../privacy/settings/PrivacySettings.java | 35 +++++++++++++++++++
|
||||
.../strings/android_chrome_strings.grd | 15 ++++++++
|
||||
4 files changed, 79 insertions(+)
|
||||
|
||||
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
|
||||
@@ -56,6 +56,16 @@
|
||||
android:fragment="org.chromium.chrome.browser.privacy.settings.DoNotTrackSettings"
|
||||
android:key="do_not_track"
|
||||
android:title="@string/do_not_track_title"/>
|
||||
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
+ android:key="allow_custom_tab_intents"
|
||||
+ android:title="@string/allow_custom_tab_intents_title"
|
||||
+ android:summary="@string/allow_custom_tab_intents_summary"
|
||||
+ android:defaultValue="false" />
|
||||
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
+ android:key="open_external_links_incognito"
|
||||
+ android:title="@string/open_external_links_incognito_title"
|
||||
+ android:summary="@string/open_external_links_incognito_summary"
|
||||
+ android:defaultValue="false" />
|
||||
<Preference
|
||||
android:key="privacy_sandbox"
|
||||
android:title="@string/prefs_privacy_sandbox"
|
||||
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/LaunchIntentDispatcher.java b/chrome/android/java/src/org/chromium/chrome/browser/LaunchIntentDispatcher.java
|
||||
--- a/chrome/android/java/src/org/chromium/chrome/browser/LaunchIntentDispatcher.java
|
||||
+++ b/chrome/android/java/src/org/chromium/chrome/browser/LaunchIntentDispatcher.java
|
||||
@@ -59,6 +59,8 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Set;
|
||||
|
||||
+import org.chromium.chrome.browser.privacy.settings.PrivacySettings;
|
||||
+
|
||||
/**
|
||||
* Dispatches incoming intents to the appropriate activity based on the current configuration and
|
||||
* Intent fired.
|
||||
@@ -279,6 +281,12 @@ public class LaunchIntentDispatcher implements IntentHandler.IntentHandlerDelega
|
||||
*/
|
||||
public static boolean isCustomTabIntent(Intent intent) {
|
||||
if (intent == null) return false;
|
||||
+ if (ContextUtils.getAppSharedPreferences()
|
||||
+ .getBoolean(PrivacySettings.PREF_OPEN_EXTERNAL_LINKS_INCOGNITO, false))
|
||||
+ return false;
|
||||
+ if (!ContextUtils.getAppSharedPreferences()
|
||||
+ .getBoolean(PrivacySettings.PREF_ALLOW_CUSTOM_TAB_INTENTS, false))
|
||||
+ return false;
|
||||
if (CustomTabsIntent.shouldAlwaysUseBrowserUI(intent)
|
||||
|| !intent.hasExtra(CustomTabsIntent.EXTRA_SESSION)) {
|
||||
return false;
|
||||
@@ -417,6 +425,17 @@ public class LaunchIntentDispatcher implements IntentHandler.IntentHandlerDelega
|
||||
|
||||
if (Intent.ACTION_VIEW.equals(newIntent.getAction())
|
||||
&& !IntentHandler.wasIntentSenderChrome(newIntent)) {
|
||||
+
|
||||
+ if (ContextUtils.getAppSharedPreferences().getBoolean(
|
||||
+ PrivacySettings.PREF_OPEN_EXTERNAL_LINKS_INCOGNITO, false)) {
|
||||
+ Context applicationContext = ContextUtils.getApplicationContext();
|
||||
+ newIntent = IntentHandler.createTrustedOpenNewTabIntent(applicationContext,
|
||||
+ /*incognito*/true);
|
||||
+ newIntent.setData(mIntent.getData());
|
||||
+ newIntent.setPackage(applicationContext.getPackageName());
|
||||
+ newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
+ }
|
||||
+
|
||||
long time = SystemClock.elapsedRealtime();
|
||||
if (!chromeTabbedTaskExists()) {
|
||||
newIntent.putExtra(IntentHandler.EXTRA_STARTED_TABBED_CHROME_TASK, true);
|
||||
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java b/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
|
||||
--- a/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
|
||||
+++ b/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
|
||||
@@ -66,6 +66,8 @@ public class PrivacySettings
|
||||
private static final String PREF_CLEAR_BROWSING_DATA = "clear_browsing_data";
|
||||
private static final String PREF_CLOSE_TABS_ON_EXIT = "close_tabs_on_exit";
|
||||
private static final String PREF_PROXY_OPTIONS = "proxy";
|
||||
+ public static final String PREF_ALLOW_CUSTOM_TAB_INTENTS = "allow_custom_tab_intents";
|
||||
+ public static final String PREF_OPEN_EXTERNAL_LINKS_INCOGNITO = "open_external_links_incognito";
|
||||
private static final String PREF_PRIVACY_SANDBOX = "privacy_sandbox";
|
||||
private static final String PREF_FORCE_NO_JIT = "force_no_jit";
|
||||
|
||||
@@ -83,6 +85,9 @@ public class PrivacySettings
|
||||
|
||||
private ManagedPreferenceDelegate mManagedPreferenceDelegate;
|
||||
|
||||
+ private ChromeSwitchPreference allowCustomTabIntentsPref;
|
||||
+ private ChromeSwitchPreference openExternalLinksPref;
|
||||
+
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
PrivacyPreferencesManagerImpl privacyPrefManager =
|
||||
@@ -193,6 +198,26 @@ public class PrivacySettings
|
||||
} else if (PREF_INCOGNITO_TAB_HISTORY_ENABLED.equals(key)) {
|
||||
UserPrefs.get(Profile.getLastUsedRegularProfile())
|
||||
.setBoolean(Pref.INCOGNITO_TAB_HISTORY_ENABLED, (boolean) newValue);
|
||||
+ } else if (PREF_ALLOW_CUSTOM_TAB_INTENTS.equals(key)) {
|
||||
+ SharedPreferences.Editor sharedPreferencesEditor = ContextUtils.getAppSharedPreferences().edit();
|
||||
+ sharedPreferencesEditor.putBoolean(PREF_ALLOW_CUSTOM_TAB_INTENTS, (boolean)newValue);
|
||||
+ sharedPreferencesEditor.apply();
|
||||
+
|
||||
+ // PREF_ALLOW_CUSTOM_TAB_INTENTS and PREF_OPEN_EXTERNAL_LINKS_INCOGNITO
|
||||
+ // are mutually exclusive
|
||||
+ if((boolean)newValue && ContextUtils.getAppSharedPreferences()
|
||||
+ .getBoolean(PrivacySettings.PREF_OPEN_EXTERNAL_LINKS_INCOGNITO, false))
|
||||
+ openExternalLinksPref.setChecked(!(boolean)newValue);
|
||||
+ } else if (PREF_OPEN_EXTERNAL_LINKS_INCOGNITO.equals(key)) {
|
||||
+ SharedPreferences.Editor sharedPreferencesEditor = ContextUtils.getAppSharedPreferences().edit();
|
||||
+ sharedPreferencesEditor.putBoolean(PREF_OPEN_EXTERNAL_LINKS_INCOGNITO, (boolean)newValue);
|
||||
+ sharedPreferencesEditor.apply();
|
||||
+
|
||||
+ // PREF_ALLOW_CUSTOM_TAB_INTENTS and PREF_OPEN_EXTERNAL_LINKS_INCOGNITO
|
||||
+ // are mutually exclusive
|
||||
+ if((boolean)newValue && ContextUtils.getAppSharedPreferences()
|
||||
+ .getBoolean(PrivacySettings.PREF_ALLOW_CUSTOM_TAB_INTENTS, false))
|
||||
+ allowCustomTabIntentsPref.setChecked(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -226,6 +251,16 @@ public class PrivacySettings
|
||||
canMakePaymentPref.setChecked(prefService.getBoolean(Pref.CAN_MAKE_PAYMENT_ENABLED));
|
||||
}
|
||||
|
||||
+ allowCustomTabIntentsPref =
|
||||
+ (ChromeSwitchPreference) findPreference(PREF_ALLOW_CUSTOM_TAB_INTENTS);
|
||||
+ allowCustomTabIntentsPref.setOnPreferenceChangeListener(this);
|
||||
+ allowCustomTabIntentsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
|
||||
+
|
||||
+ openExternalLinksPref =
|
||||
+ (ChromeSwitchPreference) findPreference(PREF_OPEN_EXTERNAL_LINKS_INCOGNITO);
|
||||
+ openExternalLinksPref.setOnPreferenceChangeListener(this);
|
||||
+ openExternalLinksPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
|
||||
+
|
||||
Preference doNotTrackPref = findPreference(PREF_DO_NOT_TRACK);
|
||||
if (doNotTrackPref != null) {
|
||||
doNotTrackPref.setSummary(prefService.getBoolean(Pref.ENABLE_DO_NOT_TRACK)
|
||||
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd
|
||||
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
|
||||
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
|
||||
@@ -4509,6 +4509,21 @@ To change this setting, <ph name="BEGIN_LINK"><resetlink></ph>reset sync<p
|
||||
<message name="IDS_NEAR_OOM_REDUCTION_DECLINE" desc="The text of the button letting the user decline the browser's intervention, so that the page can be reloaded.">
|
||||
Show original
|
||||
</message>
|
||||
+ <!-- Allow custom tab intents -->
|
||||
+ <message name="IDS_ALLOW_CUSTOM_TAB_INTENTS_TITLE" desc="Text for 'Allow custom tab intents' settings-privacy option.">
|
||||
+ Allow custom tab intents
|
||||
+ </message>
|
||||
+ <message name="IDS_ALLOW_CUSTOM_TAB_INTENTS_SUMMARY" desc="Summary text for 'Allow custom tab intents' settings-privacy option.">
|
||||
+ Allow applications to open custom tab intents, similar to webview.
|
||||
+ </message>
|
||||
+
|
||||
+ <!-- Open External Links in Incognito -->
|
||||
+ <message name="IDS_OPEN_EXTERNAL_LINKS_INCOGNITO_TITLE" desc="Text for 'Open external links in incognito' settings-privacy option.">
|
||||
+ Open external links in incognito
|
||||
+ </message>
|
||||
+ <message name="IDS_OPEN_EXTERNAL_LINKS_INCOGNITO_SUMMARY" desc="Summary text for 'Open external links in incognito' settings-privacy option.">
|
||||
+ Force the opening of all external links in incognito mode
|
||||
+ </message>
|
||||
|
||||
<!-- Autofill Assistant preferences -->
|
||||
<!-- TODO(b/168178344): Move to Assistant settings strings section below. -->
|
||||
--
|
||||
2.17.1
|
||||
|
Loading…
Add table
Reference in a new issue