From 826776d415157b99701dd19d2713a60db6fefe2c Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Mon, 5 Sep 2016 19:30:31 -0700 Subject: [PATCH] Add a DNT option and turn it on by default. Fixes https://redmine.stoutner.com/issues/30 --- .../main/assets/de/guide_local_storage.html | 14 ++++-- .../assets/de/images/cookie_dark_blue.png | 1 + .../de/images/ic_subtitles_dark_blue.png | 1 + .../assets/de/images/ic_web_dark_blue.png | 1 + .../main/assets/en/guide_local_storage.html | 24 +++++---- .../main/assets/en/guide_tracking_ids.html | 12 ++++- .../assets/en/images/cookie_dark_blue.png | Bin 0 -> 3625 bytes .../en/images/ic_subtitles_dark_blue.png | Bin 0 -> 1079 bytes .../assets/en/images/ic_web_dark_blue.png | Bin 0 -> 1097 bytes .../privacybrowser/MainWebViewActivity.java | 19 +++++-- .../privacybrowser/SettingsFragment.java | 47 ++++++++++-------- app/src/main/res/values/strings.xml | 2 + app/src/main/res/xml/preferences.xml | 6 +++ 13 files changed, 86 insertions(+), 41 deletions(-) create mode 120000 app/src/main/assets/de/images/cookie_dark_blue.png create mode 120000 app/src/main/assets/de/images/ic_subtitles_dark_blue.png create mode 120000 app/src/main/assets/de/images/ic_web_dark_blue.png create mode 100644 app/src/main/assets/en/images/cookie_dark_blue.png create mode 100644 app/src/main/assets/en/images/ic_subtitles_dark_blue.png create mode 100644 app/src/main/assets/en/images/ic_web_dark_blue.png diff --git a/app/src/main/assets/de/guide_local_storage.html b/app/src/main/assets/de/guide_local_storage.html index 8aea5734..d3c2a84b 100644 --- a/app/src/main/assets/de/guide_local_storage.html +++ b/app/src/main/assets/de/guide_local_storage.html @@ -27,11 +27,17 @@ h3 { color: 0D4781; } + + img { + vertical-align: bottom; + height: 32; + width: 32; + } -

Erstanbieter-Cookies

+

Erstanbieter-Cookies

Cookies können in zwei Typen unterteilt werden. Erstanbieter-Cookies sind Cookies, die von aktuell besuchten Website gesetzt werden.

@@ -54,7 +60,7 @@ als Warnung.

-

Drittanbieter-Cookies

+

Drittanbieter-Cookies

Drittanbieter-Cookies werden von Teilen einer Website gesetzt, die von einem anderen Server als dem aktuell besuchten. Beispielsweise laden viele Websites Werbungen von einem Drittanbieter-Broker wie Googles @@ -82,14 +88,14 @@ Deshalb aktiviert das Aktivieren von Erstanbieter-Cookies zugleich auch Drittanbieter-Cookies.

-

DOM-Speicher

+

DOM-Speicher

Der Document Object Model-Speicher, auch bekannt als Web-Speicher, ist wie Cookies auf Steroiden. Während die maximale Gesamtspeichergrße für alle Cookies von einer einzigen URL 4kb beträgt, kann der DOM-Speicher zwischen 5-25 Megabytes pro Seite betragen. Da der DOM-Speicher Javascript zum Lesen und Schreiben von Daten nutzt, ändert das Aktivieren also nichts, solange nicht auch Javascript aktiviert ist.

-

Formulardaten

+

Formulardaten

Formulardaten beinhalten die Informationen, die in Web-Formularen eingegeben werden, wie Benutzernamen, Adressen, Telefonnummern etc. und listet sie als Auswahlmenü auf künftig besuchten Websites auf. Ungleich der anderen Arten der lokalen Datenspeicherung werden Formulardaten nicht ohne die explizite Handlung des Nutzers an den Webserver gesendet.

