/* 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/. */

#include "nsISupports.idl"

interface nsIPrincipal;
interface nsIDOMWindow;
interface nsIDOMElement;
interface nsIArray;

/**
 *  Interface provides the request type and its access.
 */
[scriptable, builtinclass, uuid(384b6cc4-a66b-4bea-98e0-eb10562a9ba4)]
interface nsIContentPermissionType : nsISupports {
  /**
   *  The type of the permission request, such as
   *  "geolocation".
   */
  readonly attribute ACString type;

  /**
   *  The access of the permission request, such as
   *  "read".
   */
  readonly attribute ACString access;
};

/**
 * Interface allows access to a content to request
 * permission to perform a privileged operation such as
 * geolocation.
 */
[scriptable, uuid(69a39d88-d1c4-4ba9-9b19-bafc7a1bb783)]
interface nsIContentPermissionRequest : nsISupports {
  /**
   *  The array will include the request types. Elements of this array are
   *  nsIContentPermissionType object.
   */
  readonly attribute nsIArray types;

  /*
   *  The principal of the permission request.
   */
  readonly attribute nsIPrincipal principal;

  /**
   *  The window or element that the permission request was
   *  originated in.  Typically the element will be non-null
   *  in when using out of process content.  window or
   *  element can be null but not both.
   */
  readonly attribute nsIDOMWindow window;
  readonly attribute nsIDOMElement element;

  /**
   * allow or cancel the request
   */

  void cancel();
  void allow();
};

/**
 * Interface provides a way for the application to handle
 * the UI prompts associated with geo position.
 */
[scriptable, function, uuid(F72DE90D-E954-4E69-9A61-917303029301)]
interface nsIContentPermissionPrompt : nsISupports {
  /**
   * Called when a request has been made to access
   * privileged content apis
   */
  void prompt(in nsIContentPermissionRequest request);
};

%{C++
#define NS_CONTENT_PERMISSION_PROMPT_CONTRACTID   "@mozilla.org/content-permission/prompt;1"
%}
