123 lines
6.9 KiB
Diff
123 lines
6.9 KiB
Diff
|
From: csagan5 <32685696+csagan5@users.noreply.github.com>
|
||
|
Date: Sat, 7 Sep 2019 15:07:42 +0200
|
||
|
Subject: Add option to not persist tabs across sessions
|
||
|
|
||
|
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
|
||
|
---
|
||
|
.../android/java/res/xml/privacy_preferences.xml | 5 +++++
|
||
|
.../chrome/browser/ChromeTabbedActivity.java | 5 ++++-
|
||
|
.../privacy/settings/PrivacySettings.java | 16 +++++++++++++++-
|
||
|
.../android/strings/android_chrome_strings.grd | 6 ++++++
|
||
|
4 files changed, 30 insertions(+), 2 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
|
||
|
@@ -61,6 +61,11 @@ found in the LICENSE file.
|
||
|
android:title="@string/incognito_settings_title"
|
||
|
android:summary="@string/incognito_settings_summary"
|
||
|
android:fragment="org.chromium.chrome.browser.privacy.settings.IncognitoSettings"/>
|
||
|
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||
|
+ android:key="close_tabs_on_exit"
|
||
|
+ android:title="@string/close_tabs_on_exit_title"
|
||
|
+ android:summary="@string/close_tabs_on_exit_summary"
|
||
|
+ android:defaultValue="false" />
|
||
|
<Preference
|
||
|
android:fragment="org.chromium.chrome.browser.privacy.settings.DoNotTrackSettings"
|
||
|
android:key="do_not_track"
|
||
|
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
|
||
|
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
|
||
|
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
|
||
|
@@ -40,6 +40,7 @@ import org.chromium.base.BuildInfo;
|
||
|
import org.chromium.base.Callback;
|
||
|
import org.chromium.base.CallbackController;
|
||
|
import org.chromium.base.CommandLine;
|
||
|
+import org.chromium.base.ContextUtils;
|
||
|
import org.chromium.base.IntentUtils;
|
||
|
import org.chromium.base.Log;
|
||
|
import org.chromium.base.MemoryPressureListener;
|
||
|
@@ -1307,8 +1308,10 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
|
||
|
boolean hadCipherData =
|
||
|
CipherFactory.getInstance().restoreFromBundle(getSavedInstanceState());
|
||
|
|
||
|
+ String PREF_CLOSE_TABS_ON_EXIT = "close_tabs_on_exit";
|
||
|
boolean noRestoreState =
|
||
|
- CommandLine.getInstance().hasSwitch(ChromeSwitches.NO_RESTORE_STATE);
|
||
|
+ CommandLine.getInstance().hasSwitch(ChromeSwitches.NO_RESTORE_STATE) ||
|
||
|
+ ContextUtils.getAppSharedPreferences().getBoolean(PREF_CLOSE_TABS_ON_EXIT, false);
|
||
|
boolean shouldShowHomeSurfaceAtStartupOnTablet = false;
|
||
|
final AtomicBoolean isActiveUrlNTP = new AtomicBoolean(false);
|
||
|
if (noRestoreState) {
|
||
|
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
|
||
|
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.privacy.settings;
|
||
|
import static org.chromium.components.content_settings.PrefNames.COOKIE_CONTROLS_MODE;
|
||
|
|
||
|
import android.os.Build;
|
||
|
+import android.content.SharedPreferences;
|
||
|
import android.os.Bundle;
|
||
|
import android.text.SpannableString;
|
||
|
import android.text.style.ForegroundColorSpan;
|
||
|
@@ -20,6 +21,8 @@ import androidx.preference.Preference;
|
||
|
|
||
|
import org.chromium.base.metrics.RecordHistogram;
|
||
|
import org.chromium.base.metrics.RecordUserAction;
|
||
|
+import org.chromium.base.ContextUtils;
|
||
|
+import org.chromium.base.BuildInfo;
|
||
|
import org.chromium.chrome.R;
|
||
|
import org.chromium.chrome.browser.enterprise.util.ManagedBrowserUtils;
|
||
|
import org.chromium.chrome.browser.flags.ChromeFeatureList;
|
||
|
@@ -88,6 +91,8 @@ public class PrivacySettings
|
||
|
private final SharedPreferencesManager mSharedPreferencesManager =
|
||
|
SharedPreferencesManager.getInstance();
|
||
|
|
||
|
+ private static final String PREF_CLOSE_TABS_ON_EXIT = "close_tabs_on_exit";
|
||
|
+
|
||
|
private ManagedPreferenceDelegate mManagedPreferenceDelegate;
|
||
|
private IncognitoLockSettings mIncognitoLockSettings;
|
||
|
|
||
|
@@ -244,7 +249,11 @@ public class PrivacySettings
|
||
|
@Override
|
||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||
|
String key = preference.getKey();
|
||
|
- if (PREF_CAN_MAKE_PAYMENT.equals(key)) {
|
||
|
+ if (PREF_CLOSE_TABS_ON_EXIT.equals(key)) {
|
||
|
+ SharedPreferences.Editor sharedPreferencesEditor = ContextUtils.getAppSharedPreferences().edit();
|
||
|
+ sharedPreferencesEditor.putBoolean(PREF_CLOSE_TABS_ON_EXIT, (boolean)newValue);
|
||
|
+ sharedPreferencesEditor.apply();
|
||
|
+ } else if (PREF_CAN_MAKE_PAYMENT.equals(key)) {
|
||
|
UserPrefs.get(getProfile())
|
||
|
.setBoolean(Pref.CAN_MAKE_PAYMENT_ENABLED, (boolean) newValue);
|
||
|
} else if (PREF_HTTPS_FIRST_MODE.equals(key)) {
|
||
|
@@ -291,6 +300,11 @@ public class PrivacySettings
|
||
|
PreloadPagesSettingsFragment.getPreloadPagesSummaryString(getContext()));
|
||
|
}
|
||
|
|
||
|
+ ChromeSwitchPreference closeTabsOnExitPref =
|
||
|
+ (ChromeSwitchPreference) findPreference(PREF_CLOSE_TABS_ON_EXIT);
|
||
|
+ closeTabsOnExitPref.setOnPreferenceChangeListener(this);
|
||
|
+ closeTabsOnExitPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
|
||
|
+
|
||
|
Preference secureDnsPref = findPreference(PREF_SECURE_DNS);
|
||
|
if (secureDnsPref != null && secureDnsPref.isVisible()) {
|
||
|
secureDnsPref.setSummary(SecureDnsSettings.getSummary(getContext()));
|
||
|
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
|
||
|
@@ -4876,6 +4876,12 @@ To change this setting, <ph name="BEGIN_LINK"><resetlink></ph>reset sync<p
|
||
|
<message name="IDS_CONTEXTMENU_IMAGE_TITLE" desc="The title of a context menu tab when the item pressed contains more than one type. This indicates that all the actions are related to the image.">
|
||
|
IMAGE
|
||
|
</message>
|
||
|
+ <message name="IDS_CLOSE_TABS_ON_EXIT_TITLE" desc="Text for 'Close tabs on exit' settings-privacy option.">
|
||
|
+ Close all open tabs on exit
|
||
|
+ </message>
|
||
|
+ <message name="IDS_CLOSE_TABS_ON_EXIT_SUMMARY" desc="Summary text for 'Close tabs on exit' settings-privacy option.">
|
||
|
+ Don't persist tabs between browsing sessions
|
||
|
+ </message>
|
||
|
<message name="IDS_CONTEXTMENU_LINK_TITLE" desc="The title of a context menu tab when the item pressed contains more than one type. This indicates that all the actions are related to the link.">
|
||
|
LINK
|
||
|
</message>
|
||
|
--
|
||
|
2.25.1
|