1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=4 sw=4 et tw=80:
3 : * ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is the mozilla.org code.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Mozilla Foundation.
20 : * Portions created by the Initial Developer are Copyright (C) 2009
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : * Shawn Wilsher <me@shawnwilsher.com> (Original Author)
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either of the GNU General Public License Version 2 or later (the "GPL"),
28 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef mozilla_IHistory_h_
41 : #define mozilla_IHistory_h_
42 :
43 : #include "nsISupports.h"
44 :
45 : class nsIURI;
46 : class nsString;
47 :
48 : namespace mozilla {
49 :
50 : namespace dom {
51 : class Link;
52 : }
53 :
54 : #define IHISTORY_IID \
55 : {0x6f733924, 0x6321, 0x4384, {0x01, 0xee, 0x8e, 0x7d, 0xfb, 0xde, 0xe7, 0xa8}}
56 :
57 : class IHistory : public nsISupports
58 123 : {
59 : public:
60 : NS_DECLARE_STATIC_IID_ACCESSOR(IHISTORY_IID)
61 :
62 : /**
63 : * Registers the Link for notifications about the visited-ness of aURI.
64 : * Consumers should assume that the URI is unvisited after calling this, and
65 : * they will be notified if that state (unvisited) changes by having
66 : * SetLinkState called on themselves. This function is guaranteed to run to
67 : * completion before aLink is notified. After the node is notified, it will
68 : * be unregistered.
69 : *
70 : * @note SetLinkState must not call RegisterVisitedCallback or
71 : * UnregisterVisitedCallback.
72 : *
73 : * @pre aURI must not be null.
74 : * @pre aLink may be null only in the parent (chrome) process.
75 : *
76 : * @param aURI
77 : * The URI to check.
78 : * @param aLink
79 : * The link to update whenever the history status changes. The
80 : * implementation will only hold onto a raw pointer, so if this
81 : * object should be destroyed, be sure to call
82 : * UnregisterVistedCallback first.
83 : */
84 : NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, dom::Link *aLink) = 0;
85 :
86 : /**
87 : * Unregisters a previously registered Link object. This must be called
88 : * before destroying the registered object.
89 : *
90 : * @pre aURI must not be null.
91 : * @pre aLink must not be null.
92 : *
93 : * @param aURI
94 : * The URI that aLink was registered for.
95 : * @param aLink
96 : * The link object to unregister for aURI.
97 : */
98 : NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, dom::Link *aLink) = 0;
99 :
100 : enum VisitFlags {
101 : /**
102 : * Indicates whether the URI was loaded in a top-level window.
103 : */
104 : TOP_LEVEL = 1 << 0,
105 : /**
106 : * Indicates whether the URI was loaded as part of a permanent redirect.
107 : */
108 : REDIRECT_PERMANENT = 1 << 1,
109 : /**
110 : * Indicates whether the URI was loaded as part of a temporary redirect.
111 : */
112 : REDIRECT_TEMPORARY = 1 << 2
113 : };
114 :
115 : /**
116 : * Adds a history visit for the URI.
117 : *
118 : * @pre aURI must not be null.
119 : *
120 : * @param aURI
121 : * The URI of the page being visited.
122 : * @param aLastVisitedURI
123 : * The URI of the last visit in the chain.
124 : * @param aFlags
125 : * The VisitFlags describing this visit.
126 : */
127 : NS_IMETHOD VisitURI(
128 : nsIURI *aURI,
129 : nsIURI *aLastVisitedURI,
130 : PRUint32 aFlags
131 : ) = 0;
132 :
133 : /**
134 : * Set the title of the URI.
135 : *
136 : * @pre aURI must not be null.
137 : *
138 : * @param aURI
139 : * The URI to set the title for.
140 : * @param aTitle
141 : * The title string.
142 : */
143 : NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
144 : };
145 :
146 : NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
147 :
148 : #define NS_DECL_IHISTORY \
149 : NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, \
150 : mozilla::dom::Link *aContent); \
151 : NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, \
152 : mozilla::dom::Link *aContent); \
153 : NS_IMETHOD VisitURI(nsIURI *aURI, \
154 : nsIURI *aLastVisitedURI, \
155 : PRUint32 aFlags); \
156 : NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle);
157 :
158 : } // namespace mozilla
159 :
160 : #endif // mozilla_IHistory_h_
|