| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 void UserDefinedSubscription::MakeDefaultFor(const Filter* filter) | 63 void UserDefinedSubscription::MakeDefaultFor(const Filter* filter) |
| 64 { | 64 { |
| 65 if (filter->mType >= Filter::Type::VALUE_COUNT) | 65 if (filter->mType >= Filter::Type::VALUE_COUNT) |
| 66 { | 66 { |
| 67 assert(false, "Filter type exceeds valid range"); | 67 assert(false, "Filter type exceeds valid range"); |
| 68 abort(); | 68 abort(); |
| 69 } | 69 } |
| 70 mDefaults |= filterTypeToCategory[filter->mType]; | 70 mDefaults |= filterTypeToCategory[filter->mType]; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void UserDefinedSubscription::InsertFilterAt(Filter* filter, unsigned pos) |
| 74 { |
| 75 if (pos >= mFilters.size()) |
| 76 mFilters.emplace_back(filter); |
| 77 else |
| 78 mFilters.emplace(mFilters.begin() + pos, filter); |
| 79 } |
| 80 |
| 81 bool UserDefinedSubscription::RemoveFilterAt(unsigned pos) |
| 82 { |
| 83 if (pos >= mFilters.size()) |
| 84 return false; |
| 85 |
| 86 mFilters.erase(mFilters.begin() + pos); |
| 87 return true; |
| 88 } |
| 89 |
| 73 OwnedString UserDefinedSubscription::Serialize() const | 90 OwnedString UserDefinedSubscription::Serialize() const |
| 74 { | 91 { |
| 75 OwnedString result(Subscription::Serialize()); | 92 OwnedString result(Subscription::Serialize()); |
| 76 if (mDefaults) | 93 if (mDefaults) |
| 77 { | 94 { |
| 78 result.append(u"defaults="_str); | 95 result.append(u"defaults="_str); |
| 79 if (mDefaults & FilterCategory::BLOCKING) | 96 if (mDefaults & FilterCategory::BLOCKING) |
| 80 result.append(u" blocking"_str); | 97 result.append(u" blocking"_str); |
| 81 if (mDefaults & FilterCategory::WHITELIST) | 98 if (mDefaults & FilterCategory::WHITELIST) |
| 82 result.append(u" whitelist"_str); | 99 result.append(u" whitelist"_str); |
| 83 if (mDefaults & FilterCategory::ELEMHIDE) | 100 if (mDefaults & FilterCategory::ELEMHIDE) |
| 84 result.append(u" elemhide"_str); | 101 result.append(u" elemhide"_str); |
| 85 result.append(u'\n'); | 102 result.append(u'\n'); |
| 86 } | 103 } |
| 87 return result; | 104 return result; |
| 88 } | 105 } |
| OLD | NEW |