Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / toolkit / components / places / public / nsINavHistoryService.idl
blob59347e43efbd2d9c07e79a46f77c3f6ccc474969
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 <brett@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"
40 #include "nsIArray.idl"
41 #include "nsIURI.idl"
43 interface nsIFile;
44 interface nsINavHistoryContainerResultNode;
45 interface nsINavHistoryQueryResultNode;
46 interface nsINavHistoryQuery;
47 interface nsINavHistoryQueryOptions;
48 interface nsINavHistoryResult;
49 interface nsINavHistoryBatchCallback;
50 interface nsITreeColumn;
51 interface nsIWritablePropertyBag;
53 [scriptable, uuid(47cf89e3-4777-46bf-9677-21793870ce62)]
54 interface nsINavHistoryResultNode : nsISupports
56 /**
57 * Indentifies the parent result node in the result set. This is null for
58 * top level nodes.
60 readonly attribute nsINavHistoryContainerResultNode parent;
62 /**
63 * The history-result to which this node belongs.
65 readonly attribute nsINavHistoryResult parentResult;
67 /**
68 * URI of the resource in question. For visits and URLs, this is the URL of
69 * the page. For folders and queries, this is the place: URI of the
70 * corresponding folder or query. This may be empty for other types of
71 * objects like host containers.
73 readonly attribute AUTF8String uri;
75 /**
76 * Identifies the type of this node. This node can then be QI-ed to the
77 * corresponding specialized result node interface.
79 const unsigned long RESULT_TYPE_URI = 0; // nsINavHistoryResultNode
80 const unsigned long RESULT_TYPE_VISIT = 1; // nsINavHistoryVisitResultNode
81 const unsigned long RESULT_TYPE_FULL_VISIT = 2; // nsINavHistoryFullVisitResultNode
82 const unsigned long RESULT_TYPE_DYNAMIC_CONTAINER = 4; // nsINavHistoryContainerResultNode
83 const unsigned long RESULT_TYPE_QUERY = 5; // nsINavHistoryQueryResultNode
84 const unsigned long RESULT_TYPE_FOLDER = 6; // nsINavHistoryQueryResultNode
85 const unsigned long RESULT_TYPE_SEPARATOR = 7; // nsINavHistoryResultNode
86 const unsigned long RESULT_TYPE_FOLDER_SHORTCUT = 9; // nsINavHistoryQueryResultNode
87 readonly attribute unsigned long type;
89 /**
90 * Title of the web page, or of the node's query (day, host, folder, etc)
92 readonly attribute AUTF8String title;
94 /**
95 * Total number of times the URI has ever been accessed. For hosts, this
96 * is the total of the children under it, NOT the total times the host has
97 * been accessed (this would require an additional query, so is not given
98 * by default when most of the time it is never needed).
100 readonly attribute unsigned long accessCount;
103 * This is the time the user accessed the page.
105 * If this is a visit, it is the exact time that the page visit occurred.
107 * If this is a URI, it is the most recent time that the URI was visited.
108 * Even if you ask for all URIs for a given date range long ago, this might
109 * contain today's date if the URI was visited today.
111 * For hosts, or other node types with children, this is the most recent
112 * access time for any of the children.
114 * For days queries this is the respective endTime - a maximum possible
115 * visit time to fit in the day range.
117 readonly attribute PRTime time;
120 * This URI can be used as an image source URI and will give you the favicon
121 * for the page. It is *not* the URI of the favicon, but rather something
122 * that will resolve to the actual image.
124 * In most cases, this is an annotation URI that will query the favicon
125 * service. If the entry has no favicon, this is the chrome URI of the
126 * default favicon. If the favicon originally lived in chrome, this will
127 * be the original chrome URI of the icon.
129 readonly attribute nsIURI icon;
132 * This is the number of levels between this node and the top of the
133 * hierarchy. The members of result.children have indentLevel = 0, their
134 * children have indentLevel = 1, etc. The indent level of the root node is
135 * set to -1.
137 readonly attribute long indentLevel;
140 * Value with undefined meaning for use by the view. Its initial value will
141 * be -1. The result implementation treats nodes with this property set to
142 * -1 as invisible!
144 * View-implementations may use this value to track the node index in the
145 * view, e.g. the tree view uses this value to indicate the row in the
146 * tree that this node is at. Other views may choose not to use this, but
147 * should inititalize this value to anything but -1 for visible nodes.
149 attribute long viewIndex;
152 * You can use this to associate temporary information with the result node.
153 * This property bag is associated with the result node and is not persisted
154 * in any way.
156 readonly attribute nsIWritablePropertyBag propertyBag;
159 * When this item is in a bookmark folder (parent is of type folder), this is
160 * the index into that folder of this node. These indices start at 0 and
161 * increase in the order that they appear in the bookmark folder. For items
162 * that are not in a bookmark folder, this value is -1.
164 readonly attribute long bookmarkIndex;
167 * If the node is an item (bookmark, folder or a separator) this value is the
168 * row ID of that bookmark in the database. For other nodes, this value is
169 * set to -1.
171 readonly attribute long long itemId;
174 * If the node is an item (bookmark, folder or a separator) this value is the
175 * time that the item was created. For other nodes, this value is 0.
177 readonly attribute PRTime dateAdded;
180 * If the node is an item (bookmark, folder or a separator) this value is the
181 * time that the item was last modified. For other nodes, this value is 0.
183 readonly attribute PRTime lastModified;
186 * For uri nodes, this is a sorted list of the tags, delimited with commans,
187 * for the uri represented by this node. Otherwise this is an empty string.
189 readonly attribute AString tags;
194 * When you request RESULT_TYPE_VISIT from query options, you will get this
195 * interface for each item, which includes the session ID so that we can
196 * group items from the same session together.
198 [scriptable, uuid(8e2c5a86-b33d-4fa6-944b-559af7e95fcd)]
199 interface nsINavHistoryVisitResultNode : nsINavHistoryResultNode
202 * This indicates the session ID of the * visit. This is used for session
203 * grouping when a tree view is sorted by date.
205 readonly attribute long long sessionId;
210 * This structure will be returned when you request RESULT_TYPE_FULL_VISIT in
211 * the query options. This includes uncommonly used information about each
212 * visit.
214 [scriptable, uuid(c49fd9d5-56e2-43eb-932c-f933f28cba85)]
215 interface nsINavHistoryFullVisitResultNode : nsINavHistoryVisitResultNode
218 * This indicates the visit ID of the visit.
220 readonly attribute long long visitId;
223 * This indicates the referring visit ID of the visit. The referrer should
224 * have the same sessionId.
226 readonly attribute long long referringVisitId;
229 * Indicates the transition type of the visit.
230 * One of nsINavHistoryService.TRANSITION_*
232 readonly attribute long transitionType;
237 * Base class for container results. This includes all types of groupings.
238 * Bookmark folders and places queries will be QueryResultNodes which extends
239 * these items.
241 [scriptable, uuid(f9c8e1c1-e701-44ad-893c-8504c3956929)]
242 interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode
246 * Set this to allow descent into the container. When closed, attempting
247 * to call getChildren or childCount will result in an error. You should
248 * set this to false when you are done reading.
250 * For HOST and DAY groupings, doing this is free since the children have
251 * been precomputed. For queries and bookmark folders, being open means they
252 * will keep themselves up-to-date by listening for updates and re-querying
253 * as needed.
255 attribute boolean containerOpen;
258 * This indicates whether this node "may" have children, and can be used
259 * when the container is open or closed. When the container is closed, it
260 * will give you an exact answer if the node can easily be populated (for
261 * example, a bookmark folder). If not (for example, a complex history query),
262 * it will return true. When the container is open, it will always be
263 * accurate. It is intended to be used to see if we should draw the "+" next
264 * to a tree item.
266 readonly attribute boolean hasChildren;
269 * This gives you the children of the nodes. It is preferrable to use this
270 * interface over the array one, since it avoids creating an nsIArray object
271 * and the interface is already the correct type.
273 * @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false.
275 readonly attribute unsigned long childCount;
276 nsINavHistoryResultNode getChild(in unsigned long aIndex);
279 * Returns false if this node's list of children can be modified
280 * (adding or removing children, or reordering children), or true if
281 * the UI should not allow the list of children to be modified.
282 * This is false for bookmark folder nodes unless setFolderReadOnly() has
283 * been called to override it, and true for non-folder nodes.
285 readonly attribute boolean childrenReadOnly;
287 // --------------------------------------------------------------------------
288 // Dynamic container
291 * This is a string representing the dynamic container API service that is
292 * responsible for this container. This throws if if the node is not a dynamic
293 * container.
295 readonly attribute AUTF8String dynamicContainerType;
298 * Appends a full visit node to this container and returns it. For the dynamic
299 * container API. TO BE CALLED FROM nsIDynamicContainer::OnContainerOpening()
300 * ONLY, and only for non-bookmark-folder containers.
302 * @see nsINavHistoryURIResultNode for parameters.
304 nsINavHistoryResultNode appendURINode(
305 in AUTF8String aURI, in AUTF8String aTitle, in PRUint32 aAccessCount,
306 in PRTime aTime, in AUTF8String aIconURI);
309 * Appends a full visit node to this container and returns it. For the dynamic
310 * container API. TO BE CALLED FROM nsIDynamicContainer::OnContainerOpening()
311 * ONLY, and only for non-bookmark-folder containers.
313 * @see nsINavHistoryVisitResultNode for parameters.
315 * UNTESTED: Container API functions are commented out until we can test
317 /*nsINavHistoryVisitResultNode appendVisitNode(
318 in AUTF8String aURI, in AUTF8String aTitle, in PRUint32 aAccessCount,
319 in PRTime aTime, in AUTF8String aIconURI, in PRInt64 aSession);*/
322 * Appends a full visit node to this container and returns it. For the dynamic
323 * container API. TO BE CALLED FROM nsIDynamicContainer::OnContainerOpening()
324 * ONLY, and only for non-bookmark-folder containers.
326 * @see nsINavHistoryFullVisitResultNode for parameters.
328 * UNTESTED: Container API functions are commented out until we can test
330 /*nsINavHistoryFullVisitResultNode appendFullVisitNode(
331 in AUTF8String aURI, in AUTF8String aTitle, in PRUint32 aAccessCount,
332 in PRTime aTime, in AUTF8String aIconURI, in PRInt64 aSession,
333 in PRInt64 aVisitId, in PRInt64 aReferringVisitId,
334 in PRInt32 aTransitionType);*/
337 * Appends a container node to this container and returns it. For the dynamic
338 * container API. TO BE CALLED FROM nsIDynamicContainer::OnContainerOpening()
339 * ONLY, and only for non-bookmark-folder containers.
341 * aContainerType should be RESULT_TYPE_DYNAMIC_CONTAINER.
342 * When type is dynamic container you must
343 * specify a dynamic container type, otherwise, the dynamic container type must
344 * be null. Use appendQueryNode and appendFolderNode for the other container
345 * types.
347 * UNTESTED: Container API functions are commented out until we can test
349 /*nsINavHistoryContainerResultNode appendContainerNode(
350 in AUTF8String aTitle, in AUTF8String aIconURI, in PRUint32 aContainerType,
351 in AUTF8String aDynamicContainerType);*/
354 * Appends a query node to this container and returns it. For the dynamic
355 * container API. TO BE CALLED FROM nsIDynamicContainer::OnContainerOpening()
356 * ONLY, and only for non-bookmark-folder containers.
358 * Normally you should supply an empty string for IconURI and it will take
359 * the default query icon for the current theme.
361 * UNTESTED: Container API functions are commented out until we can test
363 /*nsINavHistoryQueryResultNode appendQueryNode(
364 in AUTF8String aQueryURI, in AUTF8String aTitle, in AUTF8String aIconURI);*/
367 * Appends a bookmark folder node to this container and returns it. For the
368 * dynamic container API. TO BE CALLED FROM nsIDynamicContainer::OnContainerOpening()
369 * ONLY, and only for non-bookmark-folder containers.
371 * All container attributes will come from the boomkarks service for this
372 * folder.
374 nsINavHistoryContainerResultNode appendFolderNode(in PRInt64 aFolderId);
377 * Clears all children of this container. For the dynamic container API.
378 * TO BE CALLED FROM nsIDynamicContainer::OnContainerOpening and
379 * nsIDynamicContainer::OnContainerClosed ONLY, and valid only for
380 * non-bookmark-folder containers.
382 * UNTESTED: Container API functions are commented out until we can test
384 /*void clearContents();*/
389 * Used for places queries and as a base for bookmark folders.
391 * Note that if you request places to *not* be expanded in the options that
392 * generated this node, this item will report it has no children and never try
393 * to populate itself.
395 [scriptable, uuid(ea17745a-1852-4155-a98f-d1dd1763b3df)]
396 interface nsINavHistoryQueryResultNode : nsINavHistoryContainerResultNode
399 * Get the queries which build this node's children.
400 * Only valid for RESULT_TYPE_QUERY nodes.
402 void getQueries(out unsigned long queryCount,
403 [retval,array,size_is(queryCount)] out nsINavHistoryQuery queries);
406 * Get the options which group this node's children.
407 * Only valid for RESULT_TYPE_QUERY nodes.
409 readonly attribute nsINavHistoryQueryOptions queryOptions;
412 * For both simple folder nodes and simple-folder-query nodes, this is set
413 * to the concrete itemId of the folder. Otherwise, this is set to -1.
415 readonly attribute long long folderItemId;
420 * Allows clients to observe what is happening to a result as it updates itself
421 * according to history and bookmark system events. Register this observer on a
422 * result using registerView
424 * @see nsINavHistoryResult for where this fits in
426 [scriptable, uuid(e60f4429-3787-45c8-a8c0-18ef52621bbf)]
427 interface nsINavHistoryResultViewer : nsISupports
430 * Called when 'aItem' is inserted into 'aParent' at index 'aNewIndex'.
431 * The item previously at index (if any) and everything below it will have
432 * been shifted down by one. The item may be a container or a leaf.
434 void itemInserted(in nsINavHistoryContainerResultNode aParent,
435 in nsINavHistoryResultNode aItem,
436 in unsigned long aNewIndex);
439 * Called whan 'aItem' is removed from 'aParent' at 'aOldIndex'. The item
440 * may be a container or a leaf. This function will be called after the item
441 * has been removed from its parent list, but before anything else (including
442 * NULLing out the item's parent) has happened.
444 void itemRemoved(in nsINavHistoryContainerResultNode aParent,
445 in nsINavHistoryResultNode aItem,
446 in unsigned long aOldIndex);
449 * Called whan 'aItem' is moved from 'aOldParent' at 'aOldIndex' to
450 * aNewParent at aNewIndex. The item may be a container or a leaf.
452 * XXX: at the moment, this method is called only when an item is moved
453 * within the same container. When an item is moved between containers,
454 * a new node is created for the item, and the itemRemoved/itemAdded methods
455 * are used.
457 void itemMoved(in nsINavHistoryResultNode aItem,
458 in nsINavHistoryContainerResultNode aOldParent,
459 in unsigned long aOldIndex,
460 in nsINavHistoryContainerResultNode aNewParent,
461 in unsigned long aNewIndex);
464 * Called when an item has been changed and should be repainted. This only
465 * refers to the specific item. If it is a container, getting this message
466 * does not imply anything happened to the children. You'll get separate
467 * messages for those. Also, this may be called for container nodes at times
468 * when the result thinks it's possible that a twisty mey need to bw redrawn.
470 void itemChanged(in nsINavHistoryResultNode item);
473 * Called when an item is being replaced with another item at the exact
474 * same position.
476 void itemReplaced(in nsINavHistoryContainerResultNode parent,
477 in nsINavHistoryResultNode oldItem,
478 in nsINavHistoryResultNode newItem,
479 in unsigned long index);
482 * Called after a container node went from closed to opened.
484 void containerOpened(in nsINavHistoryContainerResultNode item);
487 * Called after a container node went from opened to closed. This will be
488 * called for the topmost container that is closing, and implies that any
489 * child containers have closed as well.
491 void containerClosed(in nsINavHistoryContainerResultNode item);
494 * Called when something significant has happened within the container. The
495 * contents of the container should be re-built.
497 void invalidateContainer(in nsINavHistoryContainerResultNode item);
500 * Called when something significant is changing that requires everything
501 * to be recomputed. For example, changing sorting can affect every row.
503 void invalidateAll();
506 * This is called to indicate to the UI that the sort has changed to the
507 * given mode. For trees, for example, this would update the column headers
508 * to reflect the sorting. For many other types of views, this won't be
509 * applicable.
511 * @param sortingMode One of nsINavHistoryQueryOptions.SORT_BY_* that
512 * indicates the new sorting mode.
514 * This only is expected to update the sorting UI. invalidateAll() will also
515 * get called if the sorting changes to update everything.
517 void sortingChanged(in unsigned short sortingMode);
520 * Called by the result when this object is set using
521 * nsINavHistoryResult.viewer. This will be set to NULL when the result
522 * is being deallocated. This should not be set by other code.
524 attribute nsINavHistoryResult result;
529 * A predefined view adaptor for interfacing results with an nsITree. This
530 * object will remove itself from its associated result when the tree has been
531 * detached. This prevents circular references. Users should be aware of this,
532 * if you want to re-use the same viewer, you will need to keep your own
533 * reference to it and re-initialize it when the tree changes. If you use this
534 * object, attach it to a result, never attach it to a tree, and forget about
535 * it, it will leak!
537 [scriptable, uuid(fa77e4e9-9fc8-45d2-9507-0fe4f0602505)]
538 interface nsINavHistoryResultTreeViewer : nsINavHistoryResultViewer
541 * This allows you to get at the real node for a given row index. This is
542 * only valid when a tree is attached.
544 nsINavHistoryResultNode nodeForTreeIndex(in unsigned long aIndex);
547 * Reverse of nodeForFlatIndex, returns the row index for a given result node.
548 * Returns INDEX_INVISIBLE if the item is not visible (for example, its
549 * parent is collapsed). This is only valid when a tree is attached. The
550 * the result will always be INDEX_INVISIBLE if not.
552 * Note: This sounds sort of obvious, but it got me: aNode must be a node
553 * retrieved from the same result that this viewer is for. If you
554 * execute another query and get a node from a _different_ result, this
555 * function will always return the index of that node in the tree that
556 * is attached to that result.
558 const unsigned long INDEX_INVISIBLE = 0xffffffff;
559 unsigned long treeIndexForNode(in nsINavHistoryResultNode aNode);
564 * The result of a history/bookmark query.
566 * Use the "root" element to access the children of this query.
568 * The basic design of the system is a model-view-controller. This result object
569 * represents the model where the data is stored. External components
570 * provide the view and controller which define how the data looks and how
571 * interaction happens.
572 * [RESULT]----->[viewer]----->[controller]
574 * +-- nsINavHistoryResultViewer
576 * The result indicates to the view when something changes through the
577 * nsINavHistoryResultViewer interface. The viewer is set through
578 * the nsINavHistoryResult.viewer property.
581 [scriptable, uuid(d1562f6f-8d5a-4042-8524-72f747a51b18)]
582 interface nsINavHistoryResult : nsISupports
585 * Sorts all nodes recursively by the given parameter, one of
586 * nsINavHistoryQueryOptions.SORT_BY_* This will update the corresponding
587 * options for this result, so that re-using the current options/queries will
588 * always give you the current view.
590 attribute unsigned short sortingMode;
593 * The annotation to use in SORT_BY_ANNOTATION_* sorting modes, set this
594 * before setting the sortingMode attribute.
596 attribute AUTF8String sortingAnnotation;
599 * The viewer for this result (see comment for the class for how these
600 * objects are related). This may be null, in which case you can still
601 * manually walk the tree using the root node. When this is non-null, you
602 * can access the flattened list of items (flatItemCount, nodeForFlatIndex,
603 * flatIndexForNode).
605 attribute nsINavHistoryResultViewer viewer;
608 * This is the root of the results. Remember that you need to open all
609 * containers for their contents to be valid.
611 readonly attribute nsINavHistoryContainerResultNode root;
616 * Similar to nsIRDFObserver for history. Note that we don't pass the data
617 * source since that is always the global history.
619 * DANGER! If you are in the middle of a batch transaction, there may be a
620 * database transaction active. You can still access the DB, but be careful.
622 [scriptable, uuid(eacb76eb-3eeb-419b-a963-9b3a9d65f356)]
623 interface nsINavHistoryObserver : nsISupports
626 * Notifies you that a bunch of things are about to change, don't do any
627 * heavy-duty processing until onEndUpdateBatch is called.
629 void onBeginUpdateBatch();
632 * Notifies you that we are done doing a bunch of things and you should go
633 * ahead and update UI, etc.
635 void onEndUpdateBatch();
638 * Called when a resource is visited. This is called the first time a
639 * resource (page, image, etc.) is seen as well as every subsequent time.
641 * Normally, transition types of TRANSITION_EMBED (corresponding to images in
642 * a page, for example) are not displayed in history results (unless
643 * includeHidden is set). Many observers can ignore _EMBED notifications
644 * (which will comprise the majority of visit notifications) to save work.
646 * @param aVisitID ID of the visit that was just created.
647 * @param aTime Time of the visit
648 * @param aSessionID The ID of one connected sequence of visits.
649 * @param aReferringID The ID of the visit the user came from. 0 if empty.
650 * @param aTransitionType One of nsINavHistory.TRANSITION_*
651 * @param aAdded Incremented by query nodes when the visited uri
652 * belongs to them. If no such query exists, the
653 * history result creates a new query node dynamically.
654 * It is used in places views only and can be ignored.
656 void onVisit(in nsIURI aURI, in long long aVisitID, in PRTime aTime,
657 in long long aSessionID, in long long aReferringID,
658 in unsigned long aTransitionType, out unsigned long aAdded);
661 * Called whenever either the "real" title or the custom title of the page
662 * changed. BOTH TITLES ARE ALWAYS INCLUDED in this notification, even though
663 * only one will change at a time. Often, consumers will want to display the
664 * user title if it is available, and fall back to the page title (the one
665 * specified in the <title> tag of the page).
667 * Note that there is a difference between an empty title and a NULL title.
668 * An empty string means that somebody specifically set the title to be
669 * nothing. NULL means nobody set it. From C++: use IsVoid() and SetIsVoid()
670 * to see whether an empty string is "null" or not (it will always be an
671 * empty string in either case).
674 void onTitleChanged(in nsIURI aURI, in AString aPageTitle);
677 * This page and all of its visits are being deleted. Note: the page may not
678 * necessarily have actually existed for this function to be called.
680 * Delete notifications are only 99.99% accurate. Batch delete operations
681 * must be done in two steps, so first come notifications, then a bulk
682 * delete. If there is some error in the middle (for example, out of memory)
683 * then you'll get a notification and it won't get deleted. There's no easy
684 * way around this.
686 void onDeleteURI(in nsIURI aURI);
689 * Notification that all of history is being deleted.
691 void onClearHistory();
694 * A page has had some attribute on it changed. Note that for TYPED and
695 * HIDDEN, the page may not necessarily have been added yet.
697 const unsigned long ATTRIBUTE_FAVICON = 3; // favicon updated, aString = favicon annotation URI
698 void onPageChanged(in nsIURI aURI, in unsigned long aWhat, in AString aValue);
701 * Called when a history entry expires. You will recieve notifications that
702 * a specific visit has expired with the time of that visit. When the last
703 * visit for a history entry expires, the history entry itself is deleted
704 * and aWholeEntry is set. (If your observer only cares about URLs and not
705 * specific visits, it needs only to listen for aWholeEntry notifications).
707 * It is possible for a history entry to be deleted that has no visits if
708 * something is out of sync or after a bookmark is deleted that has no
709 * visits (thus freeing the history entry). In these cases, aVisitTime will
710 * be 0.
712 void onPageExpired(in nsIURI aURI, in PRTime aVisitTime, in boolean aWholeEntry);
717 * This object encapsulates all the query parameters you're likely to need
718 * when building up history UI. All parameters are ANDed together.
720 * This is not intended to be a super-general query mechanism. This was designed
721 * so that most queries can be done in only one SQL query. This is important
722 * because, if the user has their profile on a networked drive, query latency
723 * can be non-negligible.
726 [scriptable, uuid(53B51AFE-9DE8-40AD-9C81-F2CC1701F1FF)]
727 interface nsINavHistoryQuery : nsISupports
730 * Time range for results (INCLUSIVE). The *TimeReference is one of the
731 * constants TIME_RELATIVE_* which indicates how to interpret the
732 * corresponding time value.
733 * TIME_RELATIVE_EPOCH (default):
734 * The time is relative to Jan 1 1970 GMT, (this is a normal PRTime)
735 * TIME_RELATIVE_TODAY:
736 * The time is relative to this morning at midnight. Normally used for
737 * queries relative to today. For example, a "past week" query would be
738 * today-6 days -> today+1 day
739 * TIME_RELATIVE_NOW:
740 * The time is relative to right now.
742 * Note: PRTime is in MICROseconds since 1 Jan 1970. Javascript date objects
743 * are expressed in MILLIseconds since 1 Jan 1970.
745 * As a special case, a 0 time relative to TIME_RELATIVE_EPOCH indicates that
746 * the time is not part of the query. This is the default, so an empty query
747 * will match any time. The has* functions return whether the corresponding
748 * time is considered.
750 * You can read absolute*Time to get the time value that the currently loaded
751 * reference points + offset resolve to.
753 const unsigned long TIME_RELATIVE_EPOCH = 0;
754 const unsigned long TIME_RELATIVE_TODAY = 1;
755 const unsigned long TIME_RELATIVE_NOW = 2;
757 attribute PRTime beginTime;
758 attribute unsigned long beginTimeReference;
759 readonly attribute boolean hasBeginTime;
760 readonly attribute PRTime absoluteBeginTime;
762 attribute PRTime endTime;
763 attribute unsigned long endTimeReference;
764 readonly attribute boolean hasEndTime;
765 readonly attribute PRTime absoluteEndTime;
768 * Text search terms.
770 attribute AString searchTerms;
771 readonly attribute boolean hasSearchTerms;
774 * Set lower or upper limits for how many times an item has been
775 * visited. The default is -1, and in that case all items are
776 * matched regardless of their visit count.
778 attribute long minVisits;
779 attribute long maxVisits;
782 * When set, returns only bookmarked items, when unset, returns anything. Setting this
783 * is equivalent to listing all bookmark folders in the 'folders' parameter.
785 attribute boolean onlyBookmarked;
788 * This controls the meaning of 'domain', and whether it is an exact match
789 * 'domainIsHost' = true, or hierarchical (= false).
791 attribute boolean domainIsHost;
794 * This is the host or domain name (controlled by domainIsHost). When
795 * domainIsHost, domain only does exact matching on host names. Otherwise,
796 * it will return anything whose host name ends in 'domain'.
798 * This one is a little different than most. Setting it to an empty string
799 * is a real query and will match any URI that has no host name (local files
800 * and such). Set this to NULL (in C++ use SetIsVoid) if you don't want
801 * domain matching.
803 attribute AUTF8String domain;
804 readonly attribute boolean hasDomain;
807 * Controls the interpretation of 'uri'. When unset (default), the URI will
808 * request an exact match of the specified URI. When set, any history entry
809 * beginning in 'uri' will match. For example "http://bar.com/foo" will match
810 * "http://bar.com/foo" as well as "http://bar.com/foo/baz.gif".
812 attribute boolean uriIsPrefix;
815 * This is a URI to match, to, for example, find out every time you visited
816 * a given URI. Use uriIsPrefix to control whether this is an exact match.
818 attribute nsIURI uri;
819 readonly attribute boolean hasUri;
822 * Test for existance or non-existance of a given annotation. We don't
823 * currently support >1 annotation name per query. If 'annotationIsNot' is
824 * true, we test for the non-existance of the specified annotation.
826 * Testing for not annotation will do the same thing as a normal query and
827 * remove everything that doesn't have that annotation. Asking for things
828 * that DO have a given annotation is a little different. It also includes
829 * things that have never been visited. This allows place queries to be
830 * returned as well as anything else that may have been tagged with an
831 * annotation. This will only work for RESULTS_AS_URI since there will be
832 * no visits for these items.
834 attribute boolean annotationIsNot;
835 attribute AUTF8String annotation;
836 readonly attribute boolean hasAnnotation;
839 * Limit results to items that are in all of the given folders.
841 void getFolders(out unsigned long count,
842 [retval,array,size_is(count)] out long long folders);
843 readonly attribute unsigned long folderCount;
846 * For the special result type RESULTS_AS_TAG_CONTENTS we can define only
847 * one folder that must be a tag folder. This is not recursive so results
848 * will be returned from the first level of that folder.
850 void setFolders([const,array, size_is(folderCount)] in long long folders,
851 in unsigned long folderCount);
854 * Creates a new query item with the same parameters of this one.
856 nsINavHistoryQuery clone();
860 * This object represents the global options for executing a query.
862 [scriptable, uuid(a46c132e-35f3-4e1e-bb3d-4e3043657248)]
863 interface nsINavHistoryQueryOptions : nsISupports
866 * You can ask for the results to be pre-sorted. Since the DB has indices
867 * of many items, it can produce sorted results almost for free. These should
868 * be self-explanatory.
870 * Note: re-sorting is slower, as is sorting by title or when you have a
871 * host name.
873 * For bookmark items, SORT_BY_NONE means sort by the natural bookmark order.
875 const unsigned short SORT_BY_NONE = 0;
876 const unsigned short SORT_BY_TITLE_ASCENDING = 1;
877 const unsigned short SORT_BY_TITLE_DESCENDING = 2;
878 const unsigned short SORT_BY_DATE_ASCENDING = 3;
879 const unsigned short SORT_BY_DATE_DESCENDING = 4;
880 const unsigned short SORT_BY_URI_ASCENDING = 5;
881 const unsigned short SORT_BY_URI_DESCENDING = 6;
882 const unsigned short SORT_BY_VISITCOUNT_ASCENDING = 7;
883 const unsigned short SORT_BY_VISITCOUNT_DESCENDING = 8;
884 const unsigned short SORT_BY_KEYWORD_ASCENDING = 9;
885 const unsigned short SORT_BY_KEYWORD_DESCENDING = 10;
886 const unsigned short SORT_BY_DATEADDED_ASCENDING = 11;
887 const unsigned short SORT_BY_DATEADDED_DESCENDING = 12;
888 const unsigned short SORT_BY_LASTMODIFIED_ASCENDING = 13;
889 const unsigned short SORT_BY_LASTMODIFIED_DESCENDING = 14;
890 const unsigned short SORT_BY_TAGS_ASCENDING = 17;
891 const unsigned short SORT_BY_TAGS_DESCENDING = 18;
892 const unsigned short SORT_BY_ANNOTATION_ASCENDING = 19;
893 const unsigned short SORT_BY_ANNOTATION_DESCENDING = 20;
897 * "URI" results, one for each URI visited in the range. Individual result
898 * nodes will be of type "URI".
900 const unsigned short RESULTS_AS_URI = 0;
903 * "Visit" results, with one for each time a page was visited (this will
904 * often give you multiple results for one URI). Individual result nodes will
905 * have type "Visit"
907 const unsigned short RESULTS_AS_VISIT = 1;
910 * This is identical to RESULT_TYPE_VISIT except that individual result nodes
911 * will have type "FullVisit". This is used for the attributes that are not
912 * commonly accessed to save space in the common case (the lists can be very
913 * long).
915 const unsigned short RESULTS_AS_FULL_VISIT = 2;
918 * This returns query nodes for each predefined date range where we
919 * had visits. The node contains information how to load its content:
920 * - visits for the given date range will be loaded.
922 const unsigned short RESULTS_AS_DATE_QUERY = 3;
925 * This returns nsINavHistoryQueryResultNode nodes for each site where we
926 * have visits. The node contains information how to load its content:
927 * - last visit for each url in the given host will be loaded.
929 const unsigned short RESULTS_AS_SITE_QUERY = 4;
932 * This returns nsINavHistoryQueryResultNode nodes for each day where we
933 * have visits. The node contains information how to load its content:
934 * - list of hosts visited in the given period will be loaded.
936 const unsigned short RESULTS_AS_DATE_SITE_QUERY = 5;
939 * This returns nsINavHistoryQueryResultNode nodes for each tag.
940 * The node contains information how to load its content:
941 * - list of bookmarks with the given tag will be loaded.
942 * Setting this resultType will force queryType to QUERY_TYPE_BOOKMARKS.
944 const unsigned short RESULTS_AS_TAG_QUERY = 6;
947 * This is a container with an URI result type that contains the last
948 * modified bookmarks for the given tag.
949 * Tag folder id must be defined in the query.
950 * Setting this resultType will force queryType to QUERY_TYPE_BOOKMARKS.
952 const unsigned short RESULTS_AS_TAG_CONTENTS = 7;
955 * The sorting mode to be used for this query.
956 * mode is one of SORT_BY_*
958 attribute unsigned short sortingMode;
961 * The annotation to use in SORT_BY_ANNOTATION_* sorting modes.
963 attribute AUTF8String sortingAnnotation;
966 * Sets the result type. One of RESULT_TYPE_* which includes how URIs are
967 * represented.
969 attribute unsigned short resultType;
972 * This option excludes all URIs and separators from a bookmarks query.
973 * This would be used if you just wanted a list of bookmark folders and
974 * queries (such as the left pane of the places page).
975 * Ignored for queries over history. Defaults to false.
977 attribute boolean excludeItems;
980 * Set to true to exclude queries ("place:" URIs) from the query results.
981 * Simple folder queries (bookmark folder symlinks) will still be included.
982 * Defaults to false.
984 attribute boolean excludeQueries;
987 * Set to true to exclude read-only folders from the query results. This is
988 * designed for cases where you want to give the user the option of filing
989 * something into a list of folders. It only affects cases where the actual
990 * folder result node would appear in its parent folder and filters it out.
991 * It doesn't affect the query at all, and doesn't affect more complex
992 * queries (such as "folders with annotation X").
994 attribute boolean excludeReadOnlyFolders;
997 * This option excludes items from a bookmarks query
998 * if the parent of the item has this annotation.
999 * An example is to exclude livemark items
1000 * (parent folders have the "livemark/feedURI" annotation)
1001 * Ignored for queries over history.
1003 attribute AUTF8String excludeItemIfParentHasAnnotation;
1006 * When set, allows items with "place:" URIs to appear as containers,
1007 * with the container's contents filled in from the stored query.
1008 * If not set, these will appear as normal items. Doesn't do anything if
1009 * excludeQueries is set. Defaults to false.
1011 * Note that this has no effect on folder links, which are place: URIs
1012 * returned by nsINavBookmarkService.GetFolderURI. These are always expanded
1013 * and will appear as bookmark folders.
1015 attribute boolean expandQueries;
1018 * Most items in history are marked "hidden." Only toplevel pages that the
1019 * user sees in the URL bar are not hidden. Hidden things include the content
1020 * of iframes and all images on web pages. Normally, you don't want these
1021 * things. If you do, set this flag and you'll get all items, even hidden
1022 * ones. Does nothing for bookmark queries. Defaults to false.
1024 attribute boolean includeHidden;
1027 * Separate/group history items based on session information. Only
1028 * matters when sorting by date.
1030 attribute boolean showSessions;
1033 * This is the maximum number of results that you want. The query is exeucted,
1034 * the results are sorted, and then the top 'maxResults' results are taken
1035 * and returned. Set to 0 (the default) to get all results.
1037 * THIS DOES NOT WORK IN CONJUNCTION WITH SORTING BY TITLE. This is because
1038 * sorting by title requires us to sort after using locale-sensetive sorting
1039 * (as opposed to letting the database do it for us).
1041 * Instead, we get the result ordered by date, pick the maxResult most recent
1042 * ones, and THEN sort by title.
1044 attribute unsigned long maxResults;
1046 const unsigned short QUERY_TYPE_HISTORY = 0;
1047 const unsigned short QUERY_TYPE_BOOKMARKS = 1;
1048 const unsigned short QUERY_TYPE_UNIFIED = 2;
1051 * The type of search to use when querying the DB; This attribute is only
1052 * honored by query nodes. It is silently ignored for simple folder queries.
1054 attribute unsigned short queryType;
1057 * Creates a new options item with the same parameters of this one.
1059 nsINavHistoryQueryOptions clone();
1062 [scriptable, uuid(437f539b-d541-4a0f-a200-6f9a6d45cce2)]
1063 interface nsINavHistoryService : nsISupports
1066 * This transition type means the user followed a link and got a new toplevel
1067 * window.
1069 const unsigned long TRANSITION_LINK = 1;
1072 * This transition type means that the user typed the page's URL in the
1073 * URL bar or selected it from URL bar autocomplete results, clicked on
1074 * it from a history query (from the History sidebar, History menu,
1075 * or history query in the personal toolbar or Places organizer.
1077 const unsigned long TRANSITION_TYPED = 2;
1080 * This transition is set when the user followed a bookmark to get to the
1081 * page.
1083 const unsigned long TRANSITION_BOOKMARK = 3;
1086 * This transition type is set when some inner content is loaded. This is
1087 * true of all images on a page, and the contents of the iframe. It is also
1088 * true of any content in a frame, regardless if whether or not the user
1089 * clicked something to get there.
1091 const unsigned long TRANSITION_EMBED = 4;
1094 * Set when the transition was a permanent redirect.
1096 const unsigned long TRANSITION_REDIRECT_PERMANENT = 5;
1099 * Set when the transition was a temporary redirect.
1101 const unsigned long TRANSITION_REDIRECT_TEMPORARY = 6;
1104 * Set when the transition is a download.
1106 const unsigned long TRANSITION_DOWNLOAD = 7;
1109 * Set when database is coherent
1111 const unsigned short DATABASE_STATUS_OK = 0;
1114 * Set when database did not exist and we created a new one
1116 const unsigned short DATABASE_STATUS_CREATE = 1;
1119 * Set when database was corrupt and we replaced it
1121 const unsigned short DATABASE_STATUS_CORRUPT = 2;
1124 * Returns the current database status
1126 readonly attribute unsigned short databaseStatus;
1129 * True if there is any history. This can be used in UI to determine whether
1130 * the "clear history" button should be enabled or not. This is much better
1131 * than using BrowserHistory.count since that can be very slow if there is
1132 * a lot of history (it must enumerate each item). This is pretty fast.
1134 readonly attribute boolean hasHistoryEntries;
1137 * Gets the original title of the page.
1139 AString getPageTitle(in nsIURI aURI);
1142 * This is just like markPageAsTyped (in nsIBrowserHistory, also implemented
1143 * by the history service), but for bookmarks. It declares that the given URI
1144 * is being opened as a result of following a bookmark. If this URI is loaded
1145 * soon after this message has been received, that transition will be marked
1146 * as following a bookmark.
1148 void markPageAsFollowedBookmark(in nsIURI aURI);
1151 * Gets the stored character-set for an URI.
1153 * @param aURI
1154 * URI to retrieve character-set for
1155 * @returns character-set, empty string if not found
1157 AString getCharsetForURI(in nsIURI aURI);
1160 * Sets the character-set for an URI.
1162 * @param aURI
1163 * URI to set the character-set for
1164 * @param aCharset
1165 * character-set to be set
1167 void setCharsetForURI(in nsIURI aURI, in AString aCharset);
1170 * Returns true if this URI would be added to the history. You don't have to
1171 * worry about calling this, addPageToSession/addURI will always check before
1172 * actually adding the page. This function is public because some components
1173 * may want to check if this page would go in the history (i.e. for
1174 * annotations).
1176 boolean canAddURI(in nsIURI aURI);
1179 * Call to manually add a visit for a specific page. This will probably not
1180 * be commonly used other than for backup/restore type operations. If the URI
1181 * does not have an entry in the history database already, one will be created
1182 * with no visits, no title, hidden, not typed. Adding a visit will
1183 * automatically increment the visit count for the visited page and will unhide
1184 * it and/or mark it typed according to the transition type.
1186 * @param aURI Visited page
1187 * @param aTime Time page was visited (microseconds)
1188 * @param aReferringURI The URI of the visit that generated this one. Use
1189 * null for no referrer.
1190 * @param aTranstitionType Type of transition: one of TRANSITION_* above
1191 * @param aIsRedirect True if the given visit redirects to somewhere else.
1192 * (ie you will create an visit out of here that is a
1193 * redirect transition). This causes this page to be
1194 * hidden in normal history views (unless it has been
1195 * unhidden by visiting it with a non-redirect).
1196 * @param aSessionID The session ID that this page belongs to. Use 0 for
1197 * no session.
1198 * @returns The ID of the created visit. This will be 0 if the URI is not
1199 * valid for adding to history (canAddURI = false).
1201 long long addVisit(in nsIURI aURI, in PRTime aTime,
1202 in nsIURI aReferringURI, in long aTransitionType,
1203 in boolean aIsRedirect, in long long aSessionID);
1206 * This returns a new query object that you can pass to executeQuer[y/ies].
1207 * It will be initialized to all empty (so using it will give you all history).
1209 nsINavHistoryQuery getNewQuery();
1212 * This returns a new options object that you can pass to executeQuer[y/ies]
1213 * after setting the desired options.
1215 nsINavHistoryQueryOptions getNewQueryOptions();
1218 * Executes a single query.
1220 nsINavHistoryResult executeQuery(in nsINavHistoryQuery aQuery,
1221 in nsINavHistoryQueryOptions options);
1224 * Executes an array of queries. All of the query objects are ORed
1225 * together. Within a query, all the terms are ANDed together as in
1226 * executeQuery. See executeQuery()
1228 nsINavHistoryResult executeQueries(
1229 [array,size_is(aQueryCount)] in nsINavHistoryQuery aQueries,
1230 in unsigned long aQueryCount,
1231 in nsINavHistoryQueryOptions options);
1234 * Converts a query URI-like string to an array of actual query objects for
1235 * use to executeQueries(). The output query array may be empty if there is
1236 * no information. However, there will always be an options structure returned
1237 * (if nothing is defined, it will just have the default values).
1239 void queryStringToQueries(in AUTF8String aQueryString,
1240 [array, size_is(aResultCount)] out nsINavHistoryQuery aQueries,
1241 out unsigned long aResultCount,
1242 out nsINavHistoryQueryOptions options);
1245 * Converts a query into an equivalent string that can be persisted. Inverse
1246 * of queryStringToQueries()
1248 AUTF8String queriesToQueryString(
1249 [array, size_is(aQueryCount)] in nsINavHistoryQuery aQueries,
1250 in unsigned long aQueryCount,
1251 in nsINavHistoryQueryOptions options);
1254 * Adds a history observer. If ownsWeak is false, the history service will
1255 * keep an owning reference to the observer. If ownsWeak is true, then
1256 * aObserver must implement nsISupportsWeakReference, and the history service
1257 * will keep a weak reference to the observer.
1259 void addObserver(in nsINavHistoryObserver observer, in boolean ownsWeak);
1262 * Removes a history observer.
1264 void removeObserver(in nsINavHistoryObserver observer);
1267 * Runs the passed callback in batch mode. Use this when a lot of things
1268 * are about to change. Calls can be nested, observers will only be
1269 * notified when all batches begin/end.
1271 * @param aCallback
1272 * nsINavHistoryBatchCallback interface to call.
1273 * @param aUserData
1274 * Opaque parameter passed to nsINavBookmarksBatchCallback
1276 void runInBatchMode(in nsINavHistoryBatchCallback aCallback,
1277 in nsISupports aClosure);
1279 /**
1280 * True if history is disabled. currently,
1281 * history is disabled if the browser.history_expire_days pref is 0
1283 readonly attribute boolean historyDisabled;
1286 * Import the given Mork history file.
1287 * @param file The Mork history file to import
1289 void importHistory(in nsIFile file);
1293 * @see runInBatchMode of nsINavHistoryService/nsINavBookmarksService
1295 [scriptable, uuid(5143f2bb-be0a-4faf-9acb-b0ed3f82952c)]
1296 interface nsINavHistoryBatchCallback : nsISupports {
1297 void runBatched(in nsISupports aUserData);