2 Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
19 This class provides all functionality needed for tracking global history.
23 #include "qwebhistoryinterface.h"
25 #include <QCoreApplication>
27 #include "PageGroup.h"
28 #include "PlatformString.h"
31 static QWebHistoryInterface* default_interface;
33 static bool gRoutineAdded;
35 static void gCleanupInterface()
37 if (default_interface && !default_interface->parent())
38 delete default_interface;
39 default_interface = 0;
43 Sets a new default interface, \a defaultInterface, that will be used by all of WebKit
46 If an interface without a parent has already been set, the old interface will be deleted.
47 When the application exists QWebHistoryInterface will automatically delete the
48 \a defaultInterface if it does not have a parent.
50 void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface* defaultInterface)
52 if (default_interface == defaultInterface)
55 if (default_interface && !default_interface->parent())
56 delete default_interface;
58 default_interface = defaultInterface;
59 WebCore::PageGroup::removeAllVisitedLinks();
61 //### enable after the introduction of a version
62 //WebCore::PageGroup::setShouldTrackVisitedLinks(true);
65 qAddPostRoutine(gCleanupInterface);
71 Returns the default interface that will be used by WebKit. If no
72 default interface has been set, QtWebkit will not track history.
74 QWebHistoryInterface* QWebHistoryInterface::defaultInterface()
76 return default_interface;
80 \class QWebHistoryInterface
82 \brief The QWebHistoryInterface class provides an interface to implement link history.
86 The QWebHistoryInterface is an interface that can be used to
87 implement link history. It contains two pure virtual methods that
88 are called by the WebKit engine. addHistoryEntry() is used to add
89 pages that have been visited to the interface, while
90 historyContains() is used to query whether this page has been
95 Constructs a new QWebHistoryInterface with parent \a parent.
97 QWebHistoryInterface::QWebHistoryInterface(QObject* parent)
103 Destructor. If this is currently the default interface it will be unset.
105 QWebHistoryInterface::~QWebHistoryInterface()
107 if (default_interface == this)
108 default_interface = 0;
112 \fn bool QWebHistoryInterface::historyContains(const QString &url) const = 0
114 Called by the WebKit engine to query whether a certain \a url has been visited by the user already.
115 Returns true if the \a url is part of the history of visited links; otherwise returns false.
119 \fn void QWebHistoryInterface::addHistoryEntry(const QString &url) = 0
121 Called by WebKit to add another \a url to the list of visited pages.