LEFT | RIGHT |
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 { | 162 { |
163 DEBUG_GENERAL("CallEngine start"); | 163 DEBUG_GENERAL("CallEngine start"); |
164 CriticalSection::Lock lock(enginePipeLock); | 164 CriticalSection::Lock lock(enginePipeLock); |
165 try | 165 try |
166 { | 166 { |
167 if (!enginePipe) | 167 if (!enginePipe) |
168 enginePipe.reset(OpenEnginePipe()); | 168 enginePipe.reset(OpenEnginePipe()); |
169 enginePipe->WriteMessage(message); | 169 enginePipe->WriteMessage(message); |
170 inputBuffer = enginePipe->ReadMessage(); | 170 inputBuffer = enginePipe->ReadMessage(); |
171 } | 171 } |
172 catch (const std::exception& e) | 172 catch (const std::exception& ex) |
173 { | 173 { |
174 DEBUG_GENERAL(e.what()); | 174 DEBUG_EXCEPTION(ex); |
175 return false; | 175 return false; |
176 } | 176 } |
177 DEBUG_GENERAL("CallEngine end"); | 177 DEBUG_GENERAL("CallEngine end"); |
178 return true; | 178 return true; |
179 } | 179 } |
180 | 180 |
181 bool CAdblockPlusClient::CallEngine(Communication::ProcType proc, Communication:
:InputBuffer& inputBuffer) | 181 bool CAdblockPlusClient::CallEngine(Communication::ProcType proc, Communication:
:InputBuffer& inputBuffer) |
182 { | 182 { |
183 Communication::OutputBuffer message; | 183 Communication::OutputBuffer message; |
184 message << proc; | 184 message << proc; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 { | 252 { |
253 bool isHidden; | 253 bool isHidden; |
254 m_criticalSectionFilter.Lock(); | 254 m_criticalSectionFilter.Lock(); |
255 { | 255 { |
256 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); | 256 isHidden = filter && filter->IsElementHidden(tag, pEl, domain, indent); |
257 } | 257 } |
258 m_criticalSectionFilter.Unlock(); | 258 m_criticalSectionFilter.Unlock(); |
259 return isHidden; | 259 return isHidden; |
260 } | 260 } |
261 | 261 |
262 CAdblockPlusClient::ExceptionFilter CAdblockPlusClient::IsWhitelistedUrl(const s
td::wstring& url) | 262 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) |
| 263 { |
| 264 return !GetWhitelistingFilter(url).empty(); |
| 265 } |
| 266 |
| 267 std::string CAdblockPlusClient::GetWhitelistingFilter(const std::wstring& url) |
263 { | 268 { |
264 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str()); | 269 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str()); |
265 ExceptionFilter exceptionFilter; | 270 Communication::OutputBuffer request; |
266 Communication::OutputBuffer request; | 271 request << Communication::PROC_GET_WHITELISTING_FITER << ToUtf8String(url); |
267 request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url); | 272 |
268 | 273 Communication::InputBuffer response; |
269 Communication::InputBuffer response; | 274 if (!CallEngine(request, response)) |
270 if (!CallEngine(request, response)) | 275 return ""; |
271 return exceptionFilter; | 276 |
272 | 277 std::string filterText; |
273 response >> exceptionFilter.filterText; | 278 response >> filterText; |
274 | 279 |
275 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" end").c_str()); | 280 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" end").c_str()); |
276 return exceptionFilter; | 281 return filterText; |
277 } | 282 } |
278 | 283 |
279 bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url) | 284 bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url) |
280 { | 285 { |
281 Communication::OutputBuffer request; | 286 Communication::OutputBuffer request; |
282 request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << ToUtf8String(
url); | 287 request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << ToUtf8String(
url); |
283 | 288 |
284 Communication::InputBuffer response; | 289 Communication::InputBuffer response; |
285 if (!CallEngine(request, response)) | 290 if (!CallEngine(request, response)) |
286 return false; | 291 return false; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 DEBUG_GENERAL("CompareVersions"); | 568 DEBUG_GENERAL("CompareVersions"); |
564 Communication::OutputBuffer request; | 569 Communication::OutputBuffer request; |
565 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S
tring(v2); | 570 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S
tring(v2); |
566 Communication::InputBuffer response; | 571 Communication::InputBuffer response; |
567 if (!CallEngine(request, response)) | 572 if (!CallEngine(request, response)) |
568 return 0; | 573 return 0; |
569 int result; | 574 int result; |
570 response >> result; | 575 response >> result; |
571 return result; | 576 return result; |
572 } | 577 } |
LEFT | RIGHT |