Bug 1222377 - Add option to enable blocking content in restricted profiles. r=margaret

(Feature only enabled in Nightly until we deployed an actual block list)
This commit is contained in:
Sebastian Kaspari 2015-12-15 13:34:49 +01:00
parent 4628ca63b5
commit 59ea8f3540
9 changed files with 47 additions and 6 deletions

View File

@ -12,6 +12,10 @@ package org.mozilla.gecko.restrictions;
public class DefaultConfiguration implements RestrictionConfiguration {
@Override
public boolean isAllowed(Restrictable restrictable) {
if (restrictable == Restrictable.BLOCK_LIST) {
return false;
}
return true;
}

View File

@ -25,7 +25,8 @@ public class GuestProfileConfiguration implements RestrictionConfiguration {
Restrictable.SET_IMAGE,
Restrictable.MODIFY_ACCOUNTS,
Restrictable.REMOTE_DEBUGGING,
Restrictable.IMPORT_SETTINGS
Restrictable.IMPORT_SETTINGS,
Restrictable.BLOCK_LIST
);
@SuppressWarnings("serial")

View File

@ -66,7 +66,11 @@ public enum Restrictable {
CAMERA_MICROPHONE(18, "camera_microphone",
R.string.restrictable_feature_camera_microphone,
R.string.restrictable_feature_camera_microphone_description);
R.string.restrictable_feature_camera_microphone_description),
BLOCK_LIST(19, "block_list",
R.string.restrictable_feature_block_list,
R.string.restrictable_feature_block_list_description);
public final int id;
public final String name;

View File

@ -6,6 +6,7 @@
package org.mozilla.gecko.restrictions;
import org.mozilla.gecko.AboutPages;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.util.ThreadUtils;
import android.annotation.TargetApi;
@ -33,6 +34,11 @@ public class RestrictedProfileConfiguration implements RestrictionConfiguration
configuration.put(Restrictable.ADVANCED_SETTINGS, false);
configuration.put(Restrictable.CAMERA_MICROPHONE, false);
configuration.put(Restrictable.DATA_CHOICES, true);
// Hold behind Nightly flag until we have an actual block list deployed.
if (AppConstants.NIGHTLY_BUILD) {
configuration.put(Restrictable.BLOCK_LIST, false);
}
}
/**

View File

@ -746,6 +746,8 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!ENTITY restrictable_feature_camera_microphone_description "Allows family members to engage in real time communication on websites.">
<!ENTITY restrictable_feature_data_choices "Data Choices">
<!ENTITY restrictable_feature_data_choices_description "Choose whether or not to send usage information to Mozilla to help make Firefox better.">
<!ENTITY restrictable_feature_block_list "Block List">
<!ENTITY restrictable_feature_block_list_description "Block websites that include sensitive content.">
<!-- Default Bookmarks titles-->
<!-- LOCALIZATION NOTE (bookmarks_about_browser): link title for about:fennec -->

View File

@ -581,6 +581,8 @@
<string name="restrictable_feature_camera_microphone_description">&restrictable_feature_camera_microphone_description;</string>
<string name="restrictable_feature_data_choices">&restrictable_feature_data_choices;</string>
<string name="restrictable_feature_data_choices_description">&restrictable_feature_data_choices_description;</string>
<string name="restrictable_feature_block_list">&restrictable_feature_block_list;</string>
<string name="restrictable_feature_block_list_description">&restrictable_feature_block_list_description;</string>
<!-- Miscellaneous -->
<string name="ellipsis">&ellipsis;</string>

View File

@ -538,6 +538,12 @@ var BrowserApp = {
Services.prefs.setBoolPref("xpinstall.enabled", true);
}
if (ParentalControls.parentalControlsEnabled) {
let isBlockListEnabled = ParentalControls.isAllowed(ParentalControls.BLOCK_LIST);
Services.prefs.setBoolPref("browser.safebrowsing.forbiddenURIs.enabled", isBlockListEnabled);
Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", !isBlockListEnabled);
}
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
if (sysInfo.get("version") < 16) {
let defaults = Services.prefs.getDefaultBranch(null);

View File

@ -4,6 +4,7 @@
package org.mozilla.gecko.tests;
import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertFalse;
import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertTrue;
import org.mozilla.gecko.Restrictions;
@ -16,9 +17,23 @@ public class testRestrictions extends UITest {
// No restrictions should be enforced when using a normal profile
for (Restrictable restrictable : Restrictable.values()) {
fAssertTrue(String.format("Restriction %s is not enforced", restrictable.name),
Restrictions.isAllowed(getActivity(), restrictable)
);
if (restrictable == Restrictable.BLOCK_LIST) {
assertFeatureDisabled(restrictable);
} else {
assertFeatureEnabled(restrictable);
}
}
}
private void assertFeatureEnabled(Restrictable restrictable) {
fAssertTrue(String.format("Restrictable feature %s is enabled", restrictable.name),
Restrictions.isAllowed(getActivity(), restrictable)
);
}
private void assertFeatureDisabled(Restrictable restrictable) {
fAssertFalse(String.format("Restrictable feature %s is disabled", restrictable.name),
Restrictions.isAllowed(getActivity(), restrictable)
);
}
}

View File

@ -11,7 +11,7 @@ interface nsIFile;
interface nsIInterfaceRequestor;
interface nsIArray;
[scriptable, uuid(f35733bc-114b-49ce-a8dd-a423f19318bc)]
[scriptable, uuid(f17414cd-d357-476d-b894-2f7bda9e3a9b)]
interface nsIParentalControlsService : nsISupports
{
/**
@ -35,6 +35,7 @@ interface nsIParentalControlsService : nsISupports
const short GUEST_BROWSING = 16; // Disallow usage of guest browsing
const short ADVANCED_SETTINGS = 17; // Advanced settings
const short CAMERA_MICROPHONE = 18; // Camera and microphone (WebRTC)
const short BLOCK_LIST = 19; // Block websites that include sensitive content
/**
* @returns true if the current user account has parental controls