Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / toolkit / components / places / public / nsIFaviconService.idl
blob60d8edd13490da98ffaaade81845301d45ffd5ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Places code
17 * The Initial Developer of the Original Code is
18 * Google Inc.
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Brett Wilson <brettw@gmail.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsISupports.idl"
41 interface nsIURI;
43 [scriptable, uuid(fafe10e0-194f-4e89-aab9-a5849e97287c)]
44 interface nsIFaviconService : nsISupports
46 /**
47 * Declares that a given page uses a favicon with the given URI.
49 * You needn't have specified any data at this point. An entry linking the
50 * favicon with the page will be create with no data. You can populate it
51 * later with SetFaviconData. However, any favicons not associated with a
52 * visited web page, a bookmark, or a "place:" URI will be expired when
53 * history cleanup is done * (typically at app shutdown, but also possibly
54 * if the user clears their * cache or history).
56 * This will send out history notifications if the new favicon has any data.
57 * This means that you should try to set data first if you have it, otherwise
58 * the page might not get a notification sent for it since data setting does
59 * not send notifications.
61 * @param aPageURI
62 * URI of the page whose favicon is being set.
63 * @param aFaviconURI
64 * URI of the favicon to associate with the page.
66 void setFaviconUrlForPage(in nsIURI aPageURI, in nsIURI aFaviconURI);
68 /**
69 * Same as SetFaviconUrlForPage except that this also attempts to set the
70 * data by loading the favicon URI. An async request will be created for
71 * this URI and if the data is available, it will asynchronously get
72 * saved in the database without any further work from the caller.
74 * If the icon data already exists, we won't normally try to re-load the
75 * icon from the net (or more likely the cache). If the icon is in the
76 * failed favicon cache we won't do anything. Use forceReload to force
77 * a reload of the data. This will remove the favicon from the failed
78 * cache. If it then fails again, it will be re-added to the failed cache.
80 * SetFaviconUrlForPage and SetFaviconData will take any URI you provide
81 * and save it. This function is intended for automatic usage, and will
82 * only save favicons for "good" URIs, as defined by what gets added to
83 * history. For "bad" URIs, this function will succeed and do nothing.
84 * This function will also ignore the error page favicon URI
85 * (chrome://global/skin/icons/warning-16.png). Icons that fail to load
86 * will automatically be added to the failed favicon cache.
88 * This function will not save favicons for non-bookmarked URIs when
89 * history is disabled (expiration time is 0 days). The rest of the functions
90 * here will always store favicons even when history is disabled.
92 * @param aPageURI
93 * URI of the page whose favicon is being set.
94 * @param aFaviconURI
95 * URI of the favicon to associate with the page.
96 * @param aForceReload
97 * Unset is normal behavior, we will only try to reload the favicon
98 * if we don't have it or if it has expired from the cache. If set,
99 * it will always try to reload the favicon.
101 void setAndLoadFaviconForPage(in nsIURI aPageURI, in nsIURI aFaviconURI,
102 in boolean aForceReload);
105 * Stores the data of a given favicon. You must specify the MIME type
106 * unless you're clearing the data.
108 * You can set the data even if you haven't called SetFaviconUrlForPage
109 * yet. It will be stored but will not be associated with any page.
110 * However, any favicons not associated with a visited web page, bookmark,
111 * or "place:" URI will be expired when history cleanup is done. This might
112 * be done at any time on a timer, so you should not let the message loop
113 * run between calls or your icon may get deleted.
115 * It is best to set the favicon data, and then associate it with a page.
116 * This will make the notifications more efficient since the icon will
117 * already have data when the set favicon observer messages goes out.
119 * The expiration time is stored. This will be used if you call
120 * SetAndLoadFaviconForPage to see whether the data needs reloading.
122 * Do not use this function for chrome: icon URIs. You should reference the
123 * chrome image yourself. The GetFaviconLinkForIcon/Page will ignore any
124 * associated data if the favicon URI is "chrome:" and just return the same
125 * chrome URI.
127 * This function does NOT send out notifications that the data has changed.
128 * Potentially, many pages could be referencing the favicon and they could
129 * be visible in a history view or toolbar. But sending out those
130 * notifications is very intensive. Those pages will keep the old icon
131 * until they have been refreshed by other means.
133 * This function tries to optimize the favicon size, if it is bigger
134 * than defined limit we will try to convert it to a 16x16 png image. If the
135 * conversion fails and favicon is bigger than our max accepted favicon size
136 * we will fail and the favicon won't be saved.
138 * @param aFaviconURI
139 * URI of the favicon whose data is being set.
140 * @param aData
141 * Binary contents of the favicon to save
142 * @param aDataLength
143 * Length of binary data
144 * @param aMimeType
145 * MIME type of the data to store. This is important so that we know
146 * what to report when the favicon is used.
147 * @param aExpiration
148 * Time in microseconds since the epoch when this favicon expires.
149 * Until this time, we won't try to load it again.
150 * @throws NS_ERROR_FAILURE
151 * Thrown if the favicon is overbloated and won't be saved to the db.
153 void setFaviconData(in nsIURI aFaviconURI,
154 [const,array,size_is(aDataLen)] in octet aData,
155 in unsigned long aDataLen, in AUTF8String aMimeType,
156 in PRTime aExpiration);
159 * Stores the data of a given favicon. The data is provided by a string
160 * containing a data URL.
162 * This function tries to optimize the favicon size, if it is bigger
163 * than defined limit we will try to convert it to a 16x16 png image. If the
164 * conversion fails and favicon is bigger than our max accepted favicon size
165 * we will fail and the favicon won't be saved.
167 * @see setFaviconData
169 * @param aFaviconURI
170 * URI of the favicon whose data is being set.
171 * @param aDataURL
172 * string containing a data URL that represents the contents of
173 * the favicon to save
174 * @param aExpiration
175 * Time in microseconds since the epoch when this favicon expires.
176 * Until this time, we won't try to load it again.
177 * @throws NS_ERROR_FAILURE
178 * Thrown if the favicon is overbloated and won't be saved to the db.
180 void setFaviconDataFromDataURL(in nsIURI aFaviconURI, in AString aDataURL,
181 in PRTime aExpiration);
184 * Retrieves the given favicon data. Throws if we don't have data.
186 * If there is no data but we have an entry for this favicon, aDataLen will
187 * be 0 and aData will be NULL.
189 * @param aFaviconURI
190 * URI of the favicon whose data is being read
191 * @param aData
192 * Output parameter where the binary favicon data will be placed.
193 * This will be null if we have this URI but have no data associated
194 * with it.
195 * @param aDataLen
196 * Output parameter where the size of the binary data will be placed.
197 * @param aMimeType
198 * Output parameter where the MIME type will be placed.
199 * @throws NS_ERROR_NOT_AVAILABLE
200 * Thrown when we have never heard of this favicon URI.
202 void getFaviconData(in nsIURI aFaviconURI,
203 out AUTF8String aMimeType,
204 out unsigned long aDataLen,
205 [array,retval,size_is(aDataLen)] out octet aData);
208 * Retrieves the given favicon data as a data URL. Throws if we don't
209 * have data.
211 * If there is no data but we have an entry for this favicon, the return
212 * value will be NULL.
214 * @see getFaviconData
216 * @param aFaviconURI
217 * URI of the favicon whose data is being read
218 * @returns A data URL containing the data of the favicon. This will be
219 * null if we have this URL but have no data associated with it.
220 * @throws NS_ERROR_NOT_AVAILABLE
221 * Thrown when we have never heard of this favicon URL.
223 AString getFaviconDataAsDataURL(in nsIURI aFaviconURI);
226 * Retrieves the URI of the favicon for the given page.
228 * @param aPageURI
229 * URI of the page whose favicon is desired
230 * @returns The URI of the favicon associated with that page. Returning a
231 * URI here does NOT mean that we have data for this favicon, only
232 * that we know what the favicon should be.
233 * @throws NS_ERROR_NOT_AVAILABLE
234 * When the page is not found or it has no favicon.
236 nsIURI getFaviconForPage(in nsIURI aPageURI);
239 * For a given page, this will give you a URI that, when displayed in chrome,
240 * will result in the given page's favicon. Unlike the other get functions,
241 * we needn't have heard of the page or its favicon: the default one will
242 * be returned in this case.
244 * @see getFaviconLinkForIcon
245 * This function only adds the extra level of indirection, looking up
246 * the favicon based on the page URI and using the default if not found.
248 * @param aPageURI
249 * URI of the page whose favicon is desired
250 * @returns A URI that will give you the icon image. This is NOT the URI of
251 * the icon as set on the page, but a URI that will give you the
252 * data out of the favicon service. For a normal page with a
253 * favicon we've stored, this will be an annotation URI which will
254 * then cause the corresponding favicon data to be loaded from this
255 * service. For pages where we don't have a favicon, this will be a
256 * chrome URI of the default icon for a web page.
258 nsIURI getFaviconImageForPage(in nsIURI aPageURI);
261 * For a given icon URI, this will return a URI that will result in the image.
262 * In most cases, this is an annotation URI. For chrome, this will do nothing
263 * and return the input URI. For NULL input, this will return the URI of
264 * the default favicon.
266 * @param aFaviconURI
267 * The URI of an icon in the favicon service. Can be NULL.
268 * @returns A URI that will load the desired icon. This is NOT the URI of the
269 * icon as set on the page, but a URI that will give you the data
270 * out of the favicon service. For a normal page with a favicon
271 * we've stored, this will be an annotation URI which will then
272 * cause the corresponding favicon data to be loaded from this
273 * service. For pages where we don't have a favicon, this will be a
274 * chrome URI of the default icon for a web page. For chrome, the
275 * output will be the same as the input. For NULL input, this will
276 * be the URI of the default favicon.
278 * No validity checking is done. If you pass an icon URI that we've
279 * never seen, you'll get back a URI that references an invalid
280 * icon. The moz-anno protocol handler's special case for "favicon"
281 * annotations will detect most invalid icons and it will resolve to
282 * the default icon, although without caching. For invalid chrome
283 * URIs, you'll get a broken image.
285 nsIURI getFaviconLinkForIcon(in nsIURI aFaviconURI);
288 * Adds a given favicon's URI to the failed favicon cache.
290 * The lifespan of the favicon cache is up to the caching system. This cache
291 * will also be written to if you use setAndLoadFaviconForPage and it
292 * encounters an error.
294 * @see isFailedFavicon
296 void addFailedFavicon(in nsIURI aFaviconURI);
299 * Removes the given favicon from the failed favicon cache. If the icon is
300 * not in the cache, this function will silently succeed.
302 void removeFailedFavicon(in nsIURI aFaviconURI);
305 * Checks to see if this favicon is in the failed favicon cache. Returns true
306 * if the favicon is in the failed cache, meaning you probably shouldn't try
307 * to load it. A false return value means that it's worth trying to load it.
308 * This allows you to avoid trying to load "foo.com/favicon.ico" for every
309 * page on a site that doesn't have a favicon.
311 boolean isFailedFavicon(in nsIURI aFaviconURI);
314 * The default favicon URI
316 readonly attribute nsIURI defaultFavicon;