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

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

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Left Patch Set: update to fixed libadblockplus Created Nov. 24, 2014, 11:07 a.m.
Right Patch Set: rebase and remove member of CFilter Created Feb. 4, 2015, 12:50 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/AdblockPlusDomTraverser.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 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 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
1 #include "PluginStdAfx.h" 18 #include "PluginStdAfx.h"
2 #include "PluginSettings.h" 19 #include "PluginSettings.h"
3 #include "PluginSystem.h" 20 #include "PluginSystem.h"
4 #include "PluginFilter.h" 21 #include "PluginFilter.h"
5 #include "PluginClientFactory.h" 22 #include "PluginClientFactory.h"
6 #include "PluginMutex.h" 23 #include "PluginMutex.h"
7 #include "PluginClass.h" 24 #include "PluginClass.h"
8 25
9 #include "AdblockPlusClient.h" 26 #include "AdblockPlusClient.h"
10 27
11 #include "../shared/Utils.h" 28 #include "../shared/Utils.h"
12 29
13 namespace 30 namespace
14 { 31 {
15 void SpawnAdblockPlusEngine() 32 void SpawnAdblockPlusEngine()
16 { 33 {
17 std::wstring engineExecutablePath = GetDllDir() + L"AdblockPlusEngine.exe"; 34 std::wstring engineExecutablePath = GetDllDir() + L"AdblockPlusEngine.exe";
18 CString params = to_CString(L"AdblockPlusEngine.exe " + GetBrowserLanguage() ); 35 CString params = ToCString(L"AdblockPlusEngine.exe " + GetBrowserLanguage()) ;
19 36
20 STARTUPINFO startupInfo = {}; 37 STARTUPINFO startupInfo = {};
21 PROCESS_INFORMATION processInformation = {}; 38 PROCESS_INFORMATION processInformation = {};
22 39
23 HANDLE token; 40 HANDLE token;
24 OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &token); 41 OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &token);
25 42
26 TOKEN_APPCONTAINER_INFORMATION *acs = NULL; 43 TOKEN_APPCONTAINER_INFORMATION *acs = NULL;
27 DWORD length = 0; 44 DWORD length = 0;
28 45
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 297
281 Communication::InputBuffer response; 298 Communication::InputBuffer response;
282 if (!CallEngine(request, response)) 299 if (!CallEngine(request, response))
283 return false; 300 return false;
284 301
285 bool isWhitelisted; 302 bool isWhitelisted;
286 response >> isWhitelisted; 303 response >> isWhitelisted;
287 return isWhitelisted; 304 return isWhitelisted;
288 } 305 }
289 306
290 int CAdblockPlusClient::GetIEVersion()
291 {
292 //HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
293 HKEY hKey;
294 LSTATUS status = RegOpenKey(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Interne t Explorer", &hKey);
295 if (status != 0)
296 {
297 return 0;
298 }
299 DWORD type, cbData;
300 BYTE version[50];
301 cbData = 50;
302 status = RegQueryValueEx(hKey, L"Version", NULL, &type, (BYTE*)version, &cbDat a);
303 if (status != 0)
304 {
305 return 0;
306 }
307 RegCloseKey(hKey);
308 return (int)(version[0] - 48);
309 }
310
311 bool CAdblockPlusClient::Matches(const std::wstring& url, AdblockPlus::FilterEng ine::ContentType contentType, const std::wstring& domain) 307 bool CAdblockPlusClient::Matches(const std::wstring& url, AdblockPlus::FilterEng ine::ContentType contentType, const std::wstring& domain)
312 { 308 {
313 Communication::OutputBuffer request; 309 Communication::OutputBuffer request;
314 request << Communication::PROC_MATCHES << ToUtf8String(url) << static_cast<int 32_t>(contentType) << ToUtf8String(domain); 310 request << Communication::PROC_MATCHES << ToUtf8String(url) << static_cast<int 32_t>(contentType) << ToUtf8String(domain);
315 311
316 Communication::InputBuffer response; 312 Communication::InputBuffer response;
317 if (!CallEngine(request, response)) 313 if (!CallEngine(request, response))
318 return false; 314 return false;
319 315
320 bool match; 316 bool match;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 request << Communication::PROC_CHECK_FOR_UPDATES << reinterpret_cast<int32_t>( callbackWindow); 524 request << Communication::PROC_CHECK_FOR_UPDATES << reinterpret_cast<int32_t>( callbackWindow);
529 CallEngine(request); 525 CallEngine(request);
530 } 526 }
531 527
532 std::wstring CAdblockPlusClient::GetDocumentationLink() 528 std::wstring CAdblockPlusClient::GetDocumentationLink()
533 { 529 {
534 DEBUG_GENERAL("GetDocumentationLink"); 530 DEBUG_GENERAL("GetDocumentationLink");
535 Communication::InputBuffer response; 531 Communication::InputBuffer response;
536 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response)) 532 if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response))
537 return L""; 533 return L"";
538 std::wstring docLink; 534 std::string docLink;
539 response >> docLink; 535 response >> docLink;
540 return docLink; 536 return ToUtf16String(docLink);
541 } 537 }
542 538
543 bool CAdblockPlusClient::TogglePluginEnabled() 539 bool CAdblockPlusClient::TogglePluginEnabled()
544 { 540 {
545 DEBUG_GENERAL("TogglePluginEnabled"); 541 DEBUG_GENERAL("TogglePluginEnabled");
546 Communication::InputBuffer response; 542 Communication::InputBuffer response;
547 if (!CallEngine(Communication::PROC_TOGGLE_PLUGIN_ENABLED, response)) 543 if (!CallEngine(Communication::PROC_TOGGLE_PLUGIN_ENABLED, response))
548 return false; 544 return false;
549 bool currentEnabledState; 545 bool currentEnabledState;
550 response >> currentEnabledState; 546 response >> currentEnabledState;
(...skipping 19 matching lines...) Expand all
570 DEBUG_GENERAL("CompareVersions"); 566 DEBUG_GENERAL("CompareVersions");
571 Communication::OutputBuffer request; 567 Communication::OutputBuffer request;
572 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S tring(v2); 568 request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8S tring(v2);
573 Communication::InputBuffer response; 569 Communication::InputBuffer response;
574 if (!CallEngine(request, response)) 570 if (!CallEngine(request, response))
575 return 0; 571 return 0;
576 int result; 572 int result;
577 response >> result; 573 response >> result;
578 return result; 574 return result;
579 } 575 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld