Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_IHistory_h_
8
#define mozilla_IHistory_h_
9
10
#include "nsISupports.h"
11
#include "nsDataHashtable.h"
12
#include "nsURIHashKey.h"
13
#include "nsTObserverArray.h"
14
15
class nsIURI;
16
class nsIWidget;
17
18
namespace mozilla {
19
20
namespace dom {
21
class Document;
22
class Link;
23
} // namespace dom
24
25
// 0057c9d3-b98e-4933-bdc5-0275d06705e1
26
#define IHISTORY_IID \
27
{ \
28
0x0057c9d3, 0xb98e, 0x4933, { \
29
0xbd, 0xc5, 0x02, 0x75, 0xd0, 0x67, 0x05, 0xe1 \
30
} \
31
}
32
33
class IHistory : public nsISupports {
34
public:
35
NS_DECLARE_STATIC_IID_ACCESSOR(IHISTORY_IID)
36
37
/**
38
* Registers the Link for notifications about the visited-ness of aURI.
39
* Consumers should assume that the URI is unvisited after calling this, and
40
* they will be notified if that state (unvisited) changes by having
41
* SetLinkState called on themselves. This function is guaranteed to run to
42
* completion before aLink is notified. After the node is notified, it will
43
* be unregistered.
44
*
45
* @note SetLinkState must not call RegisterVisitedCallback or
46
* UnregisterVisitedCallback.
47
*
48
* @pre aURI must not be null.
49
* @pre aLink may be null only in the parent (chrome) process.
50
*
51
* @param aURI
52
* The URI to check.
53
* @param aLink
54
* The link to update whenever the history status changes. The
55
* implementation will only hold onto a raw pointer, so if this
56
* object should be destroyed, be sure to call
57
* UnregisterVistedCallback first.
58
*/
59
virtual nsresult RegisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
60
61
/**
62
* Unregisters a previously registered Link object. This must be called
63
* before destroying the registered object, and asserts when misused.
64
*
65
* @pre aURI must not be null.
66
* @pre aLink must not be null.
67
*
68
* @param aURI
69
* The URI that aLink was registered for.
70
* @param aLink
71
* The link object to unregister for aURI.
72
*/
73
virtual void UnregisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
74
75
enum class VisitedStatus : uint8_t {
76
Unknown,
77
Visited,
78
Unvisited,
79
};
80
81
/**
82
* Notifies about the visited status of a given URI. The visited status cannot
83
* be unknown, otherwise there's no point in notifying of anything.
84
*/
85
virtual void NotifyVisited(nsIURI*, VisitedStatus) = 0;
86
87
enum VisitFlags {
88
/**
89
* Indicates whether the URI was loaded in a top-level window.
90
*/
91
TOP_LEVEL = 1 << 0,
92
/**
93
* Indicates whether the URI is the target of a permanent redirect.
94
*/
95
REDIRECT_PERMANENT = 1 << 1,
96
/**
97
* Indicates whether the URI is the target of a temporary redirect.
98
*/
99
REDIRECT_TEMPORARY = 1 << 2,
100
/**
101
* Indicates the URI will redirect (Response code 3xx).
102
*/
103
REDIRECT_SOURCE = 1 << 3,
104
/**
105
* Indicates the URI caused an error that is unlikely fixable by a
106
* retry, like a not found or unfetchable page.
107
*/
108
UNRECOVERABLE_ERROR = 1 << 4,
109
/**
110
* If REDIRECT_SOURCE is set, this indicates that the redirect is permanent.
111
* Note this differs from REDIRECT_PERMANENT because that one refers to how
112
* we reached the URI, while this is used when the URI itself redirects.
113
*/
114
REDIRECT_SOURCE_PERMANENT = 1 << 5
115
};
116
117
/**
118
* Adds a history visit for the URI.
119
*
120
* @pre aURI must not be null.
121
*
122
* @param aWidget
123
* The widget for the DocShell.
124
* @param aURI
125
* The URI of the page being visited.
126
* @param aLastVisitedURI
127
* The URI of the last visit in the chain.
128
* @param aFlags
129
* The VisitFlags describing this visit.
130
*/
131
NS_IMETHOD VisitURI(nsIWidget* aWidget, nsIURI* aURI, nsIURI* aLastVisitedURI,
132
uint32_t aFlags) = 0;
133
134
/**
135
* Set the title of the URI.
136
*
137
* @pre aURI must not be null.
138
*
139
* @param aURI
140
* The URI to set the title for.
141
* @param aTitle
142
* The title string.
143
*/
144
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
145
};
146
147
NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
148
149
} // namespace mozilla
150
151
#endif // mozilla_IHistory_h_