1/* 2 * Copyright (C) 2014 Apple 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 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef SessionState_h 27#define SessionState_h 28 29#if PLATFORM(COCOA) 30#include "ViewSnapshotStore.h" 31#endif 32 33#include <WebCore/FloatRect.h> 34#include <WebCore/IntRect.h> 35#include <WebCore/URL.h> 36#include <wtf/Optional.h> 37#include <wtf/Vector.h> 38#include <wtf/text/WTFString.h> 39 40namespace IPC { 41class ArgumentDecoder; 42class ArgumentEncoder; 43} 44 45namespace WebKit { 46 47struct HTTPBody { 48 struct Element { 49 void encode(IPC::ArgumentEncoder&) const; 50 static bool decode(IPC::ArgumentDecoder&, Element&); 51 52 enum class Type { 53 Data, 54 File, 55 Blob, 56 }; 57 58 Type type = Type::Data; 59 60 // Data. 61 Vector<char> data; 62 63 // File. 64 String filePath; 65 int64_t fileStart; 66 Optional<int64_t> fileLength; 67 Optional<double> expectedFileModificationTime; 68 69 // Blob. 70 String blobURLString; 71 }; 72 73 void encode(IPC::ArgumentEncoder&) const; 74 static bool decode(IPC::ArgumentDecoder&, HTTPBody&); 75 76 String contentType; 77 Vector<Element> elements; 78}; 79 80struct FrameState { 81 void encode(IPC::ArgumentEncoder&) const; 82 static bool decode(IPC::ArgumentDecoder&, FrameState&); 83 84 String urlString; 85 String originalURLString; 86 String referrer; 87 String target; 88 89 Vector<String> documentState; 90 Optional<Vector<uint8_t>> stateObjectData; 91 92 int64_t documentSequenceNumber; 93 int64_t itemSequenceNumber; 94 95 WebCore::IntPoint scrollPoint; 96 float pageScaleFactor; 97 98 Optional<HTTPBody> httpBody; 99 100 // FIXME: These should not be per frame. 101#if PLATFORM(IOS) 102 WebCore::FloatRect exposedContentRect; 103 WebCore::IntRect unobscuredContentRect; 104 WebCore::FloatSize minimumLayoutSizeInScrollViewCoordinates; 105 WebCore::IntSize contentSize; 106 bool scaleIsInitial = false; 107#endif 108 109 Vector<FrameState> children; 110}; 111 112struct PageState { 113 void encode(IPC::ArgumentEncoder&) const; 114 static bool decode(IPC::ArgumentDecoder&, PageState&); 115 116 String title; 117 FrameState mainFrameState; 118}; 119 120struct BackForwardListItemState { 121 void encode(IPC::ArgumentEncoder&) const; 122 static bool decode(IPC::ArgumentDecoder&, BackForwardListItemState&); 123 124 uint64_t identifier; 125 126 PageState pageState; 127#if PLATFORM(COCOA) 128 RefPtr<ViewSnapshot> snapshot; 129#endif 130 131}; 132 133struct BackForwardListState { 134 void encode(IPC::ArgumentEncoder&) const; 135 static bool decode(IPC::ArgumentDecoder&, BackForwardListState&); 136 137 Vector<BackForwardListItemState> items; 138 Optional<uint32_t> currentIndex; 139}; 140 141struct SessionState { 142 BackForwardListState backForwardListState; 143 WebCore::URL provisionalURL; 144}; 145 146} // namespace WebKit 147 148#endif // SessionState_h 149