webengine_filter.h 1.85 KB
Newer Older
Urs Wolfer's avatar
Urs Wolfer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* This file is part of the KDE project

   Copyright (C) 2005 Ivor Hewitt     <ivor@kde.org>
   Copyright (C) 2008 Maksim Orlovich <maksim@kde.org>
   Copyright (C) 2008 Vyacheslav Tokarev <tsjoker@gmail.com>

   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.
*/

Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
23
24
#ifndef WEBENGNINE_FILTER_P_H
#define WEBENGNINE_FILTER_P_H
Urs Wolfer's avatar
Urs Wolfer committed
25

Urs Wolfer's avatar
Urs Wolfer committed
26
27
28
#include <QString>
#include <QRegExp>
#include <QVector>
29
#include <webenginepart.h>
Urs Wolfer's avatar
Urs Wolfer committed
30

31
class StringsMatcher;
Urs Wolfer's avatar
Urs Wolfer committed
32

33
34
namespace KDEPrivate
{
Urs Wolfer's avatar
Urs Wolfer committed
35
36
37
38
// This represents a set of filters that may match URLs.
// Currently it supports a subset of AddBlock Plus functionality.
class FilterSet {
public:
39
40
41
    FilterSet();
    ~FilterSet();

Urs Wolfer's avatar
Urs Wolfer committed
42
43
44
    // Parses and registers a filter. This will also strip @@ for exclusion rules, skip comments, etc.
    // The user does have to split black and white lists into separate sets, however
    void addFilter(const QString& filter);
45

Urs Wolfer's avatar
Urs Wolfer committed
46
    bool isUrlMatched(const QString& url);
47
    QString urlMatchedBy(const QString& url);
48

Urs Wolfer's avatar
Urs Wolfer committed
49
50
51
52
    void clear();

private:
    QVector<QRegExp> reFilters;
53
    StringsMatcher* stringFiltersMatcher;
Urs Wolfer's avatar
Urs Wolfer committed
54
55
56
57
};

}

Sune Stolborg Vuorela's avatar
Sune Stolborg Vuorela committed
58
#endif // WEBENGINE_FILTER_P_H
Urs Wolfer's avatar
Urs Wolfer committed
59

Urs Wolfer's avatar
Urs Wolfer committed
60
// kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;