Bug 1064177 - Part 1: Add RestrictedProfiles.DISALLOW_MODIFY_ACCOUNTS. r=wesj
authorNick Alexander <nalexander@mozilla.com>
Fri, 26 Sep 2014 11:44:55 -0700
changeset 207448 3b86d4a1dd9f1c387569274ae56b8f6ad812eb81
parent 207447 3d08daf2b5008e323ef2c1b011145df327d4296b
child 207449 67f1009c3eba005942c7f29dab0708bb55d6059a
push id9018
push usernalexander@mozilla.com
push dateFri, 26 Sep 2014 18:48:16 +0000
treeherderfx-team@5698141fb2b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs1064177
milestone35.0a1
Bug 1064177 - Part 1: Add RestrictedProfiles.DISALLOW_MODIFY_ACCOUNTS. r=wesj This corresponds to UserManager.DISALLOW_MODIFY_ACCOUNTS.
mobile/android/base/RestrictedProfiles.java
mobile/android/base/tests/testRestrictedProfiles.js
toolkit/components/parentalcontrols/nsIParentalControlsService.idl
--- a/mobile/android/base/RestrictedProfiles.java
+++ b/mobile/android/base/RestrictedProfiles.java
@@ -1,44 +1,43 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
+import java.util.Set;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.mozilla.gecko.AppConstants.Versions;
+import org.mozilla.gecko.mozglue.RobocopTarget;
+import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
+
 import android.content.Context;
 import android.os.Bundle;
 import android.os.UserManager;
 import android.util.Log;
 
-import java.lang.StringBuilder;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import org.mozilla.gecko.AppConstants.Versions;
-import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
-
-
+@RobocopTarget
 public class RestrictedProfiles {
     private static final String LOGTAG = "GeckoRestrictedProfiles";
 
     // These constants should be in sync with the ones from toolkit/components/parentalcontrols/nsIParentalControlServices.java
     public static enum Restriction {
         DISALLOW_DOWNLOADS(1, "no_download_files"),
         DISALLOW_INSTALL_EXTENSIONS(2, "no_install_extensions"),
-        DISALLOW_INSTALL_APPS(3, UserManager.DISALLOW_INSTALL_APPS),
+        DISALLOW_INSTALL_APPS(3, "no_install_apps"), // UserManager.DISALLOW_INSTALL_APPS
         DISALLOW_BROWSE_FILES(4, "no_browse_files"),
         DISALLOW_SHARE(5, "no_share"),
         DISALLOW_BOOKMARK(6, "no_bookmark"),
         DISALLOW_ADD_CONTACTS(7, "no_add_contacts"),
-        DISALLOW_SET_IMAGE(8, "no_set_image");
+        DISALLOW_SET_IMAGE(8, "no_set_image"),
+        DISALLOW_MODIFY_ACCOUNTS(9, "no_modify_accounts"); // UserManager.DISALLOW_MODIFY_ACCOUNTS
 
         public final int id;
         public final String name;
 
         private Restriction(final int id, final String name) {
             this.id = id;
             this.name = name;
         }
@@ -49,16 +48,17 @@ public class RestrictedProfiles {
             if (rest.id == action) {
                 return rest.name;
             }
         }
 
         throw new IllegalArgumentException("Unknown action " + action);
     }
 
+    @RobocopTarget
     private static Bundle getRestrictions() {
         final UserManager mgr = (UserManager) GeckoAppShell.getContext().getSystemService(Context.USER_SERVICE);
         return mgr.getUserRestrictions();
     }
 
     @WrapElementForJNI
     public static boolean isUserRestricted() {
         // Guest mode is supported in all Android versions
--- a/mobile/android/base/tests/testRestrictedProfiles.js
+++ b/mobile/android/base/tests/testRestrictedProfiles.js
@@ -21,18 +21,17 @@ add_task(function test_isUserRestricted(
 
   do_check_true(pc.isAllowed(Ci.nsIParentalControlsService.DOWNLOAD));
   do_check_true(pc.isAllowed(Ci.nsIParentalControlsService.INSTALL_EXTENSION));
   do_check_true(pc.isAllowed(Ci.nsIParentalControlsService.INSTALL_APP));
   do_check_true(pc.isAllowed(Ci.nsIParentalControlsService.VISIT_FILE_URLS));
   do_check_true(pc.isAllowed(Ci.nsIParentalControlsService.SHARE));
   do_check_true(pc.isAllowed(Ci.nsIParentalControlsService.BOOKMARK));
   do_check_true(pc.isAllowed(Ci.nsIParentalControlsService.INSTALL_EXTENSION));
-
-  run_next_test();
+  do_check_true(pc.isAllowed(Ci.nsIParentalControlsService.MODIFY_ACCOUNTS));
 });
 
 add_task(function test_getUserRestrictions() {
   // In an admin profile, like the tests: {}
   // In a restricted profile: {"no_modify_accounts":true,"no_share_location":true}
   let restrictions = "{}";
 
   var jenv = null;
--- a/toolkit/components/parentalcontrols/nsIParentalControlsService.idl
+++ b/toolkit/components/parentalcontrols/nsIParentalControlsService.idl
@@ -6,30 +6,31 @@
 
 #include "nsISupports.idl"
 
 interface nsIURI;
 interface nsIFile;
 interface nsIInterfaceRequestor;
 interface nsIArray;
 
-[scriptable, uuid(b3585b2a-b4b3-4aa7-be92-b8ddaa6aec5f)]
+[scriptable, uuid(4bde6754-406a-45d1-b18e-dc685adc1db4)]
 interface nsIParentalControlsService : nsISupports
 {
   /**
    * Action types that can be blocked for users.
    */
   const short DOWNLOAD = 1; // Downloading files
   const short INSTALL_EXTENSION = 2; // Installing extensions
   const short INSTALL_APP = 3; // Installing webapps
   const short VISIT_FILE_URLS = 4; // Opening file:/// urls
   const short SHARE = 5; // Sharing
   const short BOOKMARK = 6; // Creating bookmarks
   const short ADD_CONTACT = 7; // Add contacts to the system database
   const short SET_IMAGE = 8; // Setting images as wall paper
+  const short MODIFY_ACCOUNTS = 9; // Modifying system accounts
 
   /**
    * @returns true if the current user account has parental controls
    * restrictions enabled.
    */ 
   readonly attribute boolean parentalControlsEnabled;
 
   /**