35307903a45651c3d9d1ad1e6022230950a8a0b8
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / loader / HistoryItem.h
1 /*
2  * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved.
3  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #ifndef HistoryItem_h
28 #define HistoryItem_h
29
30 #include "bindings/v8/SerializedScriptValue.h"
31 #include "platform/geometry/FloatPoint.h"
32 #include "platform/geometry/IntPoint.h"
33 #include "platform/weborigin/Referrer.h"
34 #include "wtf/RefCounted.h"
35 #include "wtf/text/WTFString.h"
36
37 namespace WebCore {
38
39 class Document;
40 class DocumentState;
41 class FormData;
42 class HistoryItem;
43 class Image;
44 class KURL;
45 class ResourceRequest;
46
47 typedef Vector<RefPtr<HistoryItem> > HistoryItemVector;
48
49 class HistoryItem : public RefCounted<HistoryItem> {
50 public:
51     static PassRefPtr<HistoryItem> create() { return adoptRef(new HistoryItem); }
52     ~HistoryItem();
53
54     // Used when the frame this item represents was navigated to a different
55     // url but a new item wasn't created.
56     void generateNewItemSequenceNumber();
57     void generateNewDocumentSequenceNumber();
58
59     const String& urlString() const;
60     KURL url() const;
61
62     const Referrer& referrer() const;
63     const String& target() const;
64
65     FormData* formData();
66     const AtomicString& formContentType() const;
67
68     const FloatPoint& pinchViewportScrollPoint() const;
69     void setPinchViewportScrollPoint(const FloatPoint&);
70     const IntPoint& scrollPoint() const;
71     void setScrollPoint(const IntPoint&);
72     void clearScrollPoint();
73
74     float pageScaleFactor() const;
75     void setPageScaleFactor(float);
76
77     Vector<String> getReferencedFilePaths();
78     const Vector<String>& documentState();
79     void setDocumentState(const Vector<String>&);
80     void setDocumentState(DocumentState*);
81     void clearDocumentState();
82
83     void setURL(const KURL&);
84     void setURLString(const String&);
85     void setReferrer(const Referrer&);
86     void setTarget(const String&);
87
88     void setStateObject(PassRefPtr<SerializedScriptValue>);
89     SerializedScriptValue* stateObject() const { return m_stateObject.get(); }
90
91     void setItemSequenceNumber(long long number) { m_itemSequenceNumber = number; }
92     long long itemSequenceNumber() const { return m_itemSequenceNumber; }
93
94     void setDocumentSequenceNumber(long long number) { m_documentSequenceNumber = number; }
95     long long documentSequenceNumber() const { return m_documentSequenceNumber; }
96
97     void setFormInfoFromRequest(const ResourceRequest&);
98     void setFormData(PassRefPtr<FormData>);
99     void setFormContentType(const AtomicString&);
100
101     bool isCurrentDocument(Document*) const;
102
103 private:
104     HistoryItem();
105
106     String m_urlString;
107     Referrer m_referrer;
108     String m_target;
109
110     FloatPoint m_pinchViewportScrollPoint;
111     IntPoint m_scrollPoint;
112     float m_pageScaleFactor;
113     Vector<String> m_documentStateVector;
114     RefPtrWillBePersistent<DocumentState> m_documentState;
115
116     // If two HistoryItems have the same item sequence number, then they are
117     // clones of one another. Traversing history from one such HistoryItem to
118     // another is a no-op. HistoryItem clones are created for parent and
119     // sibling frames when only a subframe navigates.
120     int64_t m_itemSequenceNumber;
121
122     // If two HistoryItems have the same document sequence number, then they
123     // refer to the same instance of a document. Traversing history from one
124     // such HistoryItem to another preserves the document.
125     int64_t m_documentSequenceNumber;
126
127     // Support for HTML5 History
128     RefPtr<SerializedScriptValue> m_stateObject;
129
130     // info used to repost form data
131     RefPtr<FormData> m_formData;
132     AtomicString m_formContentType;
133
134 }; // class HistoryItem
135
136 } // namespace WebCore
137
138 #endif // HISTORYITEM_H