Home | History | Annotate | Download | only in public
      1 /*
      2  * Copyright (C) 2009 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef WebHistoryItem_h
     32 #define WebHistoryItem_h
     33 
     34 #include "WebCommon.h"
     35 
     36 #if WEBKIT_IMPLEMENTATION
     37 namespace WebCore { class HistoryItem; }
     38 namespace WTF { template <typename T> class PassRefPtr; }
     39 #endif
     40 
     41 namespace WebKit {
     42 
     43 class WebHistoryItemPrivate;
     44 class WebHTTPBody;
     45 class WebString;
     46 struct WebPoint;
     47 template <typename T> class WebVector;
     48 
     49 // Represents a frame-level navigation entry in session history.  A
     50 // WebHistoryItem is a node in a tree.
     51 //
     52 // Copying a WebHistoryItem is cheap.
     53 //
     54 class WebHistoryItem {
     55 public:
     56     ~WebHistoryItem() { reset(); }
     57 
     58     WebHistoryItem() : m_private(0) { }
     59     WebHistoryItem(const WebHistoryItem& h) : m_private(0) { assign(h); }
     60     WebHistoryItem& operator=(const WebHistoryItem& h)
     61     {
     62         assign(h);
     63         return *this;
     64     }
     65 
     66     WEBKIT_API void initialize();
     67     WEBKIT_API void reset();
     68     WEBKIT_API void assign(const WebHistoryItem&);
     69 
     70     bool isNull() const { return !m_private; }
     71 
     72     WEBKIT_API WebString urlString() const;
     73     WEBKIT_API void setURLString(const WebString&);
     74 
     75     WEBKIT_API WebString originalURLString() const;
     76     WEBKIT_API void setOriginalURLString(const WebString&);
     77 
     78     WEBKIT_API WebString referrer() const;
     79     WEBKIT_API void setReferrer(const WebString&);
     80 
     81     WEBKIT_API WebString target() const;
     82     WEBKIT_API void setTarget(const WebString&);
     83 
     84     WEBKIT_API WebString parent() const;
     85     WEBKIT_API void setParent(const WebString&);
     86 
     87     WEBKIT_API WebString title() const;
     88     WEBKIT_API void setTitle(const WebString&);
     89 
     90     WEBKIT_API WebString alternateTitle() const;
     91     WEBKIT_API void setAlternateTitle(const WebString&);
     92 
     93     WEBKIT_API double lastVisitedTime() const;
     94     WEBKIT_API void setLastVisitedTime(double);
     95 
     96     WEBKIT_API WebPoint scrollOffset() const;
     97     WEBKIT_API void setScrollOffset(const WebPoint&);
     98 
     99     WEBKIT_API bool isTargetItem() const;
    100     WEBKIT_API void setIsTargetItem(bool);
    101 
    102     WEBKIT_API int visitCount() const;
    103     WEBKIT_API void setVisitCount(int);
    104 
    105     WEBKIT_API WebVector<WebString> documentState() const;
    106     WEBKIT_API void setDocumentState(const WebVector<WebString>&);
    107 
    108     WEBKIT_API long long documentSequenceNumber() const;
    109     WEBKIT_API void setDocumentSequenceNumber(long long);
    110 
    111     WEBKIT_API WebString httpContentType() const;
    112     WEBKIT_API void setHTTPContentType(const WebString&);
    113 
    114     WEBKIT_API WebHTTPBody httpBody() const;
    115     WEBKIT_API void setHTTPBody(const WebHTTPBody&);
    116 
    117     WEBKIT_API WebVector<WebHistoryItem> children() const;
    118     WEBKIT_API void setChildren(const WebVector<WebHistoryItem>&);
    119     WEBKIT_API void appendToChildren(const WebHistoryItem&);
    120 
    121 #if WEBKIT_IMPLEMENTATION
    122     WebHistoryItem(const WTF::PassRefPtr<WebCore::HistoryItem>&);
    123     WebHistoryItem& operator=(const WTF::PassRefPtr<WebCore::HistoryItem>&);
    124     operator WTF::PassRefPtr<WebCore::HistoryItem>() const;
    125 #endif
    126 
    127 private:
    128     void assign(WebHistoryItemPrivate*);
    129     void ensureMutable();
    130     WebHistoryItemPrivate* m_private;
    131 };
    132 
    133 } // namespace WebKit
    134 
    135 #endif
    136