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/core/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 blink { 38 39 class Document; 40 class DocumentState; 41 class FormData; 42 class HistoryItem; 43 class KURL; 44 class ResourceRequest; 45 46 typedef Vector<RefPtr<HistoryItem> > HistoryItemVector; 47 48 class HistoryItem : public RefCounted<HistoryItem> { 49 public: create()50 static PassRefPtr<HistoryItem> create() { return adoptRef(new HistoryItem); } 51 ~HistoryItem(); 52 53 // Used when the frame this item represents was navigated to a different 54 // url but a new item wasn't created. 55 void generateNewItemSequenceNumber(); 56 void generateNewDocumentSequenceNumber(); 57 58 const String& urlString() const; 59 KURL url() const; 60 61 const Referrer& referrer() const; 62 const String& target() const; 63 64 FormData* formData(); 65 const AtomicString& formContentType() const; 66 67 const FloatPoint& pinchViewportScrollPoint() const; 68 void setPinchViewportScrollPoint(const FloatPoint&); 69 const IntPoint& scrollPoint() const; 70 void setScrollPoint(const IntPoint&); 71 void clearScrollPoint(); 72 73 float pageScaleFactor() const; 74 void setPageScaleFactor(float); 75 76 Vector<String> getReferencedFilePaths(); 77 const Vector<String>& documentState(); 78 void setDocumentState(const Vector<String>&); 79 void setDocumentState(DocumentState*); 80 void clearDocumentState(); 81 82 void setURL(const KURL&); 83 void setURLString(const String&); 84 void setReferrer(const Referrer&); 85 void setTarget(const String&); 86 87 void setStateObject(PassRefPtr<SerializedScriptValue>); stateObject()88 SerializedScriptValue* stateObject() const { return m_stateObject.get(); } 89 setItemSequenceNumber(long long number)90 void setItemSequenceNumber(long long number) { m_itemSequenceNumber = number; } itemSequenceNumber()91 long long itemSequenceNumber() const { return m_itemSequenceNumber; } 92 setDocumentSequenceNumber(long long number)93 void setDocumentSequenceNumber(long long number) { m_documentSequenceNumber = number; } documentSequenceNumber()94 long long documentSequenceNumber() const { return m_documentSequenceNumber; } 95 setFrameSequenceNumber(long long number)96 void setFrameSequenceNumber(long long number) { m_frameSequenceNumber = number; } frameSequenceNumber()97 long long frameSequenceNumber() const { return m_frameSequenceNumber; } 98 99 void setFormInfoFromRequest(const ResourceRequest&); 100 void setFormData(PassRefPtr<FormData>); 101 void setFormContentType(const AtomicString&); 102 103 bool isCurrentDocument(Document*) const; 104 105 private: 106 HistoryItem(); 107 108 String m_urlString; 109 Referrer m_referrer; 110 String m_target; 111 112 FloatPoint m_pinchViewportScrollPoint; 113 IntPoint m_scrollPoint; 114 float m_pageScaleFactor; 115 Vector<String> m_documentStateVector; 116 RefPtrWillBePersistent<DocumentState> m_documentState; 117 118 // If two HistoryItems have the same item sequence number, then they are 119 // clones of one another. Traversing history from one such HistoryItem to 120 // another is a no-op. HistoryItem clones are created for parent and 121 // sibling frames when only a subframe navigates. 122 int64_t m_itemSequenceNumber; 123 124 // If two HistoryItems have the same document sequence number, then they 125 // refer to the same instance of a document. Traversing history from one 126 // such HistoryItem to another preserves the document. 127 int64_t m_documentSequenceNumber; 128 129 // If two HistoryItems have the same frame sequence number, then they 130 // refer to the same instance of a Frame. This is used to determine whether 131 // whether a HistoryItem should navigate an existing frame or create a new 132 // one during a history navigation. 133 int64_t m_frameSequenceNumber; 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 blink 145 146 #endif // HISTORYITEM_H 147