1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*
Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
This class provides all functionality needed for tracking global history.
*/
#include "config.h"
#include "qwebhistoryinterface.h"
#include <QCoreApplication>
#include "PageGroup.h"
#include "PlatformString.h"
static QWebHistoryInterface* default_interface;
static bool gRoutineAdded;
static void gCleanupInterface()
{
if (default_interface && !default_interface->parent())
delete default_interface;
default_interface = 0;
}
/*!
Sets a new default interface, \a defaultInterface, that will be used by all of WebKit
to keep track of visited links.
If an interface without a parent has already been set, the old interface will be deleted.
When the application exists QWebHistoryInterface will automatically delete the
\a defaultInterface if it does not have a parent.
*/
void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface* defaultInterface)
{
if (default_interface == defaultInterface)
return;
if (default_interface && !default_interface->parent())
delete default_interface;
default_interface = defaultInterface;
WebCore::PageGroup::removeAllVisitedLinks();
//### enable after the introduction of a version
//WebCore::PageGroup::setShouldTrackVisitedLinks(true);
if (!gRoutineAdded) {
qAddPostRoutine(gCleanupInterface);
gRoutineAdded = true;
}
}
/*!
Returns the default interface that will be used by WebKit. If no default interface has been set,
Webkit will not keep track of visited links and a null pointer will be returned.
\sa setDefaultInterface
*/
QWebHistoryInterface* QWebHistoryInterface::defaultInterface()
{
return default_interface;
}
/*!
\class QWebHistoryInterface
\since 4.4
\brief The QWebHistoryInterface class provides an interface to implement link history.
\inmodule QtWebKit
The QWebHistoryInterface is an interface that can be used to
keep track of visited links. It contains two pure virtual methods that
are called by the WebKit engine: addHistoryEntry() is used to add
urls that have been visited to the interface, while
historyContains() is used to query whether the given url has been
visited by the user. By default the QWebHistoryInterface is not set, so WebKit does not keep
track of visited links.
\note The history tracked by QWebHistoryInterface is not specific to an instance of QWebPage
but applies to all pages.
*/
/*!
Constructs a new QWebHistoryInterface with parent \a parent.
*/
QWebHistoryInterface::QWebHistoryInterface(QObject* parent)
: QObject(parent)
{
}
/*!
Destroys the interface. If this is currently the default interface it will be unset.
*/
QWebHistoryInterface::~QWebHistoryInterface()
{
if (default_interface == this)
default_interface = 0;
}
/*!
\fn bool QWebHistoryInterface::historyContains(const QString &url) const = 0
Called by the WebKit engine to query whether a certain \a url has been visited by the user already.
Returns true if the \a url is part of the history of visited links; otherwise returns false.
*/
/*!
\fn void QWebHistoryInterface::addHistoryEntry(const QString &url) = 0
Called by WebKit to add another \a url to the list of visited pages.
*/
|