|
1 /* |
|
2 Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net> |
|
3 |
|
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. |
|
8 |
|
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. |
|
13 |
|
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. |
|
18 |
|
19 This class provides all functionality needed for tracking global history. |
|
20 */ |
|
21 |
|
22 #include "qwebhistoryinterface.h" |
|
23 |
|
24 #include <QCoreApplication> |
|
25 |
|
26 #include "DeprecatedString.h" |
|
27 |
|
28 namespace WebCore { |
|
29 |
|
30 bool historyContains(const DeprecatedString& s) |
|
31 { |
|
32 if (!QWebHistoryInterface::defaultInterface()) |
|
33 return false; |
|
34 |
|
35 return QWebHistoryInterface::defaultInterface()->historyContains(QString(s)); |
|
36 } |
|
37 |
|
38 } // namespace WebCore |
|
39 |
|
40 static QWebHistoryInterface *default_interface; |
|
41 |
|
42 static bool gRoutineAdded; |
|
43 |
|
44 static void gCleanupInterface() |
|
45 { |
|
46 delete default_interface; |
|
47 default_interface = 0; |
|
48 } |
|
49 |
|
50 /*! |
|
51 Sets a new default interface that will be used by all of WebKit |
|
52 for managing history. |
|
53 */ |
|
54 void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface *defaultInterface) |
|
55 { |
|
56 if (default_interface == defaultInterface) |
|
57 return; |
|
58 if (default_interface) |
|
59 delete default_interface; |
|
60 default_interface = defaultInterface; |
|
61 if (!gRoutineAdded) { |
|
62 qAddPostRoutine(gCleanupInterface); |
|
63 gRoutineAdded = true; |
|
64 } |
|
65 } |
|
66 |
|
67 /*! |
|
68 Returns the default interface that will be used by WebKit. If no |
|
69 default interface has been set, QtWebkit will not track history. |
|
70 */ |
|
71 QWebHistoryInterface *QWebHistoryInterface::defaultInterface() |
|
72 { |
|
73 return default_interface; |
|
74 } |
|
75 |
|
76 QWebHistoryInterface::QWebHistoryInterface(QObject *parent) : QObject(parent) |
|
77 { |
|
78 } |
|
79 |
|
80 QWebHistoryInterface::~QWebHistoryInterface() |
|
81 { |
|
82 } |