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/IntPoint.h" 32 #include "wtf/RefCounted.h" 33 #include "wtf/text/WTFString.h" 34 35 namespace WebCore { 36 37 class Document; 38 class FormData; 39 class HistoryItem; 40 class Image; 41 class KURL; 42 class ResourceRequest; 43 44 typedef Vector<RefPtr<HistoryItem> > HistoryItemVector; 45 46 class HistoryItem : public RefCounted<HistoryItem> { 47 public: create()48 static PassRefPtr<HistoryItem> create() { return adoptRef(new HistoryItem); } 49 50 ~HistoryItem(); 51 52 PassRefPtr<HistoryItem> copy() const; 53 54 // Resets the HistoryItem to its initial state, as returned by create(). 55 void reset(); 56 57 const String& originalURLString() const; 58 const String& urlString() const; 59 KURL url() const; 60 KURL originalURL() const; 61 62 const AtomicString& referrer() const; 63 const String& target() const; 64 65 FormData* formData(); 66 const AtomicString& formContentType() const; 67 68 const IntPoint& scrollPoint() const; 69 void setScrollPoint(const IntPoint&); 70 void clearScrollPoint(); 71 72 float pageScaleFactor() const; 73 void setPageScaleFactor(float); 74 75 const Vector<String>& documentState() const; 76 void setDocumentState(const Vector<String>&); 77 void clearDocumentState(); 78 79 void setURL(const KURL&); 80 void setURLString(const String&); 81 void setOriginalURLString(const String&); 82 void setReferrer(const AtomicString&); 83 void setTarget(const String&); 84 85 void setStateObject(PassRefPtr<SerializedScriptValue> object); stateObject()86 SerializedScriptValue* stateObject() const { return m_stateObject.get(); } 87 setItemSequenceNumber(long long number)88 void setItemSequenceNumber(long long number) { m_itemSequenceNumber = number; } itemSequenceNumber()89 long long itemSequenceNumber() const { return m_itemSequenceNumber; } 90 setDocumentSequenceNumber(long long number)91 void setDocumentSequenceNumber(long long number) { m_documentSequenceNumber = number; } documentSequenceNumber()92 long long documentSequenceNumber() const { return m_documentSequenceNumber; } 93 setTargetFrameID(int64_t id)94 void setTargetFrameID(int64_t id) { m_targetFrameID = id; } targetFrameID()95 int64_t targetFrameID() const { return m_targetFrameID; } 96 97 void setFormInfoFromRequest(const ResourceRequest&); 98 void setFormData(PassRefPtr<FormData>); 99 void setFormContentType(const AtomicString&); 100 101 void addChildItem(PassRefPtr<HistoryItem>); 102 const HistoryItemVector& children() const; 103 void clearChildren(); 104 105 bool isCurrentDocument(Document*) const; 106 107 private: 108 HistoryItem(); 109 explicit HistoryItem(const HistoryItem&); 110 111 String m_urlString; 112 String m_originalURLString; 113 AtomicString m_referrer; 114 String m_target; 115 116 IntPoint m_scrollPoint; 117 float m_pageScaleFactor; 118 Vector<String> m_documentState; 119 120 HistoryItemVector m_children; 121 122 // If two HistoryItems have the same item sequence number, then they are 123 // clones of one another. Traversing history from one such HistoryItem to 124 // another is a no-op. HistoryItem clones are created for parent and 125 // sibling frames when only a subframe navigates. 126 int64_t m_itemSequenceNumber; 127 128 // If two HistoryItems have the same document sequence number, then they 129 // refer to the same instance of a document. Traversing history from one 130 // such HistoryItem to another preserves the document. 131 int64_t m_documentSequenceNumber; 132 133 int64_t m_targetFrameID; 134 135 // Support for HTML5 History 136 RefPtr<SerializedScriptValue> m_stateObject; 137 138 // info used to repost form data 139 RefPtr<FormData> m_formData; 140 AtomicString m_formContentType; 141 142 }; //class HistoryItem 143 144 } //namespace WebCore 145 146 #endif // HISTORYITEM_H 147