diff --git a/app/src/main/assets/de/images/cookie_dark_blue.png b/app/src/main/assets/de/images/cookie_dark_blue.png new file mode 120000 index 00000000..d8473698 --- /dev/null +++ b/app/src/main/assets/de/images/cookie_dark_blue.png @@ -0,0 +1 @@ +../../en/images/cookie_dark_blue.png \ No newline at end of file diff --git a/app/src/main/assets/de/images/ic_subtitles_dark_blue.png b/app/src/main/assets/de/images/ic_subtitles_dark_blue.png new file mode 120000 index 00000000..6bccc980 --- /dev/null +++ b/app/src/main/assets/de/images/ic_subtitles_dark_blue.png @@ -0,0 +1 @@ +../../en/images/ic_subtitles_dark_blue.png \ No newline at end of file diff --git a/app/src/main/assets/de/images/ic_web_dark_blue.png b/app/src/main/assets/de/images/ic_web_dark_blue.png new file mode 120000 index 00000000..ddc6eef3 --- /dev/null +++ b/app/src/main/assets/de/images/ic_web_dark_blue.png @@ -0,0 +1 @@ +../../en/images/ic_web_dark_blue.png \ No newline at end of file diff --git a/app/src/main/assets/en/guide_local_storage.html b/app/src/main/assets/en/guide_local_storage.html index ae110a6b..c0eeaaee 100644 --- a/app/src/main/assets/en/guide_local_storage.html +++ b/app/src/main/assets/en/guide_local_storage.html @@ -18,15 +18,21 @@ - + -

First-Party Cookies

+

First-Party Cookies

Cookies can be divided into two types. First-party cookies are cookies set by the website in the URL bar at the top of the page.

@@ -49,7 +55,7 @@ as a warning.

-

Third-Party Cookies

+

Third-Party Cookies

Third-party cookies are set by portions of a website that are loaded from servers different from the URL at the top of the page. For example, most website that have advertisements load them from a third-party ad broker, like Google's @@ -78,14 +84,14 @@ between first-party and third-party cookies. Thus, enabling first-party cookies will also enable third-party cookies.

-

DOM Storage

+

DOM Storage

Document Object Model storage, also known as web storage, is like cookies on steroids. Whereas the maximum combined storage size for all cookies from a single URL is 4 kilobytes, DOM storage can hold between 5-25 megabytes per site. Because DOM storage uses JavaScript to read and write data, enabling it will do nothing unless JavaScript is also enabled.

-

Form Data

+

Form Data

Form data contains information typed into web forms, like user names, addresses, phone numbers, etc., and lists them in a drop-down box on future visits. Unlike the other forms of local storage, form data is not sent to the web server without specific user interaction.

diff --git a/app/src/main/assets/en/guide_tracking_ids.html b/app/src/main/assets/en/guide_tracking_ids.html index 14bed944..77813ade 100644 --- a/app/src/main/assets/en/guide_tracking_ids.html +++ b/app/src/main/assets/en/guide_tracking_ids.html @@ -32,6 +32,17 @@ +

Do Not Track

+ +

A few years ago the W3C (World Wide Web Consortium) created a mechanism for browsers to inform web servers that they would not like to be tracked. + This is accomplished by including a DNT (Do Not Track) header with web requests. + This header is enabled by default in Privacy Browser, although if desired it can be disabled in the settings.

+ +

The DNT header doesn't really provide much privacy because most web servers ignore it. Yahoo programmed their servers to ignore the DNT header + from Internet Explorer 10 when it was turned on by default because they argued that the user had not made the decision to enable DNT. + Google and Microsoft ignore DNT even though they include a DNT feature in the browsers they distribute. Facebook also ignores DNT.

+ +

Advertisements

Privacy Browser Free includes a banner advertisement across the bottom of the screen that is populated by Google's @@ -53,6 +64,5 @@

Verizon, one of the major mobile carriers in the United States, adds a unique tracking header to all HTTP traffic on their network. The Electronic Frontier Foundation has written about the privacy implications of this practice. Due to public pressure Verizon has created a way to opt out of this tracking.

