docshell/base/IHistory.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/base/IHistory.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,146 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=4 sw=4 et tw=80:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_IHistory_h_
    1.11 +#define mozilla_IHistory_h_
    1.12 +
    1.13 +#include "nsISupports.h"
    1.14 +
    1.15 +class nsIURI;
    1.16 +class nsString;
    1.17 +
    1.18 +namespace mozilla {
    1.19 +
    1.20 +    namespace dom {
    1.21 +        class Link;
    1.22 +    }
    1.23 +
    1.24 +// 0057c9d3-b98e-4933-bdc5-0275d06705e1
    1.25 +#define IHISTORY_IID \
    1.26 +  {0x0057c9d3, 0xb98e, 0x4933, {0xbd, 0xc5, 0x02, 0x75, 0xd0, 0x67, 0x05, 0xe1}}
    1.27 +
    1.28 +class IHistory : public nsISupports
    1.29 +{
    1.30 +public:
    1.31 +    NS_DECLARE_STATIC_IID_ACCESSOR(IHISTORY_IID)
    1.32 +
    1.33 +    /**
    1.34 +     * Registers the Link for notifications about the visited-ness of aURI.
    1.35 +     * Consumers should assume that the URI is unvisited after calling this, and
    1.36 +     * they will be notified if that state (unvisited) changes by having
    1.37 +     * SetLinkState called on themselves.  This function is guaranteed to run to
    1.38 +     * completion before aLink is notified.  After the node is notified, it will
    1.39 +     * be unregistered.
    1.40 +     *
    1.41 +     * @note SetLinkState must not call RegisterVisitedCallback or
    1.42 +     *       UnregisterVisitedCallback.
    1.43 +     *
    1.44 +     * @pre aURI must not be null.
    1.45 +     * @pre aLink may be null only in the parent (chrome) process.
    1.46 +     *
    1.47 +     * @param aURI
    1.48 +     *        The URI to check.
    1.49 +     * @param aLink
    1.50 +     *        The link to update whenever the history status changes.  The
    1.51 +     *        implementation will only hold onto a raw pointer, so if this
    1.52 +     *        object should be destroyed, be sure to call
    1.53 +     *        UnregisterVistedCallback first.
    1.54 +     */
    1.55 +    NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, dom::Link *aLink) = 0;
    1.56 +
    1.57 +    /**
    1.58 +     * Unregisters a previously registered Link object.  This must be called
    1.59 +     * before destroying the registered object.
    1.60 +     *
    1.61 +     * @pre aURI must not be null.
    1.62 +     * @pre aLink must not be null.
    1.63 +     *
    1.64 +     * @param aURI
    1.65 +     *        The URI that aLink was registered for.
    1.66 +     * @param aLink
    1.67 +     *        The link object to unregister for aURI.
    1.68 +     */
    1.69 +    NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, dom::Link *aLink) = 0;
    1.70 +
    1.71 +    enum VisitFlags {
    1.72 +        /**
    1.73 +         * Indicates whether the URI was loaded in a top-level window.
    1.74 +         */
    1.75 +        TOP_LEVEL = 1 << 0,
    1.76 +        /**
    1.77 +         * Indicates whether the URI was loaded as part of a permanent redirect.
    1.78 +         */
    1.79 +        REDIRECT_PERMANENT = 1 << 1,
    1.80 +        /**
    1.81 +         * Indicates whether the URI was loaded as part of a temporary redirect.
    1.82 +         */
    1.83 +        REDIRECT_TEMPORARY = 1 << 2,
    1.84 +        /**
    1.85 +         * Indicates the URI is redirecting  (Response code 3xx).
    1.86 +         */
    1.87 +        REDIRECT_SOURCE = 1 << 3,
    1.88 +        /**
    1.89 +         * Indicates the URI caused an error that is unlikely fixable by a
    1.90 +         * retry, like a not found or unfetchable page.
    1.91 +         */
    1.92 +        UNRECOVERABLE_ERROR = 1 << 4
    1.93 +    };
    1.94 +
    1.95 +    /**
    1.96 +     * Adds a history visit for the URI.
    1.97 +     *
    1.98 +     * @pre aURI must not be null.
    1.99 +     *
   1.100 +     * @param aURI
   1.101 +     *        The URI of the page being visited.
   1.102 +     * @param aLastVisitedURI
   1.103 +     *        The URI of the last visit in the chain.
   1.104 +     * @param aFlags
   1.105 +     *        The VisitFlags describing this visit.
   1.106 +     */
   1.107 +    NS_IMETHOD VisitURI(
   1.108 +        nsIURI *aURI,
   1.109 +        nsIURI *aLastVisitedURI,
   1.110 +        uint32_t aFlags
   1.111 +    ) = 0;
   1.112 +
   1.113 +    /**
   1.114 +     * Set the title of the URI.
   1.115 +     *
   1.116 +     * @pre aURI must not be null.
   1.117 +     *
   1.118 +     * @param aURI
   1.119 +     *        The URI to set the title for.
   1.120 +     * @param aTitle
   1.121 +     *        The title string.
   1.122 +     */
   1.123 +    NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
   1.124 +
   1.125 +    /**
   1.126 +     * Notifies about the visited status of a given URI.
   1.127 +     *
   1.128 +     * @param aURI
   1.129 +     *        The URI to notify about.
   1.130 +     */
   1.131 +    NS_IMETHOD NotifyVisited(nsIURI* aURI) = 0;
   1.132 +};
   1.133 +
   1.134 +NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
   1.135 +
   1.136 +#define NS_DECL_IHISTORY \
   1.137 +    NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, \
   1.138 +                                       mozilla::dom::Link *aContent); \
   1.139 +    NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, \
   1.140 +                                         mozilla::dom::Link *aContent); \
   1.141 +    NS_IMETHOD VisitURI(nsIURI *aURI, \
   1.142 +                        nsIURI *aLastVisitedURI, \
   1.143 +                        uint32_t aFlags); \
   1.144 +    NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle); \
   1.145 +    NS_IMETHOD NotifyVisited(nsIURI* aURI);
   1.146 +
   1.147 +} // namespace mozilla
   1.148 +
   1.149 +#endif // mozilla_IHistory_h_

mercurial