1/* 2 * Copyright (C) 2010, 2011 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 WebBackForwardList_h 27#define WebBackForwardList_h 28 29#include "APIObject.h" 30#include "WebBackForwardListItem.h" 31#include "WebPageProxy.h" 32#include <wtf/PassRef.h> 33#include <wtf/RefPtr.h> 34#include <wtf/Vector.h> 35#if USE(CF) 36#include <CoreFoundation/CFDictionary.h> 37#endif 38 39namespace WebKit { 40 41struct BackForwardListState; 42 43class WebBackForwardList : public API::ObjectImpl<API::Object::Type::BackForwardList> { 44public: 45 static PassRef<WebBackForwardList> create(WebPageProxy& page) 46 { 47 return adoptRef(*new WebBackForwardList(page)); 48 } 49 void pageClosed(); 50 51 virtual ~WebBackForwardList(); 52 53 void addItem(WebBackForwardListItem*); 54 void goToItem(WebBackForwardListItem*); 55 void removeAllItems(); 56 void clear(); 57 58 WebBackForwardListItem* currentItem() const; 59 WebBackForwardListItem* backItem() const; 60 WebBackForwardListItem* forwardItem() const; 61 WebBackForwardListItem* itemAtIndex(int) const; 62 63 const BackForwardListItemVector& entries() const { return m_entries; } 64 65 uint32_t currentIndex() const { return m_currentIndex; } 66 int backListCount() const; 67 int forwardListCount() const; 68 69 PassRefPtr<API::Array> backList() const; 70 PassRefPtr<API::Array> forwardList() const; 71 72 PassRefPtr<API::Array> backListAsAPIArrayWithLimit(unsigned limit) const; 73 PassRefPtr<API::Array> forwardListAsAPIArrayWithLimit(unsigned limit) const; 74 75 BackForwardListState backForwardListState(const std::function<bool (WebBackForwardListItem&)>&) const; 76 void restoreFromState(BackForwardListState); 77 78 Vector<BackForwardListItemState> itemStates() const; 79 80private: 81 explicit WebBackForwardList(WebPageProxy&); 82 83 WebPageProxy* m_page; 84 BackForwardListItemVector m_entries; 85 86 bool m_hasCurrentIndex; 87 unsigned m_currentIndex; 88 unsigned m_capacity; 89}; 90 91} // namespace WebKit 92 93#endif // WebBackForwardList_h 94