mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-10-01 01:35:54 -04:00
98 lines
4.7 KiB
Diff
98 lines
4.7 KiB
Diff
From e5a4d460e3683bb382b17e709a0b541d552c8247 Mon Sep 17 00:00:00 2001
|
|
From: Alexandre Oliveira <rockytvbr@gmail.com>
|
|
Date: Fri, 28 Jul 2017 18:05:18 -0300
|
|
Subject: [PATCH] Jelly: add option to remove identifying headers
|
|
|
|
Based off anthonycr's commit for LightningBrowser:
|
|
https://github.com/anthonycr/Lightning-Browser/commit/7a0c79d11ee1f0a19ebf61b37b8ebd53eee6eb57
|
|
|
|
Change-Id: If7c5978bd7ab5cdfd766585f2d2c479c4412e63f
|
|
---
|
|
app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java | 6 ++++++
|
|
app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java | 7 +++++++
|
|
app/src/main/res/values/strings.xml | 4 ++++
|
|
app/src/main/res/xml/settings.xml | 6 ++++++
|
|
4 files changed, 23 insertions(+)
|
|
|
|
diff --git a/app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java b/app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java
|
|
index 6b913d5..b554f30 100644
|
|
--- a/app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java
|
|
+++ b/app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java
|
|
@@ -32,6 +32,7 @@
|
|
private static final String KEY_DO_NOT_TRACK = "key_do_not_track";
|
|
private static final String KEY_SAVE_FORM_DATA = "key_save_form_data";
|
|
private static final String KEY_SUGGESTION_PROVIDER = "key_suggestion_provider";
|
|
+ private static final String KEY_REMOVE_IDENTIFYING_HEADERS = "key_remove_identifying_headers";
|
|
|
|
public enum SuggestionProviderType {
|
|
BAIDU,
|
|
@@ -91,6 +92,11 @@ public static boolean getSaveFormData(Context context) {
|
|
return prefs.getBoolean(KEY_SAVE_FORM_DATA, true);
|
|
}
|
|
|
|
+ public static boolean getRemoveIdentifyingHeaders(Context context) {
|
|
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
+ return prefs.getBoolean(KEY_REMOVE_IDENTIFYING_HEADERS, false);
|
|
+ }
|
|
+
|
|
public static SuggestionProviderType getSuggestionProvider(Context context) {
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
try {
|
|
diff --git a/app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java b/app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java
|
|
index bc88c22..ae96204 100644
|
|
--- a/app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java
|
|
+++ b/app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java
|
|
@@ -54,6 +54,8 @@
|
|
|
|
private final Map<String, String> mRequestHeaders = new ArrayMap<>();
|
|
private static final String HEADER_DNT = "DNT";
|
|
+ private static final String HEADER_REQUESTED_WITH = "X-Requested-With";
|
|
+ private static final String HEADER_WAP_PROFILE = "X-Wap-Profile";
|
|
|
|
public WebViewExt(Context context) {
|
|
super(context);
|
|
@@ -145,6 +147,11 @@ public boolean onLongClick(View v) {
|
|
if (PrefsUtils.getDoNotTrack(mActivity)) {
|
|
mRequestHeaders.put(HEADER_DNT, "1");
|
|
}
|
|
+
|
|
+ if (PrefsUtils.getRemoveIdentifyingHeaders(mActivity)) {
|
|
+ mRequestHeaders.put(HEADER_REQUESTED_WITH, "");
|
|
+ mRequestHeaders.put(HEADER_WAP_PROFILE, "");
|
|
+ }
|
|
}
|
|
|
|
public void init(WebViewExtActivity activity, EditText editText,
|
|
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
|
|
index 9784dc7..a325947 100644
|
|
--- a/app/src/main/res/values/strings.xml
|
|
+++ b/app/src/main/res/values/strings.xml
|
|
@@ -116,6 +116,10 @@
|
|
<string name="pref_save_form_data_title">Save form data</string>
|
|
<!-- Settings: suggestions provider title -->
|
|
<string name="pref_suggestions_provider">Suggestions provider</string>
|
|
+ <!-- Settings: remove identifying headers preference title -->
|
|
+ <string name="pref_remove_identifying_headers_title">Remove identifying headers</string>
|
|
+ <!-- Settings: remove identifying headers preference summary -->
|
|
+ <string name="pref_remove_identifying_headers_summary">Prevent some personally identifiable information from being sent to websites you visit</string>
|
|
|
|
<!-- History: title -->
|
|
<string name="history_title">History</string>
|
|
diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml
|
|
index 8bf0718..9bbf074 100644
|
|
--- a/app/src/main/res/xml/settings.xml
|
|
+++ b/app/src/main/res/xml/settings.xml
|
|
@@ -73,6 +73,12 @@
|
|
android:title="@string/pref_do_not_track_title" />
|
|
|
|
<SwitchPreference
|
|
+ android:defaultValue="0"
|
|
+ android:key="key_remove_identifying_headers"
|
|
+ android:summary="@string/pref_remove_identifying_headers_summary"
|
|
+ android:title="@string/pref_remove_identifying_headers_title" />
|
|
+
|
|
+ <SwitchPreference
|
|
android:defaultValue="1"
|
|
android:key="key_cookie"
|
|
android:summary="@string/pref_cookie_summary"
|