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 License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- .../java/res/xml/privacy_preferences.xml | 10 ++++++++ .../browser/LaunchIntentDispatcher.java | 21 ++++++++++++++++ .../IncognitoCustomTabIntentDataProvider.java | 6 +++++ .../privacy/settings/PrivacySettings.java | 24 +++++++++++++++++++ .../flags/android/chrome_feature_list.cc | 6 ++--- .../chrome/browser/tab/TabAssociatedApp.java | 6 ++++- .../strings/android_chrome_strings.grd | 14 +++++++++++ .../core/common/language_experiments.cc | 4 ++-- 8 files changed, 85 insertions(+), 6 deletions(-) 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 @@ -74,6 +74,16 @@ found in the LICENSE file. android:fragment="org.chromium.chrome.browser.privacy.settings.DoNotTrackSettings" android:key="do_not_track" android:title="@string/do_not_track_title"/> + + ", "", servicesLink)); } + 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"; + @Override public boolean onPreferenceChange(Preference preference, Object newValue) { String key = preference.getKey(); @@ -263,6 +269,14 @@ public class PrivacySettings } else if (PREF_SEARCH_SUGGESTIONS.equals(key)) { UserPrefs.get(getProfile()) .setBoolean(Pref.SEARCH_SUGGEST_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(); + } 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(); } return true; } @@ -287,6 +301,16 @@ public class PrivacySettings UserPrefs.get(getProfile()).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( diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc --- a/chrome/browser/flags/android/chrome_feature_list.cc +++ b/chrome/browser/flags/android/chrome_feature_list.cc @@ -592,8 +592,8 @@ BASE_FEATURE(kCCTIncognitoAvailableToThirdParty, base::FEATURE_ENABLED_BY_DEFAULT); // in Bromite BASE_FEATURE(kCCTIntentFeatureOverrides, - "CCTIntentFeatureOverrides", - base::FEATURE_ENABLED_BY_DEFAULT); + "CCTIntentFeatureOverrides", // must be disabled + base::FEATURE_DISABLED_BY_DEFAULT); // in Bromite BASE_FEATURE(kCCTMinimized, "CCTMinimized", base::FEATURE_DISABLED_BY_DEFAULT); @@ -603,7 +603,7 @@ BASE_FEATURE(kCCTPageInsightsHub, BASE_FEATURE(kCCTPostMessageAPI, "CCTPostMessageAPI", - base::FEATURE_ENABLED_BY_DEFAULT); + base::FEATURE_DISABLED_BY_DEFAULT); BASE_FEATURE(kCCTPrefetchDelayShowOnStart, "CCTPrefetchDelayShowOnStart", diff --git a/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/TabAssociatedApp.java b/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/TabAssociatedApp.java --- a/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/TabAssociatedApp.java +++ b/chrome/browser/tab/java/src/org/chromium/chrome/browser/tab/TabAssociatedApp.java @@ -84,7 +84,11 @@ public final class TabAssociatedApp extends TabWebContentsUserData implements Im public static boolean isOpenedFromExternalApp(Tab tab) { TabAssociatedApp app = get(tab); if (app == null) return false; - + if (ContextUtils.getAppSharedPreferences() + .getBoolean("open_external_links_incognito", false) && + tab.isIncognito() && + tab.getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP) + return true; String packageName = ContextUtils.getApplicationContext().getPackageName(); return tab.getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP && !TextUtils.equals(app.getAppId(), packageName); 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 @@ -5238,6 +5238,20 @@ To change this setting, <resetlink>reset sync

Resume + + + Allow custom tab intents + + + Allow applications to open custom tab intents, similar to webview. + + + + Open external links in incognito + + + Force the opening of all external links in incognito mode + Show your Chrome activity in Digital Wellbeing? diff --git a/components/language/core/common/language_experiments.cc b/components/language/core/common/language_experiments.cc --- a/components/language/core/common/language_experiments.cc +++ b/components/language/core/common/language_experiments.cc @@ -18,8 +18,8 @@ BASE_FEATURE(kContentLanguagesInLanguagePicker, "ContentLanguagesInLanguagePicker", base::FEATURE_DISABLED_BY_DEFAULT); BASE_FEATURE(kCctAutoTranslate, - "CCTAutoTranslate", - base::FEATURE_ENABLED_BY_DEFAULT); + "CCTAutoTranslate", // Always disabled + base::FEATURE_DISABLED_BY_DEFAULT); // in Bromite // Params: const char kContentLanguagesDisableObserversParam[] = "disable_observers"; -- 2.25.1