dom/interfaces/base/nsIContentPermissionPrompt.idl
author Boris Zbarsky <bzbarsky@mit.edu>
Wed, 20 Mar 2019 18:05:09 +0000
changeset 465263 3ab48ce01773af9a130477e46c50e17f9042ea4b
parent 447174 10bf548f81fa7bdbd94fa565c3d53bbb99c89a1c
child 470077 565279f288410f563f7871360a1d53d8e3f60dd9
permissions -rw-r--r--
Bug 1535124 part 3. Add MOZ_CAN_RUN_SCRIPT annotations to geolocation code as needed. r=jdm Differential Revision: https://phabricator.services.mozilla.com/D23521

/* 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 mozIDOMWindow;
interface nsIArray;

webidl Element;

/**
 *  Interface provides the request type and its access.
 */
[scriptable, uuid(ef4db3b8-ca9c-4b1d-8f81-fd88ec32af13)]
interface nsIContentPermissionType : nsISupports {
  /**
   *  The type of the permission request, such as
   *  "geolocation".
   */
  readonly attribute ACString type;

  /**
   * The array of available options.
   */
  readonly attribute nsIArray options; // ["choice1", "choice2"]
};

/**
 *  Interface provides the callback type.
 */
[scriptable, uuid(5fb5bb60-7069-11e4-9803-0800200c9a66)]
interface nsIContentPermissionRequestCallback : nsISupports {
  /**
   * The callback of the visibility result.
   */
  void notifyVisibility(in boolean isVisible);
};

/**
 *  Interface provides the way to get the visibility and
 *  the notification.
 */
[scriptable, uuid(f8577124-6a5f-486f-ae04-c5bcae911eb5)]
interface nsIContentPermissionRequester : nsISupports {
  /**
   * The function to get the visibility.
   */
  void getVisibility(in nsIContentPermissionRequestCallback callback);

  /**
   * The callback to get the notification of visibility change.
   */
  attribute nsIContentPermissionRequestCallback onVisibilityChange;
};

/**
 * Interface allows access to a content to request
 * permission to perform a privileged operation such as
 * geolocation.
 */
[scriptable, uuid(875733da-0ac0-4a26-8c76-70a30876be46)]
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 principal of the top-level page the permission request comes from.
   */
  readonly attribute nsIPrincipal topLevelPrincipal;

  /**
   *  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 mozIDOMWindow window;
  readonly attribute Element element;

  readonly attribute boolean isHandlingUserInput;

  /**
   *  The requester to get the required information of
   *  the window.
   */
  readonly attribute nsIContentPermissionRequester requester;

  /**
   * allow or cancel the request
   */
  [can_run_script]
  void cancel();
  [can_run_script]
  void allow([optional] in jsval choices); // {"type1": "choice1", "type2": "choiceA"}
};

/**
 * 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"
%}