Add support to remove identifying headers, add support for DNT header requests
This commit is contained in:
parent
4e3193bfc8
commit
7a0c79d11e
@ -528,7 +528,10 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
boolean checked = (Boolean) newValue;
|
boolean checked = false;
|
||||||
|
if (newValue instanceof Boolean) {
|
||||||
|
checked = (Boolean) newValue;
|
||||||
|
}
|
||||||
switch (preference.getKey()) {
|
switch (preference.getKey()) {
|
||||||
case SETTINGS_FLASH:
|
case SETTINGS_FLASH:
|
||||||
if (!Utils.isFlashInstalled(mActivity) && checked) {
|
if (!Utils.isFlashInstalled(mActivity) && checked) {
|
||||||
|
@ -17,6 +17,7 @@ import android.webkit.WebView;
|
|||||||
import acr.browser.lightning.R;
|
import acr.browser.lightning.R;
|
||||||
import acr.browser.lightning.utils.Utils;
|
import acr.browser.lightning.utils.Utils;
|
||||||
import acr.browser.lightning.utils.WebUtils;
|
import acr.browser.lightning.utils.WebUtils;
|
||||||
|
import acr.browser.lightning.view.LightningView;
|
||||||
|
|
||||||
public class PrivacySettingsFragment extends LightningPreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
public class PrivacySettingsFragment extends LightningPreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
@ -31,10 +32,10 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
|||||||
private static final String SETTINGS_CLEARCOOKIES = "clear_cookies";
|
private static final String SETTINGS_CLEARCOOKIES = "clear_cookies";
|
||||||
private static final String SETTINGS_CLEARWEBSTORAGE = "clear_webstorage";
|
private static final String SETTINGS_CLEARWEBSTORAGE = "clear_webstorage";
|
||||||
private static final String SETTINGS_WEBSTORAGEEXIT = "clear_webstorage_exit";
|
private static final String SETTINGS_WEBSTORAGEEXIT = "clear_webstorage_exit";
|
||||||
|
private static final String SETTINGS_DONOTTRACK = "do_not_track";
|
||||||
|
private static final String SETTINGS_INVASIVEHEADERS = "remove_identifying_headers";
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private CheckBoxPreference cblocation, cb3cookies, cbsavepasswords, cbcacheexit, cbhistoryexit,
|
|
||||||
cbcookiesexit, cbwebstorageexit;
|
|
||||||
private Handler messageHandler;
|
private Handler messageHandler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,13 +55,15 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
|||||||
Preference clearcookies = findPreference(SETTINGS_CLEARCOOKIES);
|
Preference clearcookies = findPreference(SETTINGS_CLEARCOOKIES);
|
||||||
Preference clearwebstorage = findPreference(SETTINGS_CLEARWEBSTORAGE);
|
Preference clearwebstorage = findPreference(SETTINGS_CLEARWEBSTORAGE);
|
||||||
|
|
||||||
cblocation = (CheckBoxPreference) findPreference(SETTINGS_LOCATION);
|
CheckBoxPreference cblocation = (CheckBoxPreference) findPreference(SETTINGS_LOCATION);
|
||||||
cb3cookies = (CheckBoxPreference) findPreference(SETTINGS_THIRDPCOOKIES);
|
CheckBoxPreference cb3cookies = (CheckBoxPreference) findPreference(SETTINGS_THIRDPCOOKIES);
|
||||||
cbsavepasswords = (CheckBoxPreference) findPreference(SETTINGS_SAVEPASSWORD);
|
CheckBoxPreference cbsavepasswords = (CheckBoxPreference) findPreference(SETTINGS_SAVEPASSWORD);
|
||||||
cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT);
|
CheckBoxPreference cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT);
|
||||||
cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT);
|
CheckBoxPreference cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT);
|
||||||
cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT);
|
CheckBoxPreference cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT);
|
||||||
cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT);
|
CheckBoxPreference cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT);
|
||||||
|
CheckBoxPreference cbDoNotTrack = (CheckBoxPreference) findPreference(SETTINGS_DONOTTRACK);
|
||||||
|
CheckBoxPreference cbIdentifyingHeaders = (CheckBoxPreference) findPreference(SETTINGS_INVASIVEHEADERS);
|
||||||
|
|
||||||
clearcache.setOnPreferenceClickListener(this);
|
clearcache.setOnPreferenceClickListener(this);
|
||||||
clearhistory.setOnPreferenceClickListener(this);
|
clearhistory.setOnPreferenceClickListener(this);
|
||||||
@ -74,6 +77,8 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
|||||||
cbhistoryexit.setOnPreferenceChangeListener(this);
|
cbhistoryexit.setOnPreferenceChangeListener(this);
|
||||||
cbcookiesexit.setOnPreferenceChangeListener(this);
|
cbcookiesexit.setOnPreferenceChangeListener(this);
|
||||||
cbwebstorageexit.setOnPreferenceChangeListener(this);
|
cbwebstorageexit.setOnPreferenceChangeListener(this);
|
||||||
|
cbDoNotTrack.setOnPreferenceChangeListener(this);
|
||||||
|
cbIdentifyingHeaders.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
cblocation.setChecked(mPreferenceManager.getLocationEnabled());
|
cblocation.setChecked(mPreferenceManager.getLocationEnabled());
|
||||||
cbsavepasswords.setChecked(mPreferenceManager.getSavePasswordsEnabled());
|
cbsavepasswords.setChecked(mPreferenceManager.getSavePasswordsEnabled());
|
||||||
@ -82,6 +87,11 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
|||||||
cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled());
|
cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled());
|
||||||
cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled());
|
cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled());
|
||||||
cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled());
|
cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled());
|
||||||
|
cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled());
|
||||||
|
cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled());
|
||||||
|
|
||||||
|
String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE;
|
||||||
|
cbIdentifyingHeaders.setSummary(identifyingHeadersSummary);
|
||||||
|
|
||||||
cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
|
cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
|
||||||
|
|
||||||
@ -194,35 +204,33 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
// switch preferences
|
|
||||||
switch (preference.getKey()) {
|
switch (preference.getKey()) {
|
||||||
case SETTINGS_LOCATION:
|
case SETTINGS_LOCATION:
|
||||||
mPreferenceManager.setLocationEnabled((Boolean) newValue);
|
mPreferenceManager.setLocationEnabled((Boolean) newValue);
|
||||||
cblocation.setChecked((Boolean) newValue);
|
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS_THIRDPCOOKIES:
|
case SETTINGS_THIRDPCOOKIES:
|
||||||
mPreferenceManager.setBlockThirdPartyCookiesEnabled((Boolean) newValue);
|
mPreferenceManager.setBlockThirdPartyCookiesEnabled((Boolean) newValue);
|
||||||
cb3cookies.setChecked((Boolean) newValue);
|
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS_SAVEPASSWORD:
|
case SETTINGS_SAVEPASSWORD:
|
||||||
mPreferenceManager.setSavePasswordsEnabled((Boolean) newValue);
|
mPreferenceManager.setSavePasswordsEnabled((Boolean) newValue);
|
||||||
cbsavepasswords.setChecked((Boolean) newValue);
|
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS_CACHEEXIT:
|
case SETTINGS_CACHEEXIT:
|
||||||
mPreferenceManager.setClearCacheExit((Boolean) newValue);
|
mPreferenceManager.setClearCacheExit((Boolean) newValue);
|
||||||
cbcacheexit.setChecked((Boolean) newValue);
|
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS_HISTORYEXIT:
|
case SETTINGS_HISTORYEXIT:
|
||||||
mPreferenceManager.setClearHistoryExitEnabled((Boolean) newValue);
|
mPreferenceManager.setClearHistoryExitEnabled((Boolean) newValue);
|
||||||
cbhistoryexit.setChecked((Boolean) newValue);
|
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS_COOKIEEXIT:
|
case SETTINGS_COOKIEEXIT:
|
||||||
mPreferenceManager.setClearCookiesExitEnabled((Boolean) newValue);
|
mPreferenceManager.setClearCookiesExitEnabled((Boolean) newValue);
|
||||||
cbcookiesexit.setChecked((Boolean) newValue);
|
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS_WEBSTORAGEEXIT:
|
case SETTINGS_WEBSTORAGEEXIT:
|
||||||
mPreferenceManager.setClearWebStorageExitEnabled((Boolean) newValue);
|
mPreferenceManager.setClearWebStorageExitEnabled((Boolean) newValue);
|
||||||
cbwebstorageexit.setChecked((Boolean) newValue);
|
return true;
|
||||||
|
case SETTINGS_DONOTTRACK:
|
||||||
|
mPreferenceManager.setDoNotTrackEnabled((Boolean) newValue);
|
||||||
|
return true;
|
||||||
|
case SETTINGS_INVASIVEHEADERS:
|
||||||
|
mPreferenceManager.setRemoveIdentifyingHeadersEnabled((Boolean) newValue);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -51,6 +51,8 @@ public class PreferenceManager {
|
|||||||
public static final String TEXT_ENCODING = "textEncoding";
|
public static final String TEXT_ENCODING = "textEncoding";
|
||||||
public static final String CLEAR_WEBSTORAGE_EXIT = "clearWebStorageExit";
|
public static final String CLEAR_WEBSTORAGE_EXIT = "clearWebStorageExit";
|
||||||
public static final String SHOW_TABS_IN_DRAWER = "showTabsInDrawer";
|
public static final String SHOW_TABS_IN_DRAWER = "showTabsInDrawer";
|
||||||
|
public static final String DO_NOT_TRACK = "doNotTrack";
|
||||||
|
public static final String INVASIVE_HEADERS = "removeInvasiveHeaders";
|
||||||
|
|
||||||
public static final String USE_PROXY = "useProxy";
|
public static final String USE_PROXY = "useProxy";
|
||||||
public static final String PROXY_CHOICE = "proxyChoice";
|
public static final String PROXY_CHOICE = "proxyChoice";
|
||||||
@ -245,6 +247,14 @@ public class PreferenceManager {
|
|||||||
return mPrefs.getBoolean(Name.SHOW_TABS_IN_DRAWER, defaultValue);
|
return mPrefs.getBoolean(Name.SHOW_TABS_IN_DRAWER, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getDoNotTrackEnabled() {
|
||||||
|
return mPrefs.getBoolean(Name.DO_NOT_TRACK, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getRemoveIdentifyingHeadersEnabled(){
|
||||||
|
return mPrefs.getBoolean(Name.INVASIVE_HEADERS, false);
|
||||||
|
}
|
||||||
|
|
||||||
private void putBoolean(String name, boolean value) {
|
private void putBoolean(String name, boolean value) {
|
||||||
mPrefs.edit().putBoolean(name, value).apply();
|
mPrefs.edit().putBoolean(name, value).apply();
|
||||||
}
|
}
|
||||||
@ -257,6 +267,14 @@ public class PreferenceManager {
|
|||||||
mPrefs.edit().putString(name, value).apply();
|
mPrefs.edit().putString(name, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRemoveIdentifyingHeadersEnabled(boolean enabled){
|
||||||
|
putBoolean(Name.INVASIVE_HEADERS, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDoNotTrackEnabled(boolean doNotTrack) {
|
||||||
|
putBoolean(Name.DO_NOT_TRACK, doNotTrack);
|
||||||
|
}
|
||||||
|
|
||||||
public void setShowTabsInDrawer(boolean show) {
|
public void setShowTabsInDrawer(boolean show) {
|
||||||
putBoolean(Name.SHOW_TABS_IN_DRAWER, show);
|
putBoolean(Name.SHOW_TABS_IN_DRAWER, show);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||||
@ -37,6 +38,7 @@ import java.io.File;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -58,6 +60,10 @@ import acr.browser.lightning.utils.Utils;
|
|||||||
|
|
||||||
public class LightningView {
|
public class LightningView {
|
||||||
|
|
||||||
|
public static final String HEADER_REQUESTED_WITH = "X-Requested-With";
|
||||||
|
public static final String HEADER_WAP_PROFILE = "X-Wap-Profile";
|
||||||
|
public static final String HEADER_DNT = "DNT";
|
||||||
|
|
||||||
final LightningViewTitle mTitle;
|
final LightningViewTitle mTitle;
|
||||||
private WebView mWebView;
|
private WebView mWebView;
|
||||||
final boolean mIsIncognitoTab;
|
final boolean mIsIncognitoTab;
|
||||||
@ -80,6 +86,7 @@ public class LightningView {
|
|||||||
0, 0, 0, 1.0f, 0 // alpha
|
0, 0, 0, 1.0f, 0 // alpha
|
||||||
};
|
};
|
||||||
private final WebViewHandler mWebViewHandler = new WebViewHandler(this);
|
private final WebViewHandler mWebViewHandler = new WebViewHandler(this);
|
||||||
|
private final Map<String, String> mRequestHeaders = new ArrayMap<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Bus mEventBus;
|
Bus mEventBus;
|
||||||
@ -128,7 +135,7 @@ public class LightningView {
|
|||||||
|
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
if (!url.trim().isEmpty()) {
|
if (!url.trim().isEmpty()) {
|
||||||
mWebView.loadUrl(url);
|
mWebView.loadUrl(url, mRequestHeaders);
|
||||||
} else {
|
} else {
|
||||||
// don't load anything, the user is looking for a blank tab
|
// don't load anything, the user is looking for a blank tab
|
||||||
}
|
}
|
||||||
@ -142,11 +149,11 @@ public class LightningView {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mHomepage.startsWith("about:home")) {
|
if (mHomepage.startsWith("about:home")) {
|
||||||
mWebView.loadUrl(StartPage.getHomepage(mActivity));
|
mWebView.loadUrl(StartPage.getHomepage(mActivity), mRequestHeaders);
|
||||||
} else if (mHomepage.startsWith("about:bookmarks")) {
|
} else if (mHomepage.startsWith("about:bookmarks")) {
|
||||||
loadBookmarkpage();
|
loadBookmarkpage();
|
||||||
} else {
|
} else {
|
||||||
mWebView.loadUrl(mHomepage);
|
mWebView.loadUrl(mHomepage, mRequestHeaders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +178,7 @@ public class LightningView {
|
|||||||
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
|
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
|
||||||
|
|
||||||
BrowserApp.getAppComponent().getBookmarkPage().buildBookmarkPage(null);
|
BrowserApp.getAppComponent().getBookmarkPage().buildBookmarkPage(null);
|
||||||
mWebView.loadUrl(Constants.FILE + bookmarkWebPage);
|
mWebView.loadUrl(Constants.FILE + bookmarkWebPage, mRequestHeaders);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +189,7 @@ public class LightningView {
|
|||||||
* if you don't have a reference to them
|
* if you don't have a reference to them
|
||||||
* @param context the context in which the WebView was created
|
* @param context the context in which the WebView was created
|
||||||
*/
|
*/
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
|
||||||
public synchronized void initializePreferences(@Nullable WebSettings settings, Context context) {
|
public synchronized void initializePreferences(@Nullable WebSettings settings, Context context) {
|
||||||
if (settings == null && mWebView == null) {
|
if (settings == null && mWebView == null) {
|
||||||
return;
|
return;
|
||||||
@ -190,6 +197,17 @@ public class LightningView {
|
|||||||
settings = mWebView.getSettings();
|
settings = mWebView.getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mPreferences.getDoNotTrackEnabled()) {
|
||||||
|
mRequestHeaders.put(HEADER_DNT, "1");
|
||||||
|
} else {
|
||||||
|
mRequestHeaders.remove(HEADER_DNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mPreferences.getRemoveIdentifyingHeadersEnabled()) {
|
||||||
|
mRequestHeaders.put(HEADER_REQUESTED_WITH, "");
|
||||||
|
mRequestHeaders.put(HEADER_WAP_PROFILE, "");
|
||||||
|
}
|
||||||
|
|
||||||
settings.setDefaultTextEncodingName(mPreferences.getTextEncoding());
|
settings.setDefaultTextEncodingName(mPreferences.getTextEncoding());
|
||||||
mHomepage = mPreferences.getHomepage();
|
mHomepage = mPreferences.getHomepage();
|
||||||
setColorMode(mPreferences.getRenderingMode());
|
setColorMode(mPreferences.getRenderingMode());
|
||||||
@ -384,6 +402,11 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
protected Map<String, String> getRequestHeaders() {
|
||||||
|
return mRequestHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isShown() {
|
public boolean isShown() {
|
||||||
return mWebView != null && mWebView.isShown();
|
return mWebView != null && mWebView.isShown();
|
||||||
}
|
}
|
||||||
@ -679,7 +702,7 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
mWebView.loadUrl(url);
|
mWebView.loadUrl(url, mRequestHeaders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,7 +807,7 @@ public class LightningView {
|
|||||||
|
|
||||||
private static class WebViewHandler extends Handler {
|
private static class WebViewHandler extends Handler {
|
||||||
|
|
||||||
private WeakReference<LightningView> mReference;
|
private final WeakReference<LightningView> mReference;
|
||||||
|
|
||||||
public WebViewHandler(LightningView view) {
|
public WebViewHandler(LightningView view) {
|
||||||
mReference = new WeakReference<>(view);
|
mReference = new WeakReference<>(view);
|
||||||
|
@ -30,6 +30,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import acr.browser.lightning.R;
|
import acr.browser.lightning.R;
|
||||||
import acr.browser.lightning.app.BrowserApp;
|
import acr.browser.lightning.app.BrowserApp;
|
||||||
@ -41,12 +42,9 @@ import acr.browser.lightning.utils.IntentUtils;
|
|||||||
import acr.browser.lightning.utils.ProxyUtils;
|
import acr.browser.lightning.utils.ProxyUtils;
|
||||||
import acr.browser.lightning.utils.Utils;
|
import acr.browser.lightning.utils.Utils;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stefano Pacifici based on Anthony C. Restaino's code
|
|
||||||
* @date 2015/09/22
|
|
||||||
*/
|
|
||||||
class LightningWebClient extends WebViewClient {
|
class LightningWebClient extends WebViewClient {
|
||||||
|
|
||||||
|
|
||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
private final LightningView mLightningView;
|
private final LightningView mLightningView;
|
||||||
private final UIController mUIController;
|
private final UIController mUIController;
|
||||||
@ -152,7 +150,6 @@ class LightningWebClient extends WebViewClient {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
handler.cancel();
|
handler.cancel();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
@ -275,13 +272,17 @@ class LightningWebClient extends WebViewClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, String> headers = mLightningView.getRequestHeaders();
|
||||||
|
|
||||||
if (mLightningView.mIsIncognitoTab) {
|
if (mLightningView.mIsIncognitoTab) {
|
||||||
return super.shouldOverrideUrlLoading(view, url);
|
view.loadUrl(url, headers);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (url.startsWith("about:")) {
|
if (url.startsWith("about:")) {
|
||||||
return super.shouldOverrideUrlLoading(view, url);
|
view.loadUrl(url, headers);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (url.contains("mailto:")) {
|
if (url.startsWith("mailto:")) {
|
||||||
MailTo mailTo = MailTo.parse(url);
|
MailTo mailTo = MailTo.parse(url);
|
||||||
Intent i = Utils.newEmailIntent(mailTo.getTo(), mailTo.getSubject(),
|
Intent i = Utils.newEmailIntent(mailTo.getTo(), mailTo.getSubject(),
|
||||||
mailTo.getBody(), mailTo.getCc());
|
mailTo.getBody(), mailTo.getCc());
|
||||||
@ -292,8 +293,8 @@ class LightningWebClient extends WebViewClient {
|
|||||||
Intent intent;
|
Intent intent;
|
||||||
try {
|
try {
|
||||||
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
|
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException ignored) {
|
||||||
return false;
|
intent = null;
|
||||||
}
|
}
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
@ -309,6 +310,10 @@ class LightningWebClient extends WebViewClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mIntentUtils.startActivityForUrl(view, url);
|
|
||||||
|
if (!mIntentUtils.startActivityForUrl(view, url)) {
|
||||||
|
view.loadUrl(url, headers);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,4 +224,6 @@
|
|||||||
<string name="hosts_source">Hosts File Ad Blocking Source</string>
|
<string name="hosts_source">Hosts File Ad Blocking Source</string>
|
||||||
<string name="settings_adblock">Ad Block Settings</string>
|
<string name="settings_adblock">Ad Block Settings</string>
|
||||||
<string name="tabs_in_drawer">Show tabs in Navigation Drawer</string>
|
<string name="tabs_in_drawer">Show tabs in Navigation Drawer</string>
|
||||||
|
<string name="do_not_track">Request \'Do Not Track\'</string>
|
||||||
|
<string name="remove_identifying_headers">Remove Identifying Headers</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -5,43 +5,51 @@
|
|||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="location"
|
android:key="location"
|
||||||
android:title="@string/location" />
|
android:title="@string/location"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="third_party"
|
android:key="third_party"
|
||||||
android:title="@string/third_party" />
|
android:title="@string/third_party"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="password"
|
android:key="password"
|
||||||
android:summary="@string/recommended"
|
android:summary="@string/recommended"
|
||||||
android:title="@string/password" />
|
android:title="@string/password"/>
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="do_not_track"
|
||||||
|
android:title="@string/do_not_track"/>
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="remove_identifying_headers"
|
||||||
|
android:title="@string/remove_identifying_headers"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="clear_cache_exit"
|
android:key="clear_cache_exit"
|
||||||
android:title="@string/cache" />
|
android:title="@string/cache"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="clear_history_exit"
|
android:key="clear_history_exit"
|
||||||
android:title="@string/clear_history_exit" />
|
android:title="@string/clear_history_exit"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="clear_cookies_exit"
|
android:key="clear_cookies_exit"
|
||||||
android:title="@string/clear_cookies_exit" />
|
android:title="@string/clear_cookies_exit"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="clear_webstorage_exit"
|
android:key="clear_webstorage_exit"
|
||||||
android:title="@string/clear_web_storage_exit" />
|
android:title="@string/clear_web_storage_exit"/>
|
||||||
<Preference
|
<Preference
|
||||||
android:key="clear_cache"
|
android:key="clear_cache"
|
||||||
android:title="@string/clear_cache" />
|
android:title="@string/clear_cache"/>
|
||||||
<Preference
|
<Preference
|
||||||
android:key="clear_history"
|
android:key="clear_history"
|
||||||
android:title="@string/title_clear_history" />
|
android:title="@string/title_clear_history"/>
|
||||||
<Preference
|
<Preference
|
||||||
android:key="clear_cookies"
|
android:key="clear_cookies"
|
||||||
android:title="@string/clear_cookies" />
|
android:title="@string/clear_cookies"/>
|
||||||
<Preference
|
<Preference
|
||||||
android:key="clear_webstorage"
|
android:key="clear_webstorage"
|
||||||
android:title="@string/clear_web_storage" />
|
android:title="@string/clear_web_storage"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user