forked from bromite/bromite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Force-open-external-links-in-incognito.patch
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
build/patches/Force-open-external-links-in-incognito.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
From: uazo <uazo@users.noreply.github.com> | ||
Date: Mon, 4 Oct 2021 11:48:18 +0000 | ||
Subject: Force open external links in incognito | ||
|
||
--- | ||
chrome/android/java/res/xml/privacy_preferences.xml | 5 +++++ | ||
.../chrome/browser/LaunchIntentDispatcher.java | 11 +++++++++++ | ||
.../ui/android/strings/android_chrome_strings.grd | 8 ++++++++ | ||
3 files changed, 24 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 | ||
@@ -57,6 +57,11 @@ | ||
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 | ||
@@ -427,6 +427,17 @@ public class LaunchIntentDispatcher implements IntentHandler.IntentHandlerDelega | ||
|
||
if (Intent.ACTION_VIEW.equals(newIntent.getAction()) | ||
&& !IntentHandler.wasIntentSenderChrome(newIntent)) { | ||
+ | ||
+ if (ContextUtils.getAppSharedPreferences().getBoolean( | ||
+ "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/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 | ||
@@ -4330,6 +4330,14 @@ To change this setting, <ph name="BEGIN_LINK"><resetlink></ph>reset sync<p | ||
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. --> | ||
<message name="IDS_PREFS_AUTOFILL_ASSISTANT_TITLE" desc="Title for the Autofill Assistant preferences screen. [CHAR_LIMIT=32]"> | ||
-- | ||
2.17.1 | ||
|