michael@0: /* -*- Mode: C++; tab-width: 2; 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 nsISHEntry; michael@0: interface nsISHistoryListener; michael@0: interface nsISimpleEnumerator; michael@0: /** michael@0: * An interface to the primary properties of the Session History michael@0: * component. In an embedded browser environment, the nsIWebBrowser michael@0: * object creates an instance of session history for each open window. michael@0: * A handle to the session history object can be obtained from michael@0: * nsIWebNavigation. In a non-embedded situation, the owner of the michael@0: * session history component must create a instance of it and set michael@0: * it in the nsIWebNavigation object. michael@0: * This interface is accessible from javascript. michael@0: */ michael@0: michael@0: michael@0: %{C++ michael@0: #define NS_SHISTORY_CID \ michael@0: {0x7b807041, 0xe60a, 0x4384, {0x93, 0x5f, 0xaf, 0x30, 0x61, 0xd8, 0xb8, 0x15}} michael@0: michael@0: #define NS_SHISTORY_CONTRACTID "@mozilla.org/browser/shistory;1" michael@0: %} michael@0: michael@0: [scriptable, uuid(7b807041-e60a-4384-935f-af3061d8b815)] michael@0: interface nsISHistory: nsISupports michael@0: { michael@0: /** michael@0: * A readonly property of the interface that returns michael@0: * the number of toplevel documents currently available michael@0: * in session history. michael@0: */ michael@0: readonly attribute long count; michael@0: michael@0: /** michael@0: * A readonly property of the interface that returns michael@0: * the index of the current document in session history. michael@0: */ michael@0: readonly attribute long index; michael@0: michael@0: /** michael@0: * A readonly property of the interface that returns michael@0: * the index of the last document that started to load and michael@0: * didn't finished yet. When document finishes the loading michael@0: * value -1 is returned. michael@0: */ michael@0: readonly attribute long requestedIndex; michael@0: michael@0: /** michael@0: * A read/write property of the interface, used to Get/Set michael@0: * the maximum number of toplevel documents, session history michael@0: * can hold for each instance. michael@0: */ michael@0: attribute long maxLength; michael@0: michael@0: /** michael@0: * Called to obtain handle to the history entry at a michael@0: * given index. michael@0: * michael@0: * @param index The index value whose entry is requested. michael@0: * The oldest entry is located at index == 0. michael@0: * @param modifyIndex A boolean flag that indicates if the current michael@0: * index of session history should be modified michael@0: * to the parameter index. michael@0: * michael@0: * @return NS_OK history entry for michael@0: * the index is obtained successfully. michael@0: * NS_ERROR_FAILURE Error in obtaining michael@0: * history entry for the given index. michael@0: */ michael@0: nsISHEntry getEntryAtIndex(in long index, in boolean modifyIndex); michael@0: michael@0: michael@0: /** michael@0: * Called to purge older documents from history. michael@0: * Documents can be removed from session history for various michael@0: * reasons. For example to control memory usage of the browser, to michael@0: * prevent users from loading documents from history, to erase evidence of michael@0: * prior page loads etc... michael@0: * michael@0: * @param numEntries The number of toplevel documents to be michael@0: * purged from history. During purge operation, michael@0: * the latest documents are maintained and older michael@0: * 'numEntries' documents are removed from history. michael@0: * @throws NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA Purge was vetod. michael@0: * @throws NS_ERROR_FAILURE numEntries is michael@0: * invalid or out of bounds with the size of history. michael@0: * michael@0: */ michael@0: void PurgeHistory(in long numEntries); michael@0: michael@0: /** michael@0: * Called to register a listener for the session history component. michael@0: * Listeners are notified when pages are loaded or purged from history. michael@0: * michael@0: * @param aListener Listener object to be notified for all michael@0: * page loads that initiate in session history. michael@0: * michael@0: * @note A listener object must implement michael@0: * nsISHistoryListener and nsSupportsWeakReference michael@0: * michael@0: * @see nsISHistoryListener michael@0: * @see nsSupportsWeakReference michael@0: */ michael@0: void addSHistoryListener(in nsISHistoryListener aListener); michael@0: michael@0: /** michael@0: * Called to remove a listener for the session history component. michael@0: * Listeners are notified when pages are loaded from history. michael@0: * michael@0: * @param aListener Listener object to be removed from michael@0: * session history. michael@0: * michael@0: * @note A listener object must implement michael@0: * nsISHistoryListener and nsSupportsWeakReference michael@0: * @see nsISHistoryListener michael@0: * @see nsSupportsWeakReference michael@0: */ michael@0: void removeSHistoryListener(in nsISHistoryListener aListener); michael@0: michael@0: /** michael@0: * Called to obtain a enumerator for all the documents stored in michael@0: * session history. The enumerator object thus returned by this method michael@0: * can be traversed using nsISimpleEnumerator. michael@0: * michael@0: * @note To access individual history entries of the enumerator, perform the michael@0: * following steps: michael@0: * 1) Call nsISHistory->GetSHistoryEnumerator() to obtain handle michael@0: * the nsISimpleEnumerator object. michael@0: * 2) Use nsISimpleEnumerator->GetNext() on the object returned michael@0: * by step #1 to obtain handle to the next object in the list. michael@0: * The object returned by this step is of type nsISupports. michael@0: * 3) Perform a QueryInterface on the object returned by step #2 michael@0: * to nsISHEntry. michael@0: * 4) Use nsISHEntry to access properties of each history entry. michael@0: * michael@0: * @see nsISimpleEnumerator michael@0: * @see nsISHEntry michael@0: * @see QueryInterface() michael@0: * @see do_QueryInterface() michael@0: */ michael@0: readonly attribute nsISimpleEnumerator SHistoryEnumerator; michael@0: michael@0: void reloadCurrentEntry(); michael@0: michael@0: /** michael@0: * Called to obtain the index to a given history entry. michael@0: * michael@0: * @param aEntry The entry to obtain the index of. michael@0: * michael@0: * @return NS_OK index for the history entry michael@0: * is obtained successfully. michael@0: * NS_ERROR_FAILURE Error in obtaining michael@0: * index for the given history entry. michael@0: */ michael@0: long getIndexOfEntry(in nsISHEntry aEntry); michael@0: };