2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "PlatformString.h"
35 #import <wtf/RetainPtr.h>
36 typedef struct objc_object
* id
;
51 class ResourceRequest
;
53 typedef Vector
<RefPtr
<HistoryItem
> > HistoryItemVector
;
55 extern void (*notifyHistoryItemChanged
)();
57 class HistoryItem
: public RefCounted
<HistoryItem
> {
58 friend class PageCache
;
61 static PassRefPtr
<HistoryItem
> create() { return adoptRef(new HistoryItem
); }
62 static PassRefPtr
<HistoryItem
> create(const String
& urlString
, const String
& title
, double lastVisited
)
64 return adoptRef(new HistoryItem(urlString
, title
, lastVisited
));
66 static PassRefPtr
<HistoryItem
> create(const String
& urlString
, const String
& title
, const String
& alternateTitle
, double lastVisited
)
68 return adoptRef(new HistoryItem(urlString
, title
, alternateTitle
, lastVisited
));
70 static PassRefPtr
<HistoryItem
> create(const KURL
& url
, const String
& target
, const String
& parent
, const String
& title
)
72 return adoptRef(new HistoryItem(url
, target
, parent
, title
));
77 PassRefPtr
<HistoryItem
> copy() const;
79 const String
& originalURLString() const;
80 const String
& urlString() const;
81 const String
& title() const;
83 void setInPageCache(bool inPageCache
) { m_isInPageCache
= inPageCache
; }
84 bool isInPageCache() const { return m_isInPageCache
; }
86 double lastVisitedTime() const;
88 void setAlternateTitle(const String
& alternateTitle
);
89 const String
& alternateTitle() const;
93 const String
& parent() const;
95 KURL
originalURL() const;
96 const String
& referrer() const;
97 const String
& target() const;
98 bool isTargetItem() const;
100 FormData
* formData();
101 String
formContentType() const;
103 int visitCount() const;
104 bool lastVisitWasFailure() const { return m_lastVisitWasFailure
; }
105 bool lastVisitWasHTTPNonGet() const { return m_lastVisitWasHTTPNonGet
; }
107 void mergeAutoCompleteHints(HistoryItem
* otherItem
);
109 const IntPoint
& scrollPoint() const;
110 void setScrollPoint(const IntPoint
&);
111 void clearScrollPoint();
112 const Vector
<String
>& documentState() const;
113 void setDocumentState(const Vector
<String
>&);
114 void clearDocumentState();
116 void setURL(const KURL
&);
117 void setURLString(const String
&);
118 void setOriginalURLString(const String
&);
119 void setReferrer(const String
&);
120 void setTarget(const String
&);
121 void setParent(const String
&);
122 void setTitle(const String
&);
123 void setIsTargetItem(bool);
125 void setFormInfoFromRequest(const ResourceRequest
&);
127 void recordInitialVisit();
129 void setVisitCount(int);
130 void setLastVisitWasFailure(bool wasFailure
) { m_lastVisitWasFailure
= wasFailure
; }
131 void setLastVisitWasHTTPNonGet(bool wasNotGet
) { m_lastVisitWasHTTPNonGet
= wasNotGet
; }
133 void addChildItem(PassRefPtr
<HistoryItem
>);
134 void setChildItem(PassRefPtr
<HistoryItem
>);
135 HistoryItem
* childItemWithTarget(const String
&) const;
136 HistoryItem
* targetItem();
137 const HistoryItemVector
& children() const;
138 bool hasChildren() const;
140 // This should not be called directly for HistoryItems that are already included
141 // in GlobalHistory. The WebKit api for this is to use -[WebHistory setLastVisitedTimeInterval:forItem:] instead.
142 void setLastVisitedTime(double);
143 void visited(const String
& title
, double time
);
145 void addRedirectURL(const String
&);
146 Vector
<String
>* redirectURLs() const;
147 void setRedirectURLs(std::auto_ptr
<Vector
<String
> >);
149 bool isCurrentDocument(Document
*) const;
152 id
viewState() const;
153 void setViewState(id
);
155 // Transient properties may be of any ObjC type. They are intended to be used to store state per back/forward list entry.
156 // The properties will not be persisted; when the history item is removed, the properties will be lost.
157 id
getTransientProperty(const String
&) const;
158 void setTransientProperty(const String
&, id
);
162 QVariant
userData() const { return m_userData
; }
163 void setUserData(const QVariant
& userData
) { m_userData
= userData
; }
167 int showTree() const;
168 int showTreeWithIndent(unsigned indentLevel
) const;
171 void adoptVisitCounts(Vector
<int>& dailyCounts
, Vector
<int>& weeklyCounts
);
172 const Vector
<int>& dailyVisitCounts() { return m_dailyVisitCounts
; }
173 const Vector
<int>& weeklyVisitCounts() { return m_weeklyVisitCounts
; }
175 float scale() const { return m_scale
; }
176 bool scaleIsInitial() const { return m_scaleIsInitial
; }
177 void setScale(float newScale
, bool isInitial
) { m_scale
= newScale
; m_scaleIsInitial
= isInitial
; }
178 const ViewportArguments
& viewportArguments() const { return m_viewportArguments
; }
179 void setViewportArguments(const ViewportArguments
& newArguments
) { m_viewportArguments
= newArguments
; }
183 HistoryItem(const String
& urlString
, const String
& title
, double lastVisited
);
184 HistoryItem(const String
& urlString
, const String
& title
, const String
& alternateTitle
, double lastVisited
);
185 HistoryItem(const KURL
& url
, const String
& frameName
, const String
& parent
, const String
& title
);
187 HistoryItem(const HistoryItem
&);
189 void padDailyCountsForNewVisit(double time
);
190 void collapseDailyVisitsToWeekly();
191 void recordVisitAtTime(double);
193 HistoryItem
* findTargetItem();
196 String m_originalURLString
;
201 String m_displayTitle
;
203 double m_lastVisitedTime
;
204 bool m_lastVisitWasHTTPNonGet
;
206 IntPoint m_scrollPoint
;
207 Vector
<String
> m_documentState
;
209 HistoryItemVector m_children
;
211 bool m_lastVisitWasFailure
;
212 bool m_isInPageCache
;
215 Vector
<int> m_dailyVisitCounts
;
216 Vector
<int> m_weeklyVisitCounts
;
218 OwnPtr
<Vector
<String
> > m_redirectURLs
;
220 // info used to repost form data
221 RefPtr
<FormData
> m_formData
;
222 String m_formContentType
;
224 // PageCache controls these fields.
227 RefPtr
<CachedPage
> m_cachedPage
;
230 bool m_scaleIsInitial
;
231 ViewportArguments m_viewportArguments
;
234 RetainPtr
<id
> m_viewState
;
235 OwnPtr
<HashMap
<String
, RetainPtr
<id
> > > m_transientProperties
;
241 }; //class HistoryItem
243 } //namespace WebCore
246 // Outside the WebCore namespace for ease of invocation from gdb.
247 extern "C" int showTree(const WebCore::HistoryItem
*);
250 #endif // HISTORYITEM_H