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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 { | 99 { |
100 Communication::OutputBuffer response; | 100 Communication::OutputBuffer response; |
101 | 101 |
102 Communication::ProcType procedure; | 102 Communication::ProcType procedure; |
103 request >> procedure; | 103 request >> procedure; |
104 switch (procedure) | 104 switch (procedure) |
105 { | 105 { |
106 case Communication::PROC_MATCHES: | 106 case Communication::PROC_MATCHES: |
107 { | 107 { |
108 std::string url; | 108 std::string url; |
109 std::string type; | 109 using namespace AdblockPlus; |
110 std::string documentUrl; | 110 std::string documentUrl; |
| 111 int32_t type; |
111 request >> url >> type >> documentUrl; | 112 request >> url >> type >> documentUrl; |
112 referrerMapping.Add(url, documentUrl); | 113 referrerMapping.Add(url, documentUrl); |
113 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, type, referre
rMapping.BuildReferrerChain(documentUrl)); | 114 auto contentType = static_cast<FilterEngine::ContentType>(type); |
114 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX
CEPTION); | 115 FilterPtr filter = filterEngine->Matches(url, contentType, referrerMappi
ng.BuildReferrerChain(documentUrl)); |
| 116 response << (filter && filter->GetType() != Filter::TYPE_EXCEPTION); |
115 break; | 117 break; |
116 } | 118 } |
117 case Communication::PROC_GET_ELEMHIDE_SELECTORS: | 119 case Communication::PROC_GET_ELEMHIDE_SELECTORS: |
118 { | 120 { |
119 std::string domain; | 121 std::string domain; |
120 request >> domain; | 122 request >> domain; |
121 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain)); | 123 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain)); |
122 break; | 124 break; |
123 } | 125 } |
124 case Communication::PROC_AVAILABLE_SUBSCRIPTIONS: | 126 case Communication::PROC_AVAILABLE_SUBSCRIPTIONS: |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 205 } |
204 } | 206 } |
205 | 207 |
206 WriteStrings(response, domains); | 208 WriteStrings(response, domains); |
207 break; | 209 break; |
208 } | 210 } |
209 case Communication::PROC_IS_WHITELISTED_URL: | 211 case Communication::PROC_IS_WHITELISTED_URL: |
210 { | 212 { |
211 std::string url; | 213 std::string url; |
212 request >> url; | 214 request >> url; |
213 AdblockPlus::FilterPtr match = filterEngine->Matches(url, "DOCUMENT", ur
l); | 215 AdblockPlus::FilterPtr match = filterEngine->Matches(url, |
| 216 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_DOCUMENT, url); |
214 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE
PTION); | 217 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE
PTION); |
215 break; | 218 break; |
216 } | 219 } |
217 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL: | 220 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL: |
218 { | 221 { |
219 std::string url; | 222 std::string url; |
220 request >> url; | 223 request >> url; |
221 AdblockPlus::FilterPtr match = filterEngine->Matches(url, "ELEMHIDE", ur
l); | 224 AdblockPlus::FilterPtr match = filterEngine->Matches(url, |
| 225 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_ELEMHIDE, url); |
222 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE
PTION); | 226 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE
PTION); |
223 break; | 227 break; |
224 } | 228 } |
225 case Communication::PROC_ADD_FILTER: | 229 case Communication::PROC_ADD_FILTER: |
226 { | 230 { |
227 std::string text; | 231 std::string text; |
228 request >> text; | 232 request >> text; |
229 | 233 |
230 filterEngine->GetFilter(text)->AddToList(); | 234 filterEngine->GetFilter(text)->AddToList(); |
231 break; | 235 break; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 506 } |
503 catch (const std::runtime_error& e) | 507 catch (const std::runtime_error& e) |
504 { | 508 { |
505 DebugException(e); | 509 DebugException(e); |
506 return 1; | 510 return 1; |
507 } | 511 } |
508 } | 512 } |
509 | 513 |
510 return 0; | 514 return 0; |
511 } | 515 } |
OLD | NEW |