- \ No newline at end of file diff --git a/app/src/main/assets/en/images/cookie_dark_blue.png b/app/src/main/assets/en/images/cookie_dark_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..a4d5d409cd29b644a8ca0f04e24f1cc744ae3899 GIT binary patch literal 3625 zcmai1hc_GS_fKL4wW_2_Z8eJ)^%5E}tJG+vs9kE$P(f|gDq7U6-L#0r2(MWyFSS?A zShZtswPJnsANc(~=iKL>=Q+~sr9=M;nEGmM zd1%vpr6|2swT-}62n5?jUF~T-ADMas0NR6p1&GmzKE68S@X;{wdFEm7gR()s0-#VR zNhfy~Z(AGBSCSq`hm0+yTURgSYpcVJ{4zJQLVRw&`qB>TU%ca#(eoq%FG4Sg`SU)i zNOH8euKl^wHiM5Dc5D#w3BgYErbO8&h@b^M_zR3y#kk`Fl)z%qM(9kp?m@vPmFR-I zyz}hFlWV(pao_5$!}hH2e4V{Yr&>?VRCTs{>Seq=6mvqhm0(+0+gbi052ft>Z|KSi zZc@&pUk^;AludO=SU|H z7r1|{Fx%pLzbM#wo7OruafUB7qR}eh6+yO}K?BRnoAzSgK#;W9Dnb zPGf@x*#Sa$qGSDy!pFeHn5Ao0t2-L*D*8DY3DgK-K(%#>IIA1(Pbw4N)`wdKES8bFJ(0f zz61Nm8jFU6C*tp8lPKdo*3aG;u2SC`ipued{Ymv}c+~%kn3cYOZ<~&G zMP0H~x_`7QRr=kUXR|g43z+8C?$?yPi+qZMV!iW~NJ26u5bRjSyzF=QVa;}UH*(Nk zMreudIx9ilc$;=smwqdF0aK(nMZ6g9l=PG`+o$XN7-*W1%s&65O^cLhX>~erGf?>P zeUORGt*Osvl$_^*Bn}n}lQlUSu^N-~7>gXp@p6ZkerTK|_lDfL*Rfu-`gBXL(20aE zwST>$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P_ZN3XFEDBUwm z-*pA4w8ludyj?addGgXv9*jW!8tU+<+Whjcz%LH=JX@0A<13xUEoQ35t5!0ZqM;g= z<$FJ|aE+%r@7IBG{y48Ggaf(0{hbw%?#Id)a|&{`iPE*x8%gls@V(;9nVoZd zWFamrot?0oX;Fi7QlVakcJN!XEL>H-kHX+4s!ikXu%mEyg^FIT@+GK7ek|aQ_fmO( z%{Mi*e@DFR!}@?(#T~UOGO99Nx}SRC*Lb>&Ik(t literal 0 HcmV?d00001 diff --git a/app/src/main/assets/en/images/ic_subtitles_dark_blue.png b/app/src/main/assets/en/images/ic_subtitles_dark_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..11c87bd351ea1f109d62e3e499b6ed761765c1f5 GIT binary patch literal 1079 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEX7WqAsj$Z!;#Vf4nJ zsJsMW#sHP)KY)UgC9V-A!TD(=<%vb94CUqJdYO6I#mR{Use1WE>9gP2NHH)lZ}D_- z45^s&_RijXnNX3okKfNUHEhV%?%;pO$H>bRrLs9+Lr|F*N^t+U0El;=EM2b2Zh787Uq@h=Drul zaDHkz|2wU?>3?_&FFt?UcIV!@ysPhDdHr<1>?*~6L4KP5tefnUZz;-66@wpEV22nFhltA$)&;B`cHgLRt@?L zJGb<+<>Sfr%xmUo_J`EpI&XA$@_yYj-QK@1FFpA8mc(5j$@zb{HdL>!nA2VVVP?sb zd-s?3FYWW^Tkw3}r5x`W+vDcet)0ZYg8S?2T=vgl-rg&dH}7YARG`@KfJ4E8iKCC9 zNtrs#9oD-duJ}G*HeEk&%g(g_Uv5PfuhoC`qkCHMKg$YM92TvcY~A>*ZcTmF+OMX; z|F@TlACKQM=kxiCo(z+E&qT);9|ZEh>F+xd?NGrYAj8Pw&TvrBp#X^~dzbS|`JJ5A zv$u*rejmMY@s^8k=hxr+c)9dT$c9|mL(7Y%R#orp{(RoDj_)254zGIe6OPysKJQP+ zx@+vq`K|}=Jhg-S`pKW^GW*Rx-@UT&gMZ7hZecv_2Fwb4qFNrusZ1iFL6P zU#7gXIde4q>XS#GErmDjXZyxgA9~4u=jRJME{l53Nt|fc#?0j)% zUW)$vx*Elwhws}<-Q`%N_Skp&TCZQ*PS$LBB|TsC_^Oi?n@>JDR?f5>m=;%A{F<`F zTs1a-7oXJci!qC{PR^fKSM_l9vhFRPXFuMg!xkMi_05jm>qR!TM@5SN4?4Ym_RYSu qZ?0c+YC}^a^{f1mvJHr7!SIi%d))(}>zhx>fcT!SelF{r5}E)H)8k73 literal 0 HcmV?d00001 diff --git a/app/src/main/assets/en/images/ic_web_dark_blue.png b/app/src/main/assets/en/images/ic_web_dark_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..d3030befd14c01a136db2d29ab1d25179ce9d57e GIT binary patch literal 1097 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEX7WqAsj$Z!;#Vf4nJ zsJsMW#sHP)KY)UgC9V-A!TD(=<%vb94CUqJdYO6I#mR{Use1WE>9gP2NHH)lAMLfy zT)!&NMaV$MX13S#vupjzzkHpw+dgncpO=-<)O|bd9X#@NvFN|ZtG4@AzrFmm*KE&5 z2Ajxx*Y<9$aDBGEd$wIRdr|e~U)i7f^rqIE-3~k^Ue3q`t$JO zhC8PLy|!OLoM&(sQ>>3HdqU;81(&ohj{YMpVV z@}V_5KfMdAVvwu)KEYf1rt%@5oh3oD^Y6~9sx4v&>zBEs9rm~Q{1R)v|8{==GUmxN zbY6F#&C9v@+RPstuVhbVPFOcJ?eM`hzDwd>ZGD-|u>ECCe#6d5d-)rlIx#dUGaOvX zzM$Y5gLj9df(4U+3?oM$1Iux@fPym&2L&4*a5xmODC~H`uw%3Ej-I^C#Vcp~_3O{O zpSSq?o|o(R|NPp&_2Zv#Gq%~!Zp}*b@7&(-0ivOYVFOV83`UUo5L4!G^7J9wF!R6z zWNFE6hcc$=g2oO7Yh}1hudm+w^ekA?S+BO9GoBydFlMl(u}+M zu7Pt->Ym~|kS~7vy=t}RC5`Q3Yb8CuJ-XU|PF4TkzpEL_D}V_tW}Di}+iG8Dtjgb` zC%3Zg?_9N`z2!{D5C40*YR79v&-I?WE^XnL`h7Acef2zhi+@kODm@Z9;~{k~ 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(); diff --git a/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java index 51952c4f..4eef49c2 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java @@ -128,32 +128,30 @@ public class SettingsFragment extends PreferenceFragment { switch (key) { case "javascript_enabled": - // Set javaScriptEnabled to the new state. The default is false. + // Set `javaScriptEnabled` to the new state. The default is `false`. MainWebViewActivity.javaScriptEnabled = sharedPreferences.getBoolean("javascript_enabled", false); - // Toggle the state of the "dom_storage_enabled" preference. The default is false. + // Toggle the state of the `dom_storage_enabled` preference. The default is `false`. final Preference domStorageEnabled = findPreference("dom_storage_enabled"); domStorageEnabled.setEnabled(sharedPreferences.getBoolean("javascript_enabled", false)); - // Update mainWebView and reload the website. + // Update `mainWebView`. MainWebViewActivity.mainWebView.getSettings().setJavaScriptEnabled(MainWebViewActivity.javaScriptEnabled); - MainWebViewActivity.mainWebView.reload(); // Update the privacy icons. MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity); break; case "first_party_cookies_enabled": - // Set firstPartyCookiesEnabled to the new state. The default is false. + // Set `firstPartyCookiesEnabled` to the new state. The default is `false`. MainWebViewActivity.firstPartyCookiesEnabled = sharedPreferences.getBoolean("first_party_cookies_enabled", false); - // Toggle the state of the "third_party_cookies_enabled" preference. The default is false. + // Toggle the state of the `third_party_cookies_enabled` preference. The default is `false`. final Preference thirdPartyCookiesEnabled = findPreference("third_party_cookies_enabled"); thirdPartyCookiesEnabled.setEnabled(sharedPreferences.getBoolean("first_party_cookies_enabled", false)); - // Update mainWebView and reload the website. + // Update `mainWebView`. MainWebViewActivity.cookieManager.setAcceptCookie(MainWebViewActivity.firstPartyCookiesEnabled); - MainWebViewActivity.mainWebView.reload(); // Update the checkbox in the options menu. MenuItem firstPartyCookiesMenuItem = MainWebViewActivity.mainMenu.findItem(R.id.toggleFirstPartyCookies); @@ -164,17 +162,16 @@ public class SettingsFragment extends PreferenceFragment { break; case "third_party_cookies_enabled": - // Set thirdPartyCookiesEnabled to the new state. The default is false. + // Set `thirdPartyCookiesEnabled` to the new state. The default is `false`. MainWebViewActivity.thirdPartyCookiesEnabled = sharedPreferences.getBoolean("third_party_cookies_enabled", false); // Update the checkbox in the options menu. MenuItem thirdPartyCookiesMenuItem = MainWebViewActivity.mainMenu.findItem(R.id.toggleThirdPartyCookies); thirdPartyCookiesMenuItem.setChecked(MainWebViewActivity.thirdPartyCookiesEnabled); - // Update mainWebView and reload the website if API >= 21. + // Update `mainWebView` if API >= 21. if (Build.VERSION.SDK_INT >= 21) { MainWebViewActivity.cookieManager.setAcceptThirdPartyCookies(MainWebViewActivity.mainWebView, MainWebViewActivity.thirdPartyCookiesEnabled); - MainWebViewActivity.mainWebView.reload(); } // Update the privacy icons. @@ -182,32 +179,30 @@ public class SettingsFragment extends PreferenceFragment { break; case "dom_storage_enabled": - // Set domStorageEnabled to the new state. The default is false. + // Set `domStorageEnabled` to the new state. The default is `false`. MainWebViewActivity.domStorageEnabled = sharedPreferences.getBoolean("dom_storage_enabled", false); // Update the checkbox in the options menu. MenuItem domStorageMenuItem = MainWebViewActivity.mainMenu.findItem(R.id.toggleDomStorage); domStorageMenuItem.setChecked(MainWebViewActivity.domStorageEnabled); - // Update mainWebView and reload the website. + // Update `mainWebView`. MainWebViewActivity.mainWebView.getSettings().setDomStorageEnabled(MainWebViewActivity.domStorageEnabled); - MainWebViewActivity.mainWebView.reload(); // Update the privacy icons. MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity); break; case "save_form_data_enabled": - // Set saveFormDataEnabled to the new state. The default is false. + // Set `saveFormDataEnabled` to the new state. The default is `false`. MainWebViewActivity.saveFormDataEnabled = sharedPreferences.getBoolean("save_form_data_enabled", false); // Update the checkbox in the options menu. MenuItem saveFormDataMenuItem = MainWebViewActivity.mainMenu.findItem(R.id.toggleSaveFormData); saveFormDataMenuItem.setChecked(MainWebViewActivity.saveFormDataEnabled); - // Update mainWebView and reload the website. + // Update `mainWebView`. MainWebViewActivity.mainWebView.getSettings().setSaveFormData(MainWebViewActivity.saveFormDataEnabled); - MainWebViewActivity.mainWebView.reload(); // Update the privacy icons. MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity); @@ -218,7 +213,7 @@ public class SettingsFragment extends PreferenceFragment { switch (userAgentString) { case "Default user agent": - // Set the default user agent on mainWebView, display the user agent as the summary text for userAgentPreference, and disable customUserAgent. + // Set the default user agent on `mainWebView`, display the user agent as the summary text for `userAgentPreference`, and disable `customUserAgent`. // Once API >= 17 we can use getDefaultUserAgent(). For now, setUserAgentString("") sets the WebView's default user agent. MainWebViewActivity.mainWebView.getSettings().setUserAgentString(""); userAgentPreference.setSummary(MainWebViewActivity.mainWebView.getSettings().getUserAgentString()); @@ -298,18 +293,26 @@ public class SettingsFragment extends PreferenceFragment { break; case "javascript_enabled_search_custom_url": - // Set the new custom search URL as the summary text for "javascript_enabled_search_custom_url". The default is "". + // Set the new custom search URL as the summary text for `javascript_enabled_search_custom_url`. The default is ``. javaScriptEnabledSearchCustomURLPreference.setSummary(sharedPreferences.getString("javascript_enabled_search_custom_url", "")); - // Update javaScriptEnabledSearchCustomURL. The default is "". + // Update javaScriptEnabledSearchCustomURL. The default is ``. MainWebViewActivity.javaScriptEnabledSearchURL = sharedPreferences.getString("javascript_enabled_search_custom_url", ""); break; + case "do_not_track": + // Update `customHeaders`. The default is `true`. + if (sharedPreferences.getBoolean("do_not_track", true)) { + MainWebViewActivity.customHeaders.put("DNT", "1"); + } else { // Remove the Do Not Track header. + MainWebViewActivity.customHeaders.remove("DNT"); + } + case "homepage": - // Set the new homepage URL as the summary text for the Homepage preference. The default is "https://www.duckduckgo.com". + // Set the new homepage URL as the summary text for the Homepage preference. The default is `https://www.duckduckgo.com`. homepagePreference.setSummary(sharedPreferences.getString("homepage", "https://www.duckduckgo.com")); - // Update the homepage variable. The default is "https://www.duckduckgo.com". + // Update the homepage variable. The default is `https://www.duckduckgo.com`. MainWebViewActivity.homepage = sharedPreferences.getString("homepage", "https://www.duckduckgo.com"); break; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 02ed5ea1..2ede85be 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -205,6 +205,8 @@ Custom user agent Custom user agent + Do not track + Send the Do Not Track header which politely suggests that web servers not track this browser. Search JavaScript-disabled search diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index f6acd257..4441ca6a 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -68,6 +68,12 @@ android:defaultValue="PrivacyBrowser/1.0" android:inputType="textVisiblePassword|textMultiLine" /> + +