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

Delta Between Two Patch Sets: src/engine/Main.cpp

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Left Patch Set: remove debugging code Created Nov. 24, 2014, 11:09 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 | « adblockplus.gyp ('k') | src/plugin/AdblockPlusClient.h » ('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 <AdblockPlus.h> 18 #include <AdblockPlus.h>
2 #include <functional> 19 #include <functional>
3 #include <vector> 20 #include <vector>
4 #include <thread> 21 #include <thread>
5 #include <Windows.h> 22 #include <Windows.h>
6 23
7 #include "../shared/AutoHandle.h" 24 #include "../shared/AutoHandle.h"
8 #include "../shared/Communication.h" 25 #include "../shared/Communication.h"
9 #include "../shared/Dictionary.h" 26 #include "../shared/Dictionary.h"
10 #include "../shared/Utils.h" 27 #include "../shared/Utils.h"
11 #include "../shared/Version.h" 28 #include "../shared/Version.h"
12 #include "../shared/CriticalSection.h" 29 #include "../shared/CriticalSection.h"
30 #include "../shared/IE_version.h"
13 #include "AdblockPlus.h" 31 #include "AdblockPlus.h"
14 #include "Debug.h" 32 #include "Debug.h"
15 #include "Updater.h" 33 #include "Updater.h"
16 34
17 namespace 35 namespace
18 { 36 {
19 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; 37 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine;
20 std::auto_ptr<Updater> updater; 38 std::auto_ptr<Updater> updater;
21 int activeConnections = 0; 39 int activeConnections = 0;
22 CriticalSection activeConnectionsLock; 40 CriticalSection activeConnectionsLock;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 { 99 {
82 Communication::OutputBuffer response; 100 Communication::OutputBuffer response;
83 101
84 Communication::ProcType procedure; 102 Communication::ProcType procedure;
85 request >> procedure; 103 request >> procedure;
86 switch (procedure) 104 switch (procedure)
87 { 105 {
88 case Communication::PROC_MATCHES: 106 case Communication::PROC_MATCHES:
89 { 107 {
90 std::string url; 108 std::string url;
109 using namespace AdblockPlus;
110 std::string documentUrl;
91 int32_t type; 111 int32_t type;
92 std::string documentUrl;
93 request >> url >> type >> documentUrl; 112 request >> url >> type >> documentUrl;
94 referrerMapping.Add(url, documentUrl); 113 referrerMapping.Add(url, documentUrl);
95 auto contentType = static_cast<AdblockPlus::FilterEngine::ContentType>(t ype); 114 auto contentType = static_cast<FilterEngine::ContentType>(type);
96 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, contentType, referrerMapping.BuildReferrerChain(documentUrl)); 115 FilterPtr filter = filterEngine->Matches(url, contentType, referrerMappi ng.BuildReferrerChain(documentUrl));
97 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX CEPTION); 116 response << (filter && filter->GetType() != Filter::TYPE_EXCEPTION);
98 break; 117 break;
99 } 118 }
100 case Communication::PROC_GET_ELEMHIDE_SELECTORS: 119 case Communication::PROC_GET_ELEMHIDE_SELECTORS:
101 { 120 {
102 std::string domain; 121 std::string domain;
103 request >> domain; 122 request >> domain;
104 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain)); 123 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain));
105 break; 124 break;
106 } 125 }
107 case Communication::PROC_AVAILABLE_SUBSCRIPTIONS: 126 case Communication::PROC_AVAILABLE_SUBSCRIPTIONS:
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 case Communication::PROC_COMPARE_VERSIONS: 339 case Communication::PROC_COMPARE_VERSIONS:
321 { 340 {
322 std::string v1, v2; 341 std::string v1, v2;
323 request >> v1 >> v2; 342 request >> v1 >> v2;
324 343
325 response << filterEngine->CompareVersions(v1, v2); 344 response << filterEngine->CompareVersions(v1, v2);
326 break; 345 break;
327 } 346 }
328 case Communication::PROC_GET_DOCUMENTATION_LINK: 347 case Communication::PROC_GET_DOCUMENTATION_LINK:
329 { 348 {
330 response << ToUtf16String(filterEngine->GetPref("documentation_link")->A sString()); 349 response << filterEngine->GetPref("documentation_link")->AsString();
331 break; 350 break;
332 } 351 }
333 case Communication::PROC_TOGGLE_PLUGIN_ENABLED: 352 case Communication::PROC_TOGGLE_PLUGIN_ENABLED:
334 { 353 {
335 filterEngine->SetPref("enabled", filterEngine->GetJsEngine()->NewValue(! filterEngine->GetPref("enabled")->AsBool())); 354 filterEngine->SetPref("enabled", filterEngine->GetJsEngine()->NewValue(! filterEngine->GetPref("enabled")->AsBool()));
336 response << filterEngine->GetPref("enabled")->AsBool(); 355 response << filterEngine->GetPref("enabled")->AsBool();
337 break; 356 break;
338 } 357 }
339 case Communication::PROC_GET_HOST: 358 case Communication::PROC_GET_HOST:
340 { 359 {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine(const std::wstring& locale) 437 std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine(const std::wstring& locale)
419 { 438 {
420 AdblockPlus::AppInfo appInfo; 439 AdblockPlus::AppInfo appInfo;
421 appInfo.version = ToUtf8String(IEPLUGIN_VERSION); 440 appInfo.version = ToUtf8String(IEPLUGIN_VERSION);
422 appInfo.name = "adblockplusie"; 441 appInfo.name = "adblockplusie";
423 #ifdef _WIN64 442 #ifdef _WIN64
424 appInfo.application = "msie64"; 443 appInfo.application = "msie64";
425 #else 444 #else
426 appInfo.application = "msie32"; 445 appInfo.application = "msie32";
427 #endif 446 #endif
428 // TODO: Set applicationVersion parameter 447 appInfo.applicationVersion = ToUtf8String(AdblockPlus::IE::InstalledVersionStr ing());
429 appInfo.locale = ToUtf8String(locale); 448 appInfo.locale = ToUtf8String(locale);
430 #ifdef ADBLOCK_PLUS_TEST_MODE 449 #ifdef ADBLOCK_PLUS_TEST_MODE
431 appInfo.developmentBuild = true; 450 appInfo.developmentBuild = true;
432 #else 451 #else
433 appInfo.developmentBuild = false; 452 appInfo.developmentBuild = false;
434 #endif 453 #endif
435 454
436 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); 455 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo);
437 jsEngine->SetEventCallback("updateAvailable", &OnUpdateAvailable); 456 jsEngine->SetEventCallback("updateAvailable", &OnUpdateAvailable);
438 457
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 506 }
488 catch (const std::runtime_error& e) 507 catch (const std::runtime_error& e)
489 { 508 {
490 DebugException(e); 509 DebugException(e);
491 return 1; 510 return 1;
492 } 511 }
493 } 512 }
494 513
495 return 0; 514 return 0;
496 } 515 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld