Android build for ungoogled-chromium. https://uc.droidware.info
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

118 lines
6.3 KiB

From: csagan5 <[email protected]>
Date: Sat, 7 Sep 2019 15:07:42 +0200
Subject: Add option to not persist tabs across sessions
---
chrome/android/java/res/values/values.xml | 3 ++
chrome/android/java/res/xml/privacy_preferences.xml | 5 +++
chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java | 4 ++
chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java | 14 +++++++++-
chrome/browser/ui/android/strings/android_chrome_strings.grd | 6 ++++
5 files changed, 30 insertions(+), 2 deletions(-)
--- a/chrome/android/java/res/values/values.xml
+++ b/chrome/android/java/res/values/values.xml
@@ -57,6 +57,9 @@
<!-- TODO(peconn): Add help section. -->
<!-- <string name="help_context_suggestions">mobile_content_suggestions</string> -->
+ <string name="close_tabs_on_exit_title">Close tabs on exit</string>
+ <string name="close_tabs_on_exit_summary">Don\'t persist tabs between browsing sessions</string>
+
<!-- Our manage space activity. Default pre-KitKat to be nothing. -->
<string name="manage_space_activity"></string>
--- a/chrome/android/java/res/xml/privacy_preferences.xml
+++ b/chrome/android/java/res/xml/privacy_preferences.xml
@@ -19,6 +19,11 @@
android:key="usage_stats_reporting"
android:title="@string/usage_stats_setting_title"
android:persistent="false" />
+ <org.chromium.components.browser_ui.settings.ChromeBaseCheckBoxPreference
+ 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"
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
@@ -1092,8 +1092,10 @@ public class ChromeTabbedActivity
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);
if (noRestoreState) {
// Clear the state files because they are inconsistent and useless from now on.
mTabModelSelectorImpl.clearState();
--- 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
@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.privacy.settings;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
@@ -14,6 +15,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
+import org.chromium.base.ContextUtils;
import org.chromium.base.BuildInfo;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.help.HelpAndFeedback;
@@ -37,6 +39,7 @@ public class PrivacySettings
extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener {
private static final String PREF_CAN_MAKE_PAYMENT = "can_make_payment";
private static final String PREF_NETWORK_PREDICTIONS = "preload_pages";
+ private static final String PREF_CLOSE_TABS_ON_EXIT = "close_tabs_on_exit";
private static final String PREF_USAGE_STATS = "usage_stats_reporting";
private static final String PREF_DO_NOT_TRACK = "do_not_track";
private static final String PREF_SYNC_AND_SERVICES_LINK = "sync_and_services_link";
@@ -84,7 +87,11 @@ public class PrivacySettings
Pref.CAN_MAKE_PAYMENT_ENABLED, (boolean) newValue);
} else if (PREF_NETWORK_PREDICTIONS.equals(key)) {
PrivacyPreferencesManager.getInstance().setNetworkPredictionEnabled((boolean) newValue);
- }
+ } else 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();
+ }
return true;
}
@@ -132,6 +139,11 @@ public class PrivacySettings
} else {
getPreferenceScreen().removePreference(usageStatsPref);
}
+
+ ChromeBaseCheckBoxPreference closeTabsOnExitPref =
+ (ChromeBaseCheckBoxPreference) findPreference(PREF_CLOSE_TABS_ON_EXIT);
+ closeTabsOnExitPref.setOnPreferenceChangeListener(this);
+ closeTabsOnExitPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
}
}
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -3674,6 +3674,12 @@ Only you can see what your camera is loo
<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>