Bug 1199596 - Only install "Parental Controls Theme" for restricted profiles and not guest profiles. r=ally

From browser.js's point of view there's no difference between restricted and guest profiles. Both use the
parental controls API. So there are only two "simple" solutions here:

* 1) Add a method to nsIParentalControlsService to determine whether the current profiles is a restricted or
  a guest profile (Something like isGuest()). But then every platform using this interface would require
  to at least implement a stub for this method.

* 2) Add a new restriction that controls installing the theme.

This patch implements option 2. While this restriction is not of much use besides deciding whether we need
to install a specialized theme (DISALLOW_DEFAULT_THEME), it still offers the most flexibility. In a
follow-up bug we could decide to make the restriction configurable by the device admin (requires localized
strings).
This commit is contained in:
Sebastian Kaspari 2015-08-31 18:09:42 +02:00
parent 26d61cfbf5
commit 56a9bf3fa2
5 changed files with 15 additions and 4 deletions

View File

@ -30,7 +30,8 @@ public class RestrictedProfileConfiguration implements RestrictionConfiguration
Restriction.DISALLOW_DISPLAY_SETTINGS,
Restriction.DISALLOW_CLEAR_HISTORY,
Restriction.DISALLOW_MASTER_PASSWORD,
Restriction.DISALLOW_GUEST_BROWSING
Restriction.DISALLOW_GUEST_BROWSING,
Restriction.DISALLOW_DEFAULT_THEME
);
private Context context;

View File

@ -54,8 +54,9 @@ public enum Restriction {
DISALLOW_MASTER_PASSWORD(18, "no_master_password", R.string.restriction_disallow_master_password_title),
DISALLOW_GUEST_BROWSING(19, "no_guest_browsing", R.string.restriction_disallow_guest_browsing_title);
DISALLOW_GUEST_BROWSING(19, "no_guest_browsing", R.string.restriction_disallow_guest_browsing_title),
DISALLOW_DEFAULT_THEME(20, "no_default_theme", 0);
public final int id;
public final String name;

View File

@ -58,6 +58,11 @@ public class RestrictionProvider extends BroadcastReceiver {
continue;
}
if (restriction == Restriction.DISALLOW_DEFAULT_THEME) {
// This restriction is not configurable
continue;
}
RestrictionEntry entry = createRestrictionEntryWithDefaultValue(context, restriction,
oldRestrictions.getBoolean(restriction.name, true));
entries.add(entry);

View File

@ -3080,7 +3080,10 @@ var LightWeightThemeWebInstaller = {
BrowserApp.deck.addEventListener("PreviewBrowserTheme", this, false, true);
BrowserApp.deck.addEventListener("ResetBrowserThemePreview", this, false, true);
if (ParentalControls.parentalControlsEnabled && !this._manager.currentTheme) {
if (ParentalControls.parentalControlsEnabled &&
!this._manager.currentTheme &&
!ParentalControls.isAllowed(ParentalControls.DEFAULT_THEME)) {
// We are using the DEFAULT_THEME restriction to differentiate between restricted profiles & guest mode - Bug 1199596
this._installParentalControlsTheme();
}
},

View File

@ -11,7 +11,7 @@ interface nsIFile;
interface nsIInterfaceRequestor;
interface nsIArray;
[scriptable, uuid(ed14d186-e902-4d41-86cb-8949fd7b53d7)]
[scriptable, uuid(f9962e65-5369-4346-8c44-84d5319abfc2)]
interface nsIParentalControlsService : nsISupports
{
/**
@ -36,6 +36,7 @@ interface nsIParentalControlsService : nsISupports
const short CLEAR_HISTORY = 17; // Clear browsing history
const short MASTER_PASSWORD = 18; // Setting master password for logins
const short GUEST_BROWSING = 19; // Disallow usage of guest browsing
const short DEFAULT_THEME = 20; // Use default theme or a special parental controls theme
/**
* @returns true if the current user account has parental controls