toolkit/components/places/nsIFaviconService.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsISupports.idl"
michael@0 7
michael@0 8 interface nsIURI;
michael@0 9
michael@0 10 [scriptable, uuid(e81e0b0c-b9f1-4c2e-8f3c-b809933cf73c)]
michael@0 11 interface nsIFaviconService : nsISupports
michael@0 12 {
michael@0 13 // The favicon is being loaded from a private browsing window
michael@0 14 const unsigned long FAVICON_LOAD_PRIVATE = 1;
michael@0 15 // The favicon is being loaded from a non-private browsing window
michael@0 16 const unsigned long FAVICON_LOAD_NON_PRIVATE = 2;
michael@0 17
michael@0 18 /**
michael@0 19 * For a given icon URI, this will return a URI that will result in the image.
michael@0 20 * In most cases, this is an annotation URI. For chrome URIs, this will do
michael@0 21 * nothing but returning the input URI.
michael@0 22 *
michael@0 23 * No validity checking is done. If you pass an icon URI that we've never
michael@0 24 * seen, you'll get back a URI that references an invalid icon. The moz-anno
michael@0 25 * protocol handler's special case for "favicon" annotations will resolve
michael@0 26 * invalid icons to the default icon, although without caching.
michael@0 27 * For invalid chrome URIs, you'll get a broken image.
michael@0 28 *
michael@0 29 * @param aFaviconURI
michael@0 30 * The URI of an icon in the favicon service.
michael@0 31 * @return A URI that will give you the icon image. This is NOT the URI of
michael@0 32 * the icon as set on the page, but a URI that will give you the
michael@0 33 * data out of the favicon service. For a normal page with a
michael@0 34 * favicon we've stored, this will be an annotation URI which will
michael@0 35 * then cause the corresponding favicon data to be loaded async from
michael@0 36 * this service. For pages where we don't have a favicon, this will
michael@0 37 * be a chrome URI of the default icon. For chrome URIs, the
michael@0 38 * output will be the same as the input.
michael@0 39 */
michael@0 40 nsIURI getFaviconLinkForIcon(in nsIURI aFaviconURI);
michael@0 41
michael@0 42 /**
michael@0 43 * Expire all known favicons from the database.
michael@0 44 *
michael@0 45 * @note This is an async method.
michael@0 46 * On successful completion a "places-favicons-expired" notification is
michael@0 47 * dispatched through observer's service.
michael@0 48 */
michael@0 49 void expireAllFavicons();
michael@0 50
michael@0 51 /**
michael@0 52 * Adds a given favicon's URI to the failed favicon cache.
michael@0 53 *
michael@0 54 * The lifespan of the favicon cache is up to the caching system. This cache
michael@0 55 * will also be written when setAndLoadFaviconForPage hits an error while
michael@0 56 * fetching an icon.
michael@0 57 *
michael@0 58 * @param aFaviconURI
michael@0 59 * The URI of an icon in the favicon service.
michael@0 60 */
michael@0 61 void addFailedFavicon(in nsIURI aFaviconURI);
michael@0 62
michael@0 63 /**
michael@0 64 * Removes the given favicon from the failed favicon cache. If the icon is
michael@0 65 * not in the cache, it will silently succeed.
michael@0 66 *
michael@0 67 * @param aFaviconURI
michael@0 68 * The URI of an icon in the favicon service.
michael@0 69 */
michael@0 70 void removeFailedFavicon(in nsIURI aFaviconURI);
michael@0 71
michael@0 72 /**
michael@0 73 * Checks to see if a favicon is in the failed favicon cache.
michael@0 74 * A positive return value means the icon is in the failed cache and you
michael@0 75 * probably shouldn't try to load it. A false return value means that it's
michael@0 76 * worth trying to load it.
michael@0 77 * This allows you to avoid trying to load "foo.com/favicon.ico" for every
michael@0 78 * page on a site that doesn't have a favicon.
michael@0 79 *
michael@0 80 * @param aFaviconURI
michael@0 81 * The URI of an icon in the favicon service.
michael@0 82 */
michael@0 83 boolean isFailedFavicon(in nsIURI aFaviconURI);
michael@0 84
michael@0 85 /**
michael@0 86 * The default favicon URI
michael@0 87 */
michael@0 88 readonly attribute nsIURI defaultFavicon;
michael@0 89 };
michael@0 90
michael@0 91 [scriptable, function, uuid(c85e5c82-b70f-4621-9528-beb2aa47fb44)]
michael@0 92 interface nsIFaviconDataCallback : nsISupports
michael@0 93 {
michael@0 94 /**
michael@0 95 * Called when the required favicon's information is available.
michael@0 96 *
michael@0 97 * It's up to the invoking method to state if the callback is always invoked,
michael@0 98 * or called on success only. Check the method documentation to ensure that.
michael@0 99 *
michael@0 100 * The caller will receive the most information we can gather on the icon,
michael@0 101 * but it's not guaranteed that all of them will be set. For some method
michael@0 102 * we could not know the favicon's data (it could just be too expensive to
michael@0 103 * get it, or the method does not require we actually have any data).
michael@0 104 * It's up to the caller to check aDataLen > 0 before using any data-related
michael@0 105 * information like mime-type or data itself.
michael@0 106 *
michael@0 107 * @param aFaviconURI
michael@0 108 * Receives the "favicon URI" (not the "favicon link URI") associated
michael@0 109 * to the requested page. This can be null if there is no associated
michael@0 110 * favicon URI, or the callback is notifying a failure.
michael@0 111 * @param aDataLen
michael@0 112 * Size of the icon data in bytes. Notice that a value of 0 does not
michael@0 113 * necessarily mean that we don't have an icon.
michael@0 114 * @param aData
michael@0 115 * Icon data, or an empty array if aDataLen is 0.
michael@0 116 * @param aMimeType
michael@0 117 * Mime type of the icon, or an empty string if aDataLen is 0.
michael@0 118 *
michael@0 119 * @note If you want to open a network channel to access the favicon, it's
michael@0 120 * recommended that you call the getFaviconLinkForIcon method to convert
michael@0 121 * the "favicon URI" into a "favicon link URI".
michael@0 122 */
michael@0 123 void onComplete(in nsIURI aFaviconURI,
michael@0 124 in unsigned long aDataLen,
michael@0 125 [const,array,size_is(aDataLen)] in octet aData,
michael@0 126 in AUTF8String aMimeType);
michael@0 127 };
michael@0 128
michael@0 129 %{C++
michael@0 130
michael@0 131 /**
michael@0 132 * Notification sent when all favicons are expired.
michael@0 133 */
michael@0 134 #define NS_PLACES_FAVICONS_EXPIRED_TOPIC_ID "places-favicons-expired"
michael@0 135
michael@0 136 #define FAVICON_DEFAULT_URL "chrome://mozapps/skin/places/defaultFavicon.png"
michael@0 137 #define FAVICON_ERRORPAGE_URL "chrome://global/skin/icons/warning-16.png"
michael@0 138
michael@0 139 %}

mercurial