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

Delta Between Two Patch Sets: src/plugin/AdblockPlusClient.cpp

Issue 5115380229996544: Issue 1104 - Cannot uncheck Disable on website option in tool bar (Closed)
Left Patch Set: change the interface Created March 5, 2015, 11:30 a.m.
Right Patch Set: rename and rebase Created March 13, 2015, 4:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/AdblockPlusClient.h ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url) 262 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url)
263 { 263 {
264 return !GetWhitelistingFilter(url).empty();
265 }
266
267 std::string CAdblockPlusClient::GetWhitelistingFilter(const std::wstring& url)
268 {
269 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str());
270 Communication::OutputBuffer request;
271 request << Communication::PROC_GET_WHITELISTING_FITER << ToUtf8String(url);
272
273 Communication::InputBuffer response;
274 if (!CallEngine(request, response))
275 return "";
276
264 std::string filterText; 277 std::string filterText;
265 return IsWhitelistedUrl(url, filterText);
266 }
267
268 bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url, std::string& filterText)
269 {
270 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str());
271 Communication::OutputBuffer request;
272 request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url);
273
274 Communication::InputBuffer response;
275 if (!CallEngine(request, response))
276 return false;
277
278 response >> filterText; 278 response >> filterText;
279 279
280 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" end").c_str()); 280 DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" end").c_str());
281 return !filterText.empty(); 281 return filterText;
282 } 282 }
283 283
284 bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url) 284 bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url)
285 { 285 {
286 Communication::OutputBuffer request; 286 Communication::OutputBuffer request;
287 request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << ToUtf8String( url); 287 request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << ToUtf8String( url);
288 288
289 Communication::InputBuffer response; 289 Communication::InputBuffer response;
290 if (!CallEngine(request, response)) 290 if (!CallEngine(request, response))
291 return false; 291 return false;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 DEBUG_GENERAL("CompareVersions"); 568 DEBUG_GENERAL("CompareVersions");
569 Communication::OutputBuffer request; 569 Communication::OutputBuffer request;
570 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S tring(v2); 570 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S tring(v2);
571 Communication::InputBuffer response; 571 Communication::InputBuffer response;
572 if (!CallEngine(request, response)) 572 if (!CallEngine(request, response))
573 return 0; 573 return 0;
574 int result; 574 int result;
575 response >> result; 575 response >> result;
576 return result; 576 return result;
577 } 577 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld