Bug 863242 - Add a preference setting "accept tracking me" to Fennec. r=mleibovic

This commit is contained in:
Tetsuharu OHZEKI 2013-04-26 10:10:59 -04:00
parent 6dee0b730e
commit acfc53f209
5 changed files with 73 additions and 6 deletions

View File

@ -69,7 +69,6 @@
<!ENTITY pref_category_privacy "Privacy &amp; Security">
<!ENTITY pref_category_content "Content">
<!ENTITY pref_about_firefox "About &brandShortName;">
<!ENTITY pref_do_not_track "Tell sites not to track me">
<!ENTITY pref_telemetry "Send performance data">
<!ENTITY pref_remember_signons "Remember passwords">
@ -83,6 +82,11 @@
<!ENTITY pref_cookies_not_accept_foreign "Enabled, excluding 3rd party">
<!ENTITY pref_cookies_disabled "Disabled">
<!ENTITY pref_donottrack_menu "Tracking">
<!ENTITY pref_donottrack_disallow_tracking "Tell sites that I do not want to be tracked">
<!ENTITY pref_donottrack_allow_tracking "Tell sites that I want to be tracked">
<!ENTITY pref_donottrack_no_pref "Do not tell sites anything about my tracking preferences">
<!ENTITY pref_char_encoding "Character encoding">
<!ENTITY pref_char_encoding_on "Show menu">
<!ENTITY pref_char_encoding_off "Don\'t show menu">

View File

@ -46,6 +46,16 @@
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="pref_donottrack_entries">
<item>@string/pref_donottrack_disallow_tracking</item>
<item>@string/pref_donottrack_allow_tracking</item>
<item>@string/pref_donottrack_no_pref</item>
</string-array>
<string-array name="pref_donottrack_values">
<item>1</item>
<item>2</item>
<item>0</item>
</string-array>
<string-array name="pref_import_android_entries">
<item>@string/awesomebar_bookmarks_title</item>

View File

@ -25,10 +25,11 @@
gecko:entryKeys="@array/pref_private_data_keys"
gecko:initialValues="@array/pref_private_data_values" />
<CheckBoxPreference android:key="privacy.donottrackheader.enabled"
android:title="@string/pref_do_not_track"
android:defaultValue="false"
android:persistent="false" />
<ListPreference android:key="privacy.donottrackheader"
android:title="@string/pref_donottrack_menu"
android:entries="@array/pref_donottrack_entries"
android:entryValues="@array/pref_donottrack_values"
android:persistent="false" />
<CheckBoxPreference android:key="signon.rememberSignons"
android:title="@string/pref_remember_signons"

View File

@ -84,7 +84,6 @@
<string name="pref_header_privacy">&pref_header_privacy;</string>
<string name="pref_header_content">&pref_header_content;</string>
<string name="pref_about_firefox">&pref_about_firefox;</string>
<string name="pref_do_not_track">&pref_do_not_track;</string>
<string name="pref_telemetry">&pref_telemetry;</string>
<string name="pref_remember_signons">&pref_remember_signons;</string>
@ -93,6 +92,11 @@
<string name="pref_cookies_not_accept_foreign">&pref_cookies_not_accept_foreign;</string>
<string name="pref_cookies_disabled">&pref_cookies_disabled;</string>
<string name="pref_donottrack_menu">&pref_donottrack_menu;</string>
<string name="pref_donottrack_disallow_tracking">&pref_donottrack_disallow_tracking;</string>
<string name="pref_donottrack_allow_tracking">&pref_donottrack_allow_tracking;</string>
<string name="pref_donottrack_no_pref">&pref_donottrack_no_pref;</string>
<string name="pref_char_encoding">&pref_char_encoding;</string>
<string name="pref_char_encoding_on">&pref_char_encoding_on;</string>
<string name="pref_char_encoding_off">&pref_char_encoding_off;</string>

View File

@ -138,6 +138,12 @@ const kDefaultCSSViewportHeight = 480;
const kViewportRemeasureThrottle = 500;
const kDoNotTrackPrefState = Object.freeze({
NO_PREF: "0",
DISALLOW_TRACKING: "1",
ALLOW_TRACKING: "2",
});
function dump(a) {
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(a);
}
@ -972,6 +978,28 @@ var BrowserApp = {
pref.value = MasterPassword.enabled;
prefs.push(pref);
continue;
/*
* Handle Do-not-track preference
*
* "privacy.donottrackheader" is not "real" pref name.
* This pref name is used in the setting menu, and
* this is passed when initializing the setting menu.
*/
case "privacy.donottrackheader": {
pref.type = "string";
let enableDNT = Services.prefs.getBoolPref("privacy.donottrackheader.enabled");
if (!enableDNT) {
pref.value = kDoNotTrackPrefState.NO_PREF;
} else {
let dntState = Services.prefs.getIntPref("privacy.donottrackheader.value");
pref.value = (dntState === 0) ? kDoNotTrackPrefState.ALLOW_TRACKING :
kDoNotTrackPrefState.DISALLOW_TRACKING;
}
prefs.push(pref);
continue;
}
}
try {
@ -1066,6 +1094,26 @@ var BrowserApp = {
else
MasterPassword.setPassword(json.value);
return;
} else if (json.name === "privacy.donottrackheader") {
// "privacy.donottrackheader" is not "real" pref name, it's used in the setting menu.
switch (json.value) {
case kDoNotTrackPrefState.NO_PREF:
// Don't tell anything about tracking me
Services.prefs.setBoolPref("privacy.donottrackheader.enabled", false);
Services.prefs.clearUserPref("privacy.donottrackheader.value");
break;
case kDoNotTrackPrefState.ALLOW_TRACKING:
// Accept tracking me
Services.prefs.setBoolPref("privacy.donottrackheader.enabled", true);
Services.prefs.setIntPref("privacy.donottrackheader.value", 0);
break;
case kDoNotTrackPrefState.DISALLOW_TRACKING:
// Not accept tracking me
Services.prefs.setBoolPref("privacy.donottrackheader.enabled", true);
Services.prefs.setIntPref("privacy.donottrackheader.value", 1);
break;
}
return;
} else if (json.name == SearchEngines.PREF_SUGGEST_ENABLED) {
// Enabling or disabling suggestions will prevent future prompts
Services.prefs.setBoolPref(SearchEngines.PREF_SUGGEST_PROMPTED, true);