image/public/imgILoader.idl
author Ed Morley <emorley@mozilla.com>
Tue, 30 Oct 2012 17:02:31 +0000
changeset 120431 ad1d720d82b7f84d3c7e50f4b02b7c3201662ddb
parent 118750 a913c8c0de54309d68e6b8f99fbc421ccbf9a0f7
child 120918 38b97d2a1bc5fec1615bef02713fdfcecb9be5d7
permissions -rw-r--r--
Backout a145ded68994, e0cf397089ec & 1545e91c658e (bug 798491) for bustage on a CLOSED TREE

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * 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 imgINotificationObserver;
interface imgIRequest;

interface nsIChannel;
interface nsILoadGroup;
interface nsIPrincipal;
interface nsIStreamListener;
interface nsIURI;

interface nsISimpleEnumerator;
interface nsIChannelPolicy;

#include "nsIRequest.idl" // for nsLoadFlags

/**
 * imgILoader interface
 *
 * @author Stuart Parmenter <pavlov@netscape.com>
 * @version 0.3
 * @see imagelib2
 */
[scriptable, uuid(f5a7c016-8caf-460a-b1a1-3fe5534d5c9e)]
interface imgILoader : nsISupports
{
  // Extra flags to pass to loadImage if you want a load to use CORS
  // validation.
  const unsigned long LOAD_CORS_ANONYMOUS = 1 << 16;
  const unsigned long LOAD_CORS_USE_CREDENTIALS = 1 << 17;

  /**
   * Start the load and decode of an image.
   * @param aURI the URI to load
   * @param aInitialDocumentURI the URI that 'initiated' the load -- used for 3rd party cookie blocking
   * @param aReferrerURI the 'referring' URI
   * @param aLoadingPrincipal the principal of the loading document
   * @param aLoadGroup Loadgroup to put the image load into
   * @param aObserver the observer (may be null)
   * @param aCX some random data
   * @param aLoadFlags Load flags for the request
   * @param aCacheKey cache key to use for a load if the original
   *                  image came from a request that had post data
   * @param aRequest A newly created, unused imgIRequest object or NULL for one to
                     be created for you.


   * libpr0n does NOT keep a strong ref to the observer; this prevents
   * reference cycles.  This means that callers of loadImage should
   * make sure to Cancel() the resulting request before the observer
   * goes away.
   */
  imgIRequest loadImage(in nsIURI aURI,
                        in nsIURI aInitialDocumentURL,
                        in nsIURI aReferrerURI,
                        in nsIPrincipal aLoadingPrincipal,
                        in nsILoadGroup aLoadGroup,
                        in imgINotificationObserver aObserver,
                        in nsISupports aCX,
                        in nsLoadFlags aLoadFlags,
                        in nsISupports cacheKey,
                        in imgIRequest aRequest,
                        in nsIChannelPolicy channelPolicy);

  /**
   * Start the load and decode of an image.
   * @param aChannel the channel to load the image from.  This must
   *                 already be opened before ths method is called, and there
   *                 must have been no OnDataAvailable calls for it yet.   
   * @param aObserver the observer (may be null)
   * @param cx some random data
   * @param aListener [out]
   *        A listener that you must send the channel's notifications and data to.
   *        Can be null, in which case imagelib has found a cached image and is
   *        not interested in the data. @aChannel will be canceled for you in
   *        this case.
   *
   * libpr0n does NOT keep a strong ref to the observer; this prevents
   * reference cycles.  This means that callers of loadImageWithChannel should
   * make sure to Cancel() the resulting request before the observer goes away.
   */
  imgIRequest loadImageWithChannel(in nsIChannel aChannel,
                        in imgINotificationObserver aObserver,
                        in nsISupports cx,
                        out nsIStreamListener aListener);
};