107 lines
6 KiB
Diff
107 lines
6 KiB
Diff
From: csagan5 <32685696+csagan5@users.noreply.github.com>
|
|
Date: Wed, 29 Aug 2018 11:03:44 +0200
|
|
Subject: Add custom tab intents privacy option
|
|
|
|
---
|
|
chrome/android/java/res/xml/privacy_preferences.xml | 5 +++++
|
|
.../chrome/browser/LaunchIntentDispatcher.java | 4 ++++
|
|
.../browser/privacy/settings/PrivacySettings.java | 13 ++++++++++++-
|
|
.../ui/android/strings/android_chrome_strings.grd | 7 +++++++
|
|
4 files changed, 28 insertions(+), 1 deletion(-)
|
|
|
|
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
|
|
@@ -28,6 +28,11 @@
|
|
android:key="do_not_track"
|
|
android:title="@string/do_not_track_title"
|
|
android:order="3"/>
|
|
+ <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.ChromeBasePreference
|
|
android:key="secure_dns"
|
|
android:title="@string/settings_secure_dns_title"
|
|
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
|
|
@@ -55,6 +55,8 @@ import org.chromium.url.Origin;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
|
|
+import org.chromium.chrome.browser.privacy.settings.PrivacySettings;
|
|
+
|
|
/**
|
|
* Dispatches incoming intents to the appropriate activity based on the current configuration and
|
|
* Intent fired.
|
|
@@ -271,6 +273,8 @@ public class LaunchIntentDispatcher implements IntentHandler.IntentHandlerDelega
|
|
*/
|
|
public static boolean isCustomTabIntent(Intent intent) {
|
|
if (intent == null) 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;
|
|
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
|
|
@@ -47,10 +47,12 @@ public class PrivacySettings
|
|
private static final String PREF_DO_NOT_TRACK = "do_not_track";
|
|
private static final String PREF_CLEAR_BROWSING_DATA = "clear_browsing_data";
|
|
private static final String PREF_ALWAYS_INCOGNITO = "always_incognito";
|
|
+ public static final String PREF_ALLOW_CUSTOM_TAB_INTENTS = "allow_custom_tab_intents";
|
|
private static final String[] NEW_PRIVACY_PREFERENCE_ORDER = {PREF_CLEAR_BROWSING_DATA,
|
|
PREF_CAN_MAKE_PAYMENT, PREF_NETWORK_PREDICTIONS,
|
|
PREF_SECURE_DNS, PREF_DO_NOT_TRACK,
|
|
- PREF_ALWAYS_INCOGNITO
|
|
+ PREF_ALWAYS_INCOGNITO,
|
|
+ PREF_ALLOW_CUSTOM_TAB_INTENTS
|
|
};
|
|
|
|
private ManagedPreferenceDelegate mManagedPreferenceDelegate;
|
|
@@ -101,6 +103,10 @@ public class PrivacySettings
|
|
.setBoolean(Pref.CAN_MAKE_PAYMENT_ENABLED, (boolean) newValue);
|
|
} else if (PREF_NETWORK_PREDICTIONS.equals(key)) {
|
|
PrivacyPreferencesManager.getInstance().setNetworkPredictionEnabled((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();
|
|
}
|
|
|
|
return true;
|
|
@@ -124,6 +130,11 @@ public class PrivacySettings
|
|
canMakePaymentPref.setChecked(prefService.getBoolean(Pref.CAN_MAKE_PAYMENT_ENABLED));
|
|
}
|
|
|
|
+ ChromeSwitchPreference allowCustomTabIntentsPref =
|
|
+ (ChromeSwitchPreference) findPreference(PREF_ALLOW_CUSTOM_TAB_INTENTS);
|
|
+ allowCustomTabIntentsPref.setOnPreferenceChangeListener(this);
|
|
+ allowCustomTabIntentsPref.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
|
|
@@ -3956,6 +3956,13 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
|
|
<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>
|
|
|
|
<!-- Autofill Assistant preferences -->
|
|
<!-- TODO(b/168178344): Move to Assistant settings strings section below. -->
|
|
--
|
|
2.17.1
|
|
|