toolkit/components/places/nsIFaviconService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/nsIFaviconService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,139 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +interface nsIURI;
    1.12 +
    1.13 +[scriptable, uuid(e81e0b0c-b9f1-4c2e-8f3c-b809933cf73c)]
    1.14 +interface nsIFaviconService : nsISupports
    1.15 +{
    1.16 +  // The favicon is being loaded from a private browsing window
    1.17 +  const unsigned long FAVICON_LOAD_PRIVATE = 1;
    1.18 +  // The favicon is being loaded from a non-private browsing window
    1.19 +  const unsigned long FAVICON_LOAD_NON_PRIVATE = 2;
    1.20 +
    1.21 +  /**
    1.22 +   * For a given icon URI, this will return a URI that will result in the image.
    1.23 +   * In most cases, this is an annotation URI.  For chrome URIs, this will do
    1.24 +   * nothing but returning the input URI.
    1.25 +   *
    1.26 +   * No validity checking is done. If you pass an icon URI that we've never
    1.27 +   * seen, you'll get back a URI that references an invalid icon. The moz-anno
    1.28 +   * protocol handler's special case for "favicon" annotations will resolve
    1.29 +   * invalid icons to the default icon, although without caching.
    1.30 +   * For invalid chrome URIs, you'll get a broken image.
    1.31 +   *
    1.32 +   * @param aFaviconURI
    1.33 +   *        The URI of an icon in the favicon service.
    1.34 +   * @return A URI that will give you the icon image.  This is NOT the URI of
    1.35 +   *         the icon as set on the page, but a URI that will give you the
    1.36 +   *         data out of the favicon service.  For a normal page with a
    1.37 +   *         favicon we've stored, this will be an annotation URI which will
    1.38 +   *         then cause the corresponding favicon data to be loaded async from
    1.39 +   *         this service.  For pages where we don't have a favicon, this will
    1.40 +   *         be a chrome URI of the default icon. For chrome URIs, the
    1.41 +   *         output will be the same as the input.
    1.42 +   */
    1.43 +  nsIURI getFaviconLinkForIcon(in nsIURI aFaviconURI);
    1.44 +
    1.45 +  /**
    1.46 +   * Expire all known favicons from the database.
    1.47 +   *
    1.48 +   * @note This is an async method.
    1.49 +   *       On successful completion a "places-favicons-expired" notification is
    1.50 +   *       dispatched through observer's service.
    1.51 +   */
    1.52 +  void expireAllFavicons();
    1.53 +
    1.54 +  /**
    1.55 +   * Adds a given favicon's URI to the failed favicon cache.
    1.56 +   *
    1.57 +   * The lifespan of the favicon cache is up to the caching system.  This cache
    1.58 +   * will also be written when setAndLoadFaviconForPage hits an error while
    1.59 +   * fetching an icon.
    1.60 +   *
    1.61 +   * @param aFaviconURI
    1.62 +   *        The URI of an icon in the favicon service.
    1.63 +   */
    1.64 +  void addFailedFavicon(in nsIURI aFaviconURI);
    1.65 +
    1.66 +  /**
    1.67 +   * Removes the given favicon from the failed favicon cache.  If the icon is
    1.68 +   * not in the cache, it will silently succeed.
    1.69 +   *
    1.70 +   * @param aFaviconURI
    1.71 +   *        The URI of an icon in the favicon service.
    1.72 +   */
    1.73 +  void removeFailedFavicon(in nsIURI aFaviconURI);
    1.74 +
    1.75 +  /**
    1.76 +   * Checks to see if a favicon is in the failed favicon cache.
    1.77 +   * A positive return value means the icon is in the failed cache and you
    1.78 +   * probably shouldn't try to load it.  A false return value means that it's
    1.79 +   * worth trying to load it.
    1.80 +   * This allows you to avoid trying to load "foo.com/favicon.ico" for every
    1.81 +   * page on a site that doesn't have a favicon.
    1.82 +   *
    1.83 +   * @param aFaviconURI
    1.84 +   *        The URI of an icon in the favicon service.
    1.85 +   */
    1.86 +  boolean isFailedFavicon(in nsIURI aFaviconURI);
    1.87 +
    1.88 +  /**
    1.89 +   * The default favicon URI
    1.90 +   */
    1.91 +  readonly attribute nsIURI defaultFavicon;
    1.92 +};
    1.93 +
    1.94 +[scriptable, function, uuid(c85e5c82-b70f-4621-9528-beb2aa47fb44)]
    1.95 +interface nsIFaviconDataCallback : nsISupports
    1.96 +{
    1.97 +  /**
    1.98 +   * Called when the required favicon's information is available.
    1.99 +   *
   1.100 +   * It's up to the invoking method to state if the callback is always invoked,
   1.101 +   * or called on success only.  Check the method documentation to ensure that.
   1.102 +   *
   1.103 +   * The caller will receive the most information we can gather on the icon,
   1.104 +   * but it's not guaranteed that all of them will be set.  For some method
   1.105 +   * we could not know the favicon's data (it could just be too expensive to
   1.106 +   * get it, or the method does not require we actually have any data).
   1.107 +   * It's up to the caller to check aDataLen > 0 before using any data-related
   1.108 +   * information like mime-type or data itself.
   1.109 +   *
   1.110 +   * @param aFaviconURI
   1.111 +   *        Receives the "favicon URI" (not the "favicon link URI") associated
   1.112 +   *        to the requested page.  This can be null if there is no associated
   1.113 +   *        favicon URI, or the callback is notifying a failure.
   1.114 +   * @param aDataLen
   1.115 +   *        Size of the icon data in bytes.  Notice that a value of 0 does not
   1.116 +   *        necessarily mean that we don't have an icon.
   1.117 +   * @param aData
   1.118 +   *        Icon data, or an empty array if aDataLen is 0.
   1.119 +   * @param aMimeType
   1.120 +   *        Mime type of the icon, or an empty string if aDataLen is 0.
   1.121 +   *
   1.122 +   * @note If you want to open a network channel to access the favicon, it's
   1.123 +   *       recommended that you call the getFaviconLinkForIcon method to convert
   1.124 +   *       the "favicon URI" into a "favicon link URI".
   1.125 +   */
   1.126 +  void onComplete(in nsIURI aFaviconURI,
   1.127 +                  in unsigned long aDataLen,
   1.128 +                  [const,array,size_is(aDataLen)] in octet aData,
   1.129 +                  in AUTF8String aMimeType);
   1.130 +};
   1.131 +
   1.132 +%{C++
   1.133 +
   1.134 +/**
   1.135 + * Notification sent when all favicons are expired.
   1.136 + */
   1.137 +#define NS_PLACES_FAVICONS_EXPIRED_TOPIC_ID "places-favicons-expired"
   1.138 +
   1.139 +#define FAVICON_DEFAULT_URL "chrome://mozapps/skin/places/defaultFavicon.png"
   1.140 +#define FAVICON_ERRORPAGE_URL "chrome://global/skin/icons/warning-16.png"
   1.141 +
   1.142 +%}

mercurial