Home | History | Annotate | Download | only in web
      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 "../platform/WebCommon.h"
     35 #include "../platform/WebPrivatePtr.h"
     36 #include "../platform/WebReferrerPolicy.h"
     37 
     38 namespace WebCore { class HistoryItem; }
     39 
     40 namespace blink {
     41 class WebHTTPBody;
     42 class WebString;
     43 class WebSerializedScriptValue;
     44 struct WebFloatPoint;
     45 struct WebPoint;
     46 template <typename T> class WebVector;
     47 
     48 enum WebHistoryLoadType {
     49     WebHistorySameDocumentLoad,
     50     WebHistoryDifferentDocumentLoad
     51 };
     52 
     53 // Represents a frame-level navigation entry in session history.  A
     54 // WebHistoryItem is a node in a tree.
     55 //
     56 // Copying a WebHistoryItem is cheap.
     57 //
     58 class WebHistoryItem {
     59 public:
     60     ~WebHistoryItem() { reset(); }
     61 
     62     WebHistoryItem() { }
     63     WebHistoryItem(const WebHistoryItem& h) { assign(h); }
     64     WebHistoryItem& operator=(const WebHistoryItem& h)
     65     {
     66         assign(h);
     67         return *this;
     68     }
     69 
     70     BLINK_EXPORT void initialize();
     71     BLINK_EXPORT void reset();
     72     BLINK_EXPORT void assign(const WebHistoryItem&);
     73 
     74     bool isNull() const { return m_private.isNull(); }
     75 
     76     BLINK_EXPORT WebString urlString() const;
     77     BLINK_EXPORT void setURLString(const WebString&);
     78 
     79     BLINK_EXPORT WebString referrer() const;
     80     BLINK_EXPORT WebReferrerPolicy referrerPolicy() const;
     81     BLINK_EXPORT void setReferrer(const WebString&, WebReferrerPolicy);
     82 
     83     BLINK_EXPORT WebString target() const;
     84     BLINK_EXPORT void setTarget(const WebString&);
     85 
     86     BLINK_EXPORT WebFloatPoint pinchViewportScrollOffset() const;
     87     BLINK_EXPORT void setPinchViewportScrollOffset(const WebFloatPoint&);
     88 
     89     BLINK_EXPORT WebPoint scrollOffset() const;
     90     BLINK_EXPORT void setScrollOffset(const WebPoint&);
     91 
     92     BLINK_EXPORT float pageScaleFactor() const;
     93     BLINK_EXPORT void setPageScaleFactor(float);
     94 
     95     BLINK_EXPORT WebVector<WebString> documentState() const;
     96     BLINK_EXPORT void setDocumentState(const WebVector<WebString>&);
     97 
     98     BLINK_EXPORT long long itemSequenceNumber() const;
     99     BLINK_EXPORT void setItemSequenceNumber(long long);
    100 
    101     BLINK_EXPORT long long documentSequenceNumber() const;
    102     BLINK_EXPORT void setDocumentSequenceNumber(long long);
    103 
    104     BLINK_EXPORT WebSerializedScriptValue stateObject() const;
    105     BLINK_EXPORT void setStateObject(const WebSerializedScriptValue&);
    106 
    107     BLINK_EXPORT WebString httpContentType() const;
    108     BLINK_EXPORT void setHTTPContentType(const WebString&);
    109 
    110     BLINK_EXPORT WebHTTPBody httpBody() const;
    111     BLINK_EXPORT void setHTTPBody(const WebHTTPBody&);
    112 
    113     BLINK_EXPORT WebVector<WebString> getReferencedFilePaths() const;
    114 
    115 #if BLINK_IMPLEMENTATION
    116     WebHistoryItem(const WTF::PassRefPtr<WebCore::HistoryItem>&);
    117     WebHistoryItem& operator=(const WTF::PassRefPtr<WebCore::HistoryItem>&);
    118     operator WTF::PassRefPtr<WebCore::HistoryItem>() const;
    119 #endif
    120 
    121 private:
    122     WebPrivatePtr<WebCore::HistoryItem> m_private;
    123 };
    124 
    125 } // namespace blink
    126 
    127 #endif
    128