X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2FMainWebViewActivity.java;h=2af787eb8788138f75bd0765807b681448096112;hb=826776d415157b99701dd19d2713a60db6fefe2c;hp=d604a2e1f14bec7b4cb39094d8c0ae7203772ee1;hpb=59ce7ee862a672c569637f873af95e13b619906f;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java index d604a2e1..2af787eb 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java @@ -103,7 +103,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // It is also used in `onCreate()`, `onCreateOptionsMenu()`, `onPrepareOptionsMenu()`, and `onOptionsItemSelected()`. public static boolean firstPartyCookiesEnabled; - // `thridPartyCookiesEnables` is public static so it can be accessed from `SettingsFragment`. + // `thirdPartyCookiesEnables` is public static so it can be accessed from `SettingsFragment`. // It is also used in `onCreate()`, `onCreateOptionsMenu()`, `onPrepareOptionsMenu()`, and `onOptionsItemSelected()`. public static boolean thirdPartyCookiesEnabled; @@ -128,7 +128,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // `swipeToRefreshEnabled` is public static so it can be accessed from `SettingsFragment`. It is also used in `onCreate()`. public static boolean swipeToRefreshEnabled; - // `customHeader` is public static so it can be accessed from `BookmarksActivity`. It is also used in `onCreate()` and `loadUrlFromTextBox()`. + // `customHeader` is public static so it can be accessed from `BookmarksActivity`. It is also used in `onCreate()`, `onOptionsItemSelected()`, and `loadUrlFromTextBox()`. public static Map customHeaders = new HashMap(); @@ -222,9 +222,6 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // drawerToggle creates the hamburger icon at the start of the AppBar. drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, supportAppBar, R.string.open_navigation, R.string.close_navigation); - // Replace the header that `WebView` creates for `X-Requested-With` with a null value. The default value is the application ID (com.stoutner.privacybrowser.standard). - customHeaders.put("X-Requested-With", ""); - mainWebView.setWebViewClient(new WebViewClient() { // shouldOverrideUrlLoading makes this `WebView` the default handler for URLs inside the app, so that links are not kicked out to other apps. @Override @@ -452,6 +449,15 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation swipeToRefresh.setEnabled(swipeToRefreshEnabled); + // Replace the header that `WebView` creates for `X-Requested-With` with a null value. The default value is the application ID (com.stoutner.privacybrowser.standard). + customHeaders.put("X-Requested-With", ""); + + // Set Do Not Track. The default is true. + if (sharedPreferences.getBoolean("do_not_track", true)) { + customHeaders.put("DNT", "1"); + } + + // Get the intent information that started the app. final Intent intent = getIntent(); @@ -920,6 +926,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Clear `formattedUrlString`. formattedUrlString = null; + // Clear `customHeaders`. + customHeaders.clear(); + // Destroy the internal state of the webview. mainWebView.destroy();