modules/libpref/public/nsISecurityPref.idl
author Simon Bünzli <zeniko@gmail.com>
Sun, 07 Dec 2008 15:20:33 +0100
changeset 22462 5c0da891a0902e7db281150c088758a03c8f455a
parent 1 9b2a99adc05e53cd4010de512f50118594756650
permissions -rw-r--r--
Bug 465215 - tab values can get synchronized. r=dietrich

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 1998
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"

/**
 * Interface for accessing preferences, bypassing the usual security check on
 * preferences starting with "capability". This interface is used by
 * nsScriptSecurityManager which needs unchecked access to security prefs. 
 * *PLEASE* do not call this interface from any other file, as this 
 * would be insecure.
 *
 * THIS INTERFACE SHOULD NEVER BE MADE SCRIPTABLE 
 *
 * @see nsIPrefBranch
 */

[uuid(94afd973-8045-4c6c-89e6-75bdced4209e)]
interface nsISecurityPref : nsISupports {

  /**
   * Called to get the state of a "capability" boolean preference.
   *
   * @param pref     The boolean preference to get the state of.
   *
   * @return boolean The value of the requested boolean preference.
   *
   * @see securitySetBoolPref
   */
  boolean securityGetBoolPref(in string pref);

  /**
   * Called to set the state of a "capability" boolean preference.
   *
   * @param pref   The boolean preference to set the state of.
   * @param value  The boolean value to set the preference to.
   *
   * @return NS_OK The value was successfully set.
   * @return Other The value was not set or is the wrong type.
   *
   * @see securityGetBoolPref
   */
  void securitySetBoolPref(in string pref, in boolean value);

  /**
   * Called to get the state of a "capability" string preference.
   *
   * @param pref    The string preference to retrieve.
   *
   * @return string The value of the requested string preference.
   *
   * @see securitySetCharPref
   */
  string securityGetCharPref(in string pref);

  /**
   * Called to set the state of a "capability" string preference.
   *
   * @param pref   The string preference to set.
   * @param value  The string value to set the preference to.
   *
   * @return NS_OK The value was successfully set.
   * @return Other The value was not set or is the wrong type.
   *
   * @see securityGetCharPref
   */
  void securitySetCharPref(in string pref, in string value);

  /**
   * Called to get the state of a "capability" integer preference.
   *
   * @param pref  The integer preference to get the value of.
   *
   * @return long The value of the requested integer preference.
   *
   * @see securitySetIntPref
   */
  long securityGetIntPref(in string pref);

  /**
   * Called to set the state of a "capability" integer preference.
   *
   * @param pref   The integer preference to set the value of.
   * @param value  The integer value to set the preference to.
   *
   * @return NS_OK The value was successfully set.
   * @return Other The value was not set or is the wrong type.
   *
   * @see securityGetIntPref
   */
  void securitySetIntPref(in string pref, in long value);

  /**
   * Called to clear a user set value from a "capability" preference. This
   * will, in effect, reset the value to the default value. If no default value
   * exists the preference will cease to exist.
   *
   * @param pref_name The preference to be cleared.
   *
   * @note
   * This method does nothing if this object is a default branch.
   *
   * @return NS_OK The user preference was successfully cleared.
   * @return Other The preference does not exist or have a user set value.
   */
  void securityClearUserPref(in string pref_name);

};

/**
 * This interface allows checking whether getting capability prefs is allowed.
 */
[uuid(c73c9a05-92ce-46e1-8f69-90a2a3a36104)]
interface nsIPrefSecurityCheck : nsISupports {
  /**
   * Checks whether the currently executing script (if any) can access security
   * preferences. Corresponds to CapabilityPreferencesAccess.
   *
   * Exceptions from this method should be treated like a return value of false.
   */
  boolean canAccessSecurityPreferences();
};