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: interface nsIFaviconDataCallback; michael@0: michael@0: [scriptable, uuid(8849feef-0ead-4e9b-b63b-8d862c42a736)] michael@0: interface mozIAsyncFavicons : nsISupports michael@0: { michael@0: /** michael@0: * Declares that a given page uses a favicon with the given URI and michael@0: * attempts to fetch and save the icon data by loading the favicon URI michael@0: * through an async network request. michael@0: * michael@0: * If the icon data already exists, we won't try to reload the icon unless michael@0: * aForceReload is true. Similarly, if the icon is in the failed favicon michael@0: * cache we won't do anything unless aForceReload is true, in which case michael@0: * we'll try to reload the favicon. michael@0: * michael@0: * This function will only save favicons for pages that are already stored in michael@0: * the database, like visited pages or bookmarks. For any other URIs, it michael@0: * will succeed but do nothing. This function will also ignore the error michael@0: * page favicon URI (see FAVICON_ERRORPAGE_URL below). michael@0: * michael@0: * Icons that fail to load will automatically be added to the failed favicon michael@0: * cache, and this function will not save favicons for non-bookmarked URIs michael@0: * when history is disabled. michael@0: * michael@0: * @note This function is identical to michael@0: * nsIFaviconService::setAndLoadFaviconForPage. michael@0: * michael@0: * @param aPageURI michael@0: * URI of the page whose favicon is being set. michael@0: * @param aFaviconURI michael@0: * URI of the favicon to associate with the page. michael@0: * @param aForceReload michael@0: * If aForceReload is false, we try to reload the favicon only if we michael@0: * don't have it or it has expired from the cache. Setting michael@0: * aForceReload to true causes us to reload the favicon even if we michael@0: * have a usable copy. michael@0: * @param aFaviconLoadType michael@0: * Set to FAVICON_LOAD_PRIVATE if the favicon is loaded from a private michael@0: * browsing window. Set to FAVICON_LOAD_NON_PRIVATE otherwise. michael@0: * @param aCallback michael@0: * Once we're done setting and/or fetching the favicon, we invoke this michael@0: * callback. michael@0: * michael@0: * @see nsIFaviconDataCallback in nsIFaviconService.idl. michael@0: */ michael@0: void setAndFetchFaviconForPage(in nsIURI aPageURI, michael@0: in nsIURI aFaviconURI, michael@0: in boolean aForceReload, michael@0: in unsigned long aFaviconLoadType, michael@0: [optional] in nsIFaviconDataCallback aCallback); michael@0: michael@0: /** michael@0: * Sets the data for a given favicon URI either by replacing existing data in michael@0: * the database or taking the place of otherwise fetched icon data when michael@0: * calling setAndFetchFaviconForPage later. michael@0: * michael@0: * Favicon data for favicon URIs that are not associated with a page URI via michael@0: * setAndFetchFaviconForPage will be stored in memory, but may be expired at michael@0: * any time, so you should make an effort to associate favicon URIs with page michael@0: * URIs as soon as possible. michael@0: * michael@0: * It's better to not use this function for chrome: icon URIs since you can michael@0: * reference the chrome image yourself. getFaviconLinkForIcon/Page will ignore michael@0: * any associated data if the favicon URI is "chrome:" and just return the michael@0: * same chrome URI. michael@0: * michael@0: * This function does NOT send out notifications that the data has changed. michael@0: * Pages using this favicons that are visible in history or bookmarks views michael@0: * will keep the old icon until they have been refreshed by other means. michael@0: * michael@0: * This function tries to optimize the favicon size, if it is bigger michael@0: * than a defined limit we will try to convert it to a 16x16 png image. michael@0: * If the conversion fails and favicon is still bigger than our max accepted michael@0: * size it won't be saved. michael@0: * michael@0: * @param aFaviconURI michael@0: * URI of the favicon whose data is being set. michael@0: * @param aData michael@0: * Binary contents of the favicon to save michael@0: * @param aDataLength michael@0: * Length of binary data michael@0: * @param aMimeType michael@0: * MIME type of the data to store. This is important so that we know michael@0: * what to report when the favicon is used. You should always set this michael@0: * param unless you are clearing an icon. michael@0: * @param aExpiration michael@0: * Time in microseconds since the epoch when this favicon expires. michael@0: * Until this time, we won't try to load it again. michael@0: * @throws NS_ERROR_FAILURE michael@0: * Thrown if the favicon is overbloated and won't be saved to the db. michael@0: */ michael@0: void replaceFaviconData(in nsIURI aFaviconURI, michael@0: [const,array,size_is(aDataLen)] in octet aData, michael@0: in unsigned long aDataLen, michael@0: in AUTF8String aMimeType, michael@0: [optional] in PRTime aExpiration); michael@0: michael@0: /** michael@0: * Same as replaceFaviconData but the data is provided by a string michael@0: * containing a data URL. michael@0: * michael@0: * @see replaceFaviconData michael@0: * michael@0: * @param aFaviconURI michael@0: * URI of the favicon whose data is being set. michael@0: * @param aDataURL michael@0: * string containing a data URL that represents the contents of michael@0: * the favicon to save michael@0: * @param aExpiration michael@0: * Time in microseconds since the epoch when this favicon expires. michael@0: * Until this time, we won't try to load it again. michael@0: * @throws NS_ERROR_FAILURE michael@0: * Thrown if the favicon is overbloated and won't be saved to the db. michael@0: */ michael@0: void replaceFaviconDataFromDataURL(in nsIURI aFaviconURI, michael@0: in AString aDataURL, michael@0: [optional] in PRTime aExpiration); michael@0: michael@0: /** michael@0: * Retrieves the favicon URI associated to the given page, if any. michael@0: * michael@0: * @param aPageURI michael@0: * URI of the page whose favicon URI we're looking up. michael@0: * @param aCallback michael@0: * This callback is always invoked to notify the result of the lookup. michael@0: * The aURI parameter will be the favicon URI, or null when no favicon michael@0: * is associated with the page or an error occurred while fetching it. michael@0: * michael@0: * @note When the callback is invoked, aDataLen will be always 0, aData will michael@0: * be an empty array, and aMimeType will be an empty string, regardless michael@0: * of whether a favicon is associated with the page. michael@0: * michael@0: * @see nsIFaviconDataCallback in nsIFaviconService.idl. michael@0: */ michael@0: void getFaviconURLForPage(in nsIURI aPageURI, michael@0: in nsIFaviconDataCallback aCallback); michael@0: michael@0: /** michael@0: * Retrieves the favicon URI and data associated to the given page, if any. michael@0: * michael@0: * @param aPageURI michael@0: * URI of the page whose favicon URI and data we're looking up. michael@0: * @param aCallback michael@0: * This callback is always invoked to notify the result of the lookup. The aURI michael@0: * parameter will be the favicon URI, or null when no favicon is michael@0: * associated with the page or an error occurred while fetching it. If michael@0: * aURI is not null, the other parameters may contain the favicon data. michael@0: * However, if no favicon data is currently associated with the favicon michael@0: * URI, aDataLen will be 0, aData will be an empty array, and aMimeType michael@0: * will be an empty string. michael@0: * michael@0: * @see nsIFaviconDataCallback in nsIFaviconService.idl. michael@0: */ michael@0: void getFaviconDataForPage(in nsIURI aPageURI, michael@0: in nsIFaviconDataCallback aCallback); michael@0: };