michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIURI; michael@0: michael@0: [scriptable, uuid(e81e0b0c-b9f1-4c2e-8f3c-b809933cf73c)] michael@0: interface nsIFaviconService : nsISupports michael@0: { michael@0: // The favicon is being loaded from a private browsing window michael@0: const unsigned long FAVICON_LOAD_PRIVATE = 1; michael@0: // The favicon is being loaded from a non-private browsing window michael@0: const unsigned long FAVICON_LOAD_NON_PRIVATE = 2; michael@0: michael@0: /** michael@0: * For a given icon URI, this will return a URI that will result in the image. michael@0: * In most cases, this is an annotation URI. For chrome URIs, this will do michael@0: * nothing but returning the input URI. michael@0: * michael@0: * No validity checking is done. If you pass an icon URI that we've never michael@0: * seen, you'll get back a URI that references an invalid icon. The moz-anno michael@0: * protocol handler's special case for "favicon" annotations will resolve michael@0: * invalid icons to the default icon, although without caching. michael@0: * For invalid chrome URIs, you'll get a broken image. michael@0: * michael@0: * @param aFaviconURI michael@0: * The URI of an icon in the favicon service. michael@0: * @return A URI that will give you the icon image. This is NOT the URI of michael@0: * the icon as set on the page, but a URI that will give you the michael@0: * data out of the favicon service. For a normal page with a michael@0: * favicon we've stored, this will be an annotation URI which will michael@0: * then cause the corresponding favicon data to be loaded async from michael@0: * this service. For pages where we don't have a favicon, this will michael@0: * be a chrome URI of the default icon. For chrome URIs, the michael@0: * output will be the same as the input. michael@0: */ michael@0: nsIURI getFaviconLinkForIcon(in nsIURI aFaviconURI); michael@0: michael@0: /** michael@0: * Expire all known favicons from the database. michael@0: * michael@0: * @note This is an async method. michael@0: * On successful completion a "places-favicons-expired" notification is michael@0: * dispatched through observer's service. michael@0: */ michael@0: void expireAllFavicons(); michael@0: michael@0: /** michael@0: * Adds a given favicon's URI to the failed favicon cache. michael@0: * michael@0: * The lifespan of the favicon cache is up to the caching system. This cache michael@0: * will also be written when setAndLoadFaviconForPage hits an error while michael@0: * fetching an icon. michael@0: * michael@0: * @param aFaviconURI michael@0: * The URI of an icon in the favicon service. michael@0: */ michael@0: void addFailedFavicon(in nsIURI aFaviconURI); michael@0: michael@0: /** michael@0: * Removes the given favicon from the failed favicon cache. If the icon is michael@0: * not in the cache, it will silently succeed. michael@0: * michael@0: * @param aFaviconURI michael@0: * The URI of an icon in the favicon service. michael@0: */ michael@0: void removeFailedFavicon(in nsIURI aFaviconURI); michael@0: michael@0: /** michael@0: * Checks to see if a favicon is in the failed favicon cache. michael@0: * A positive return value means the icon is in the failed cache and you michael@0: * probably shouldn't try to load it. A false return value means that it's michael@0: * worth trying to load it. michael@0: * This allows you to avoid trying to load "foo.com/favicon.ico" for every michael@0: * page on a site that doesn't have a favicon. michael@0: * michael@0: * @param aFaviconURI michael@0: * The URI of an icon in the favicon service. michael@0: */ michael@0: boolean isFailedFavicon(in nsIURI aFaviconURI); michael@0: michael@0: /** michael@0: * The default favicon URI michael@0: */ michael@0: readonly attribute nsIURI defaultFavicon; michael@0: }; michael@0: michael@0: [scriptable, function, uuid(c85e5c82-b70f-4621-9528-beb2aa47fb44)] michael@0: interface nsIFaviconDataCallback : nsISupports michael@0: { michael@0: /** michael@0: * Called when the required favicon's information is available. michael@0: * michael@0: * It's up to the invoking method to state if the callback is always invoked, michael@0: * or called on success only. Check the method documentation to ensure that. michael@0: * michael@0: * The caller will receive the most information we can gather on the icon, michael@0: * but it's not guaranteed that all of them will be set. For some method michael@0: * we could not know the favicon's data (it could just be too expensive to michael@0: * get it, or the method does not require we actually have any data). michael@0: * It's up to the caller to check aDataLen > 0 before using any data-related michael@0: * information like mime-type or data itself. michael@0: * michael@0: * @param aFaviconURI michael@0: * Receives the "favicon URI" (not the "favicon link URI") associated michael@0: * to the requested page. This can be null if there is no associated michael@0: * favicon URI, or the callback is notifying a failure. michael@0: * @param aDataLen michael@0: * Size of the icon data in bytes. Notice that a value of 0 does not michael@0: * necessarily mean that we don't have an icon. michael@0: * @param aData michael@0: * Icon data, or an empty array if aDataLen is 0. michael@0: * @param aMimeType michael@0: * Mime type of the icon, or an empty string if aDataLen is 0. michael@0: * michael@0: * @note If you want to open a network channel to access the favicon, it's michael@0: * recommended that you call the getFaviconLinkForIcon method to convert michael@0: * the "favicon URI" into a "favicon link URI". michael@0: */ michael@0: void onComplete(in nsIURI aFaviconURI, michael@0: in unsigned long aDataLen, michael@0: [const,array,size_is(aDataLen)] in octet aData, michael@0: in AUTF8String aMimeType); michael@0: }; michael@0: michael@0: %{C++ michael@0: michael@0: /** michael@0: * Notification sent when all favicons are expired. michael@0: */ michael@0: #define NS_PLACES_FAVICONS_EXPIRED_TOPIC_ID "places-favicons-expired" michael@0: michael@0: #define FAVICON_DEFAULT_URL "chrome://mozapps/skin/places/defaultFavicon.png" michael@0: #define FAVICON_ERRORPAGE_URL "chrome://global/skin/icons/warning-16.png" michael@0: michael@0: %}