Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/subscription/UserDefinedSubscription.cpp

Issue 29384812: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 1 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Added missing license headers Created March 27, 2017, 8:47 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/subscription/UserDefinedSubscription.h ('k') | lib/filterClassesNew.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "UserDefinedSubscription.h"
19
20 int UserDefinedSubscription::filterTypeToDefaults[] = {
21 UserDefinedSubscription::Defaults::BLOCKING, // UNKNOWN
22 UserDefinedSubscription::Defaults::BLOCKING, // INVALID
23 UserDefinedSubscription::Defaults::BLOCKING, // COMMENT
24 UserDefinedSubscription::Defaults::BLOCKING, // BLOCKING
25 UserDefinedSubscription::Defaults::WHITELIST, // WHITELIST
26 UserDefinedSubscription::Defaults::ELEMHIDE, // ELEMHIDE
27 UserDefinedSubscription::Defaults::ELEMHIDE, // ELEMHIDEEXCEPTION
28 UserDefinedSubscription::Defaults::ELEMHIDE, // ELEMHIDEEMULATION
29 };
30
31 UserDefinedSubscription::UserDefinedSubscription(const String& id)
32 : Subscription(Type::USERDEFINED, id), mDefaults(0)
33 {
34 }
35
36 bool UserDefinedSubscription::IsDefaultFor(const Filter* filter) const
37 {
38 return mDefaults & filterTypeToDefaults[filter->mType];
39 }
40
41 void UserDefinedSubscription::MakeDefaultFor(const Filter* filter)
42 {
43 mDefaults |= filterTypeToDefaults[filter->mType];
44 }
45
46 OwnedString UserDefinedSubscription::Serialize() const
47 {
48 OwnedString result(Subscription::Serialize());
49 if (mDefaults)
50 {
51 result.append(u"defaults="_str);
52 if (mDefaults & Defaults::BLOCKING)
53 result.append(u" blocking"_str);
54 if (mDefaults & Defaults::WHITELIST)
55 result.append(u" whitelist"_str);
56 if (mDefaults & Defaults::ELEMHIDE)
57 result.append(u" elemhide"_str);
58 result.append(u'\n');
59 }
60 return result;
61 }
OLDNEW
« no previous file with comments | « compiled/subscription/UserDefinedSubscription.h ('k') | lib/filterClassesNew.